顺序拼接三个视频
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] concat=n=3:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -y output.mp4
顺序拼接四个视频
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] [3:0][3:1]concat=n=4:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -y output.mp4
说明[x:0][x:1] x代表第几个视频(从零开始,数组就是如此),0是视频通道,1是音频通道,所以添加规则就是多少个视频,就添加多少个[n-1:0][n-1:1],最后concat=n=x是多少个视频
说明提供的视频都是同一个音视频格式和具有相同的分辨率,否则拼接出错(提供一个1536x864的视频画面拼接到1920x1080视频画面)
[Parsed_concat_0 @ 000001805df80780] Input link in0:v0 parameters (size 1536x864, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1920x1080, SAR 1:1)
[Parsed_concat_0 @ 000001805df80780] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #3:0
Conversion failed!