I have three videos s1.mp4,s2.mp4 s3.mp4 and I need to combine three videos side by side I know use hstack but my three videos has different size?

I've found following commands.It works,but only support two videos.

ffmpeg -i s1.mp4 -i s2.mp4 -filter_complex "[1:v][0:v]scale2ref[wm][base];[base][wm]hstack=2" final.mp4
up vote 1 down vote accepted

Use

ffmpeg -i s1.mp4 -i s2.mp4 -i s3.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)'" final.mp4
  • I tried with this code,strill without any luck [libx264 @ 0x7f9334838e00] width not divisible by 2 (637x160) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height @Gyan – gs z Nov 8 at 5:31
  • Added filter at end – Gyan Nov 8 at 6:11
  • It works!!!you're awesome,Thank you:) @Gyan – gs z Nov 8 at 6:41
  • Can you tell me How to use "VSTACK" in this case? @Gyan – gs z Nov 14 at 11:04

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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