使用FFmpeg提供超过2个视频 [英] Presenting more than 2 videos using FFmpeg
本文介绍了使用FFmpeg提供超过2个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现使用Ffmpeg组合2个视频的这个答案
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: alpha = 1 [right];
[left] [right] overlay = main_w / 2:0 [out]-b:v 768k Output.mp4
有没有办法组合超过2?
我尝试添加底部]
和 [upper]
但我无法了解重叠式广告的工作原理,以及我在哪里放置更多视频。
解决方案
使用FFmpeg
ffmpeg -i input0 -i input1 -i input2 -i input3 -filter_complex \
[0:v] [1:v] hstack [顶端]; \
[2:v] [3:v] hstack [bottom]; \
[顶部] [底部] vstack\
输出
如果要组合音频,请添加 amerge 过滤器:
ffmpeg -i input0 -i input1 -i input2 -i input3 -filter_complex \
[0:v] [1:v] hstack [顶端]; \
[2:v] [3:v] hstack [bottom]; \
[top] [bottom] vstack [v]; \
[0:a] [1:a] [2:a] [3:a] amerge = inputs = 4 [a]\
-map[v] [a]-ac 2输出
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
这篇关于使用FFmpeg提供超过2个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文