Presenting more than 2 videos using FFmpeg [duplic

2019-08-08 03:00发布

This question already has an answer here:

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.

标签: ffmpeg
1条回答
贼婆χ
2楼-- · 2019-08-08 03:33

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
查看更多
登录 后发表回答