How to use FFMPEG overlay_cuda filter to create SBS video

FFMPEG a few months ago launched a new version with the new filter “overlay_cuda”, this filter makes the same as the “overlay” but using an Nvidia card for applying it.

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.

I know that the normal overlay filter can achieve this using a nullsrc image with the twice width but now I don’t know how to it with this filter.

Commit description: FFMPEG Commit discussion
Documentation webpage: Overlay_cuda filter FFMPEG docs

I hope you can help me.


I made this FFmpeg order that:

  1. Input each video.
  2. The first video creates padding to the right and then is uploaded to the card’s memory.
  3. With overlay Cuda, the other video puts on the right of the original video.
ffmpeg -y -loglevel info \
-i $video_1  \
-hwaccel cuda -hwaccel_output_format cuda -i $video_2 \
-filter_complex \
" \
[base][1:v]overlay_cuda=x=800:y=0" \
-an -c:v h264_nvenc overlay_test.mp4

But I get this error message:

[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

I have issues with the pixel formats, I hope you can help me.

Hi, I just found the solution:

ffmpeg -y -loglevel info \
-hwaccel cuda -hwaccel_output_format cuda -i $video_1  \
-hwaccel cuda -hwaccel_output_format cuda -i $video_2 \
-filter_complex \
[base][overlay_video]overlay_cuda=x='"$x_output_res"':y=0' \
-c:a copy -c:v h264_nvenc $out_video

I wrote on stack overflow a complete description about my solution: