I am sort of new to this. I am trying to create an output video using two videos and a background image.

End result should look like this. With a bit of gap around the videos and Video A having a larger scale than Video B. And, it should end at Video A's duration. Therefore, Video B should be cropped to Video A's duration.

This is what I have managed to do so far:


ffmpeg -loop 1 -i Image.jpg -i Test1.mp4 -filter_complex "overlay=(W-w)/2:shortest=1" Output.mp4


ffmpeg -i Test1.mp4 -i Test1.mp4 -filter_complex "[0:v][1:v]xstack=inputs=2:layout=0_0|w0_h0[v]" -map "[v]" -map 1:a Output.mp4
  • What are the resolutions of the image, video A and video B? How long are the videos?
    – Gyan
    Apr 21 '20 at 5:04
  • The resolution of both the image and video B is 1280x720 and the resolution of video A is 640x360. Video A is 4min 59sec and video B is 6min 5sec. I only used video A labelled as "Test1.mp4" so far.
    – DanteV.N.
    Apr 21 '20 at 5:11

I managed to solve this after some pondering.

ffmpeg -loop 1 -i Image.jpg -i Test1.mp4 -i Test2.mp4 -filter_complex "[2:v]tpad=stop=-1:stop_mode=clone[v2]; [1:v]scale=640-20:360-20[a]; [v2]scale=320-20:180-20[b]; [0:v][a]overlay=10:(main_h/2)-(overlay_h/2):shortest=1[c]; [c][b]overlay=main_w-overlay_w-10:(main_h/2)-(overlay_h/2)[video]" -shortest -map "[video]" -map 1:a -vsync 2 Output.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.