问题描述:

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.

网友答案:

Use the FFmpeg hstack and vstack filters:

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
相关阅读:
Top