I'd like to combine three videos into one vertically stacked video. The three videos have different width and height.

I can combine them horizontally successfully with this command:

ffmpeg -i s1.mp4 -i s2.mp4 -i temp.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih[1v][0v];[2:v][0v]scale2ref=oh*mdar:ih[2v][0v];[0v][1v][2v]hstack=3,scale='2*trunc(iw/2)':'2*trunc(ih/2)';[0:a:0][1:a:0][2:a:0] amix=inputs=3:duration=first:dropout_transition=0,dynaudnorm" final.mp4

How can I modify this command to stack them vertically?


For vertical stacking, the widths have to be equalized.


  • oh it works,thx!
    – Jesus Slim
    Nov 22 '18 at 6:37
  • @Gyan can you explain the parts of the above string?
    – maurice
    Dec 29 '20 at 18:55

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.