title: How to use the ffmpeg overlay_cuda filter to make a SBS video?
body: <p>FFMPEG a few months ago launched the new version of FFMPEG with the new filter &quot;overlay_cuda&quot;, this filter makes the same as the &quot;overlay&quot; but using an Nvidia card for applying it.</p>
  <p>I found on the FFMPEG website description of the filter, but no examples of how to use it. The only examples I found are from the developer commits but are to put a video or a photo over another video.</p>
  <p>I  before the normal overlay filter to do this using a nullsrc image with the twice of width but now I don't know how to with this filter.</p>
  <p>Commit description: <a href="https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200318071955.2329-1-yyyaroslav@gmail.com/" rel="nofollow noreferrer">https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200318071955.2329-1-yyyaroslav@gmail.com/</a>
  ffmpeg documentation webpage: <a href="https://ffmpeg.org/ffmpeg-filters.html#overlay_005fcuda-1" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#overlay_005fcuda-1</a></p>
  <p>I hope you can help me.</p>
  <p>Update:</p>
  <p>I made this FFmpeg order that:</p>
  <ol>
  <li>Input each video.</li>
  <li>The first video creates padding to the right and then is uploaded to the card's memory.</li>
  <li>With overlay Cuda, the other video puts on the right of the original video.</li>
  </ol>
  <pre class="lang-sh prettyprint-override"><code>ffmpeg -y -loglevel info \
  -i $video_1  \
  -hwaccel cuda -hwaccel_output_format cuda -i $video_2 \
  -filter_complex \
  &quot; \
  [0:v]pad=w=2*iw:h=ih:x=0:y=0,hwupload_cuda[base];
  [base][1:v]overlay_cuda=x=800:y=0&quot; \
  -an -c:v h264_nvenc overlay_test.mp4
  </code></pre>
  <p>But I get this error message:</p>
  <pre><code>[overlay_cuda @ 0x55fdec4b2ec0] Can't overlay nv12 on yuv420p 
  [Parsed_overlay_cuda_2 @ 0x55fdec4b2d80] Failed to configure output pad on Parsed_overlay_cuda_2
  Error reinitializing filters!
  Failed to inject frame into filter network: Invalid argument
  Error while processing the decoded data for stream #1:0
  </code></pre>
  <p>I have issues with the pixel formats, I hope you can help me.</p>
  <p>Update 2:</p>
  <p>I finally solved the pixel format issue and now makes the overlay with the padding (adds space to the overlay video)</p>
  <p>This is the command that succeeds:</p>
  <pre class="lang-sh prettyprint-override"><code>ffmpeg -y -loglevel info \
  -i $video_1  \
  -hwaccel cuda -hwaccel_output_format cuda -i $video_2 \
  -filter_complex \
  &quot; \
  [0:v]pad=w=2*iw:h=ih:x=0:y=0,hwupload_cuda,scale_npp=format=nv12[base];
  [base][1:v]overlay_cuda=x=800:y=0&quot; \
  -an -c:v h264_nvenc overlay_test.mp4
  
  </code></pre>
  <p>Now I want to change <code>x=800</code> to a variable like <code>x=iw+1</code> but it seems this filter doesn't support that. Is there a way to set a global variable?</p>