1

I found this answer for combining 2 videos using Ffmpeg

ffmpeg.exe -i LeftInput.mp4 -vf "[in] scale=iw/2:ih/2, pad=2*iw:ih [left]; 
    movie=RightInput.mp4, scale=iw/3:ih/3, fade=out:300:30:alpha=1 [right]; 
    [left][right] overlay=main_w/2:0 [out]" -b:v 768k Output.mp4

Is there a way to combine more than 2?

I tried adding [bottom] and [upper] but I'm failing to understand how the overlay works and where do I put more videos.

llogan
  • 121,796
  • 28
  • 232
  • 243
Mooshy
  • 75
  • 1
  • 7
  • in the command i posted i can combine 2 videos into 1 and watch them as 1 file, i want to do the same with more then just 2 videos – Mooshy Dec 08 '12 at 09:56

1 Answers1

10

Use the FFmpeg hstack and vstack filters:

enter image description here

ffmpeg -i input0 -i input1 -i input2 -i input3 -filter_complex \
"[0:v][1:v]hstack[top]; \
 [2:v][3:v]hstack[bottom]; \
 [top][bottom]vstack" \
output

If you want to combine the audio add the amerge filter:

ffmpeg -i input0 -i input1 -i input2 -i input3 -filter_complex \
"[0:v][1:v]hstack[top]; \
 [2:v][3:v]hstack[bottom]; \
 [top][bottom]vstack[v]; \
 [0:a][1:a][2:a][3:a]amerge=inputs=4[a]" \
-map "[v]" -map "[a]" -ac 2 output
llogan
  • 121,796
  • 28
  • 232
  • 243