FFMPEG 动画 GIF 叠加,动画在指定'between'之前开始



我正在添加一个动画gif作为视频的叠加,使用如下命令:

ffmpeg -y -i video.mp4 -i overlay.gif -filter_complex "[0:v][1:v] overlay=38:11:enable='between(t,1.35,15.042000)'" -pix_fmt yuv420p -c:a copy -safe 0 output.mp4

在那个命令中,我要求它显示从1.35到15的gif,并且在覆盖只在这些时间之间显示的情况下工作,但它就好像动画在达到1.35之前开始,因为在那个点之前的动画位从来没有出现在屏幕上。最后的视频缺少动画的开头。

试过ffmpeg-20180925-a7429d8和ffmpeg-N-100581-ga454a0c14f

通常,我在发布后找到答案:

https://dev.to/oskarahl/ffmpeg-overlay-a-video-on-a-video-after-x-seconds-4fc9

Solution:
Use the setpts filter to delay the overlay video (gif.mp4) start with x seconds.
ffmpeg -i main_video.mp4 -i gif.mp4 -filter_complex
“[1:v]setpts=PTS-STARTPTS+1/TB[delayedGif];
[0:v][delayedGif]overlay=enable='between(t,1,3)'[out]”
-map [out] complete.mp4
The setpts filter evaluates its expression and assigns the value as the timestamp for the current frame it is processing.

最新更新