使用ffmpeg将两个视频添加到画布


0

我修改了这个示例代码( https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos ):

ffmpeg
    -i 1.avi -i 2.avi -i 3.avi -i 4.avi
    -filter_complex "
        nullsrc=size=640x480 [base];
        [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
        [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
        [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
        [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
        [base][upperleft] overlay=shortest=1 [tmp1];
        [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
        [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
        [tmp3][lowerright] overlay=shortest=1:x=320:y=240
    "
    -c:v libx264 output.mkv

仅使用两个视频(左和右):

./ffmpeg -i 1.avi -i 2.avi -filter_complex "nullsrc=size=1856x578 [base]; [0:v] setpts=PTS-STARTPTS, scale=928x578 [upperleft];[1:v] setpts=PTS-STARTPTS, scale=928x578 [upperright];[base][upperleft] overlay=shortest=1 [tmp1]; [tmp1][upperright]overlay=shortest=1:x=320 [tmp2] " -c:v libx264 combo.avi

但我总是得到以下错误:

Filter overlay has an unconnected output

任何帮助都会很棒。非常感谢你。

Answers:


1

使用适应的代码,它应该是

ffmpeg -i 1.avi -i 2.avi -filter_complex "nullsrc=size=1856x578[base];[0:v] setpts=PTS-STARTPTS,scale=928x578[upperleft];[1:v]setpts=PTS-STARTPTS, scale=928x578[upperright];[base][upperleft] overlay=shortest=1 [tmp1]; [tmp1][upperright]overlay=shortest=1:x=320 [tmp2] " -map "[tmp2]" -c:v libx264 combo.avi

你可能想确认一下 x 叠加层中的值。我把它保持不变但它可能应该是 928


但更好的方法是

ffmpeg -i 1.avi -i 2.avi -filter_complex "[0:v][1:v]hstack" -c:v libx264 combo.avi
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.