<div dir="ltr"><div>I am trying to overlay dvb subtitles with overlay cuda, i am transforming dvb subtitle rect from pal8 to rgba and sending rgba frame to subtitle buffer source context, and i want to overlay those subtitles on gpu, now overlay cuda accepts nv12 pixel format and i am trying to make configuration so that I convert rgba to nv12 upload it to nvidia device, scale image and overlay, but I get this errorĀ Impossible to convert between the formats supported by the filter 'overlay_cuda' and the filter 'auto_scale_1'. If anyone has experience with this I would appreciate your help.</div><div><br></div><div><div style="background-color:rgb(33,33,33);color:rgb(238,255,255)"><pre style="font-family:"Menlo",monospace;font-size:9pt"><span style="color:rgb(255,203,107)">std</span><span style="color:rgb(137,221,255)">::</span><span style="color:rgb(195,232,141)">string </span>subtitleArgs <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(255,203,107)">StringFmtUtil</span><span style="color:rgb(137,221,255)">::</span><span style="color:rgb(130,170,255)">format</span><span style="color:rgb(137,221,255)">(<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(195,232,141)">"video_size=%dx%d:pix_fmt=rgba:time_base=%d/%d:frame_rate=%d/%d:pixel_aspect=%d/%d"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">width</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">height</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">inputStreamTb</span><span style="color:rgb(137,221,255)">.</span>num<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">inputStreamTb</span><span style="color:rgb(137,221,255)">.</span>den<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">inputFps</span><span style="color:rgb(137,221,255)">.</span>num<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">inputFps</span><span style="color:rgb(137,221,255)">.</span>den<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">sampleAspectRatio</span><span style="color:rgb(137,221,255)">.</span>num<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">sampleAspectRatio</span><span style="color:rgb(137,221,255)">.</span>den<span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(130,170,255)">avfilter_graph_create_filter</span><span style="color:rgb(137,221,255)">(&</span>subBufferSrcCtx<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                             </span><span style="color:rgb(130,170,255)">avfilter_get_by_name</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(195,232,141)">"buffer"</span><span style="color:rgb(137,221,255)">),<br></span><span style="color:rgb(137,221,255)">                             </span><span style="color:rgb(195,232,141)">"sub_in"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                             </span>subtitleArgs<span style="color:rgb(137,221,255)">.</span><span style="color:rgb(130,170,255)">c_str</span><span style="color:rgb(137,221,255)">(),<br></span><span style="color:rgb(137,221,255)">                             </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                             </span>vFilterGraph<span style="color:rgb(137,221,255)">);<br><br></span></pre></div><div style="background-color:rgb(33,33,33);color:rgb(238,255,255)"><pre style="font-family:"Menlo",monospace;font-size:9pt"><span style="color:rgb(195,232,141)">AVBufferSrcParameters </span><span style="color:rgb(137,221,255)">*</span>inputParSub<span style="color:rgb(137,221,255)">;<br></span>inputParSub <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(130,170,255)">av_buffersrc_parameters_alloc</span><span style="color:rgb(137,221,255)">();<br></span><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(!</span>inputParSub<span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{</span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>time_base <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">inputStreamTb</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>width <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">width</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>height <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">height</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>sample_aspect_ratio <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">sampleAspectRatio</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>frame_rate <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">inputFps</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>format <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(247,140,108)">AV_PIX_FMT_RGBA</span><span style="color:rgb(137,221,255)">;<br></span>inputParSub<span style="color:rgb(137,221,255)">-></span>hw_frames_ctx <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(130,170,255)">av_buffer_ref</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(247,140,108)">hwFrameRef</span><span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(137,221,255)"><br></span>ret <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(130,170,255)">av_buffersrc_parameters_set</span><span style="color:rgb(137,221,255)">(</span>subBufferSrcCtx<span style="color:rgb(137,221,255)">, </span>inputParSub<span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(130,170,255)">av_freep</span><span style="color:rgb(137,221,255)">(&</span>inputParSub<span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(</span>ret <span style="color:rgb(137,221,255)">< </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{</span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br></span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(130,170,255)">avfilter_graph_create_filter</span><span style="color:rgb(137,221,255)">(&</span>hwUploadCudaCtx<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(130,170,255)">avfilter_get_by_name</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(195,232,141)">"hwupload_cuda"</span><span style="color:rgb(137,221,255)">),<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(195,232,141)">"upload_cuda"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span>vFilterGraph<span style="color:rgb(137,221,255)">) < </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{</span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(130,170,255)">release</span><span style="color:rgb(137,221,255)">();<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br></span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(130,170,255)">avfilter_graph_create_filter</span><span style="color:rgb(137,221,255)">(&</span>nv12FmtCtx<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(130,170,255)">avfilter_get_by_name</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(195,232,141)">"format"</span><span style="color:rgb(137,221,255)">),<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(195,232,141)">"nv12_fmt"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(195,232,141)">"pix_fmts=nv12"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span>vFilterGraph<span style="color:rgb(137,221,255)">) < </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{</span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(130,170,255)">release</span><span style="color:rgb(137,221,255)">();<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br></span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(199,146,234);font-style:italic">auto </span>subScaleArgs <span style="color:rgb(137,221,255)">= </span><span style="color:rgb(255,203,107)">StringFmtUtil</span><span style="color:rgb(137,221,255)">::</span><span style="color:rgb(130,170,255)">format</span><span style="color:rgb(137,221,255)">(<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(195,232,141)">"h=%d:w=%d"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">        </span><span style="color:rgb(247,140,108)">height</span><span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">width</span><span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(130,170,255)">avfilter_graph_create_filter</span><span style="color:rgb(137,221,255)">(&</span>scaleSubNppCtx<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(130,170,255)">avfilter_get_by_name</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(195,232,141)">"scale_npp"</span><span style="color:rgb(137,221,255)">),<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(195,232,141)">"scale_sub_npp"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span>subScaleArgs<span style="color:rgb(137,221,255)">.</span><span style="color:rgb(130,170,255)">c_str</span><span style="color:rgb(137,221,255)">(),<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span>vFilterGraph<span style="color:rgb(137,221,255)">) < </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{</span><span style="color:rgb(137,221,255)"><br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(130,170,255)">release</span><span style="color:rgb(137,221,255)">();<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br><br></span></pre><div style="background-color:rgb(33,33,33);color:rgb(238,255,255)"><pre style="font-family:"Menlo",monospace;font-size:9pt"><span style="color:rgb(199,146,234);font-style:italic">if </span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(130,170,255)">avfilter_graph_create_filter</span><span style="color:rgb(137,221,255)">(&</span>overlayCtx<span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(130,170,255)">avfilter_get_by_name</span><span style="color:rgb(137,221,255)">(</span><span style="color:rgb(195,232,141)">"overlay_cuda"</span><span style="color:rgb(137,221,255)">),<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(195,232,141)">"overlay_cuda"</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span><span style="color:rgb(199,146,234);font-style:italic">nullptr</span><span style="color:rgb(137,221,255)">,<br></span><span style="color:rgb(137,221,255)">                                 </span>vFilterGraph<span style="color:rgb(137,221,255)">) < </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">)<br></span><span style="color:rgb(137,221,255)">{<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(255,203,107);font-weight:bold">LOG</span><span style="color:rgb(137,221,255)">(</span>ERROR<span style="color:rgb(137,221,255)">) << </span>LOG_TAG <span style="color:rgb(137,221,255)"><< </span><span style="color:rgb(195,232,141)">" failed to overlay cuda filter"</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(130,170,255)">release</span><span style="color:rgb(137,221,255)">();<br></span><span style="color:rgb(137,221,255)">    </span><span style="color:rgb(199,146,234);font-style:italic">return false</span><span style="color:rgb(137,221,255)">;<br></span><span style="color:rgb(137,221,255)">}<br><br></span></pre><pre style="font-family:"Menlo",monospace;font-size:9pt"><span style="color:rgb(137,221,255)">// And linking them </span><br></pre><div style="background-color:rgb(33,33,33);color:rgb(238,255,255)"><pre style="font-family:"Menlo",monospace;font-size:9pt"><span style="color:rgb(130,170,255)">avfilter_link</span><span style="color:rgb(137,221,255)">(</span>subBufferSrcCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">, </span>nv12FmtCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(130,170,255)">avfilter_link</span><span style="color:rgb(137,221,255)">(</span>nv12FmtCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">, </span>hwUploadCudaCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(130,170,255)">avfilter_link</span><span style="color:rgb(137,221,255)">(</span>hwUploadCudaCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">, </span>scaleSubNppCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">);<br></span><span style="color:rgb(130,170,255)">avfilter_link</span><span style="color:rgb(137,221,255)">(</span>scaleSubNppCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">0</span><span style="color:rgb(137,221,255)">, </span>overlayCtx<span style="color:rgb(137,221,255)">, </span><span style="color:rgb(247,140,108)">1</span><span style="color:rgb(137,221,255)">);<br><br></span></pre></div></div></div></div></div>