concat 2不同图像大小的多轨视频

时间:2020-04-12 12:12:33

标签: ffmpeg concat

我尝试连接两个视频(1.mkv具有640:360图像大小,2.mkv具有1280:720图像大小),两个视频都有2个视频轨道和0个音频轨道。我尝试了这段代码:

ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[0:v:1]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v:0][1:v:1]concat=n=2:v=2:a=0[v]" -map "[v]" -c:v "libvpx" 1+2.mkv

但是我有错:

Filter pad has an unconnected output

1 个答案:

答案 0 :(得分:0)

您需要调整过滤器标签,并且需要在concat过滤器中将v=2更改为v=1

ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[1:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v1];[v0][v1]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.mkv

由于2.mkv已经是1280x720,因此您可以避免处理该输入:

ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.mkv