我只是使用这个代码建立于使用 ffmpeg 叠加视频并插入视频背景循环
ffmpeg -i main.mp4
-vf "movie=bg.mp4:loop=200,hue=s=0[bg];
[in]setpts=PTS/2,scale=iw/2:-1,pad=iw+20:ih+20:10:10:color=yellow[m];
[bg][m]overlay=shortest=1:x=(W-w)/2:y=(H-h)/2"
-af "atempo=2.0,volume=1.5" -c:v libx264 completed.mkv
但我遇到了很多丢帧的情况:
frame= 578 fps= 14 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=499 speed=
frame= 578 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=525 speed=0.448
frame= 578 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=553 speed=0.443x
Past duration 0.999992 too large
frame= 579 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=577 speed=0.438x
frame= 579 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=609 speed=0.433x
frame= 579 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=637 speed=0.428x
frame= 579 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=670 speed=0.423x
frame= 579 fps= 13 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=701 speed=0.418x
frame= 579 fps= 12 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=728 speed=0.414x
frame= 579 fps= 12 q=24.0 size= 30585kB time=00:00:19.24 bitrate=13019.6kbits/s dup=0 drop=756 speed=0.409x
frame= 579 fps= 12 q=-1.0 Lsize= 35007kB time=00:00:19.29 bitrate=14863.5kbits/s dup=0 drop=783 speed=0.406x
答案1
使用
ffmpeg -i main.mp4
-filter_complex "movie=bg.mp4:loop=200,setpts=N/FRAME_RATE/TB[bg];
[0]scale=iw/2:-1,pad=iw+20:ih+20:10:10:color=yellow[m];
[bg][m]overlay=shortest=1:x=(W-w)/2:y=(H-h)/2"
-c:v libx264 completed.mkv
您可能需要根据视频的相对大小调整比例参数。