ffmpeg - make a seamless loop with a crossfade

ぐ巨炮叔叔 提交于 2021-02-18 16:08:34

问题


I want to apply a crossfade to the last x frames of a video with the first x frames in order to obtain a seamless loop.

How can I do that?


回答1:


Let's say your video is 30 seconds long and your fade is 1 second long. Your command would be

ffmpeg -i video.mp4 -filter_complex
        "[0]split[body][pre];
         [pre]trim=duration=1,format=yuva420p,fade=d=1:alpha=1,setpts=PTS+(28/TB)[jt];
         [body]trim=1,setpts=PTS-STARTPTS[main];
         [main][jt]overlay"   output.mp4

The video is split into two identical streams. The first is trimmed to just the first second, has an alpha channel added, and then faded. The last filter on the first stream delays it by 28 seconds since the final output will have trimmed off the first second of the original clip and overlap with the last second. The 2nd stream is trimmed to start at t=1 and the processed first stream is overlaid on the 2nd. Since the alpha channel is faded in the first stream, it crossfades in.



来源:https://stackoverflow.com/questions/38186672/ffmpeg-make-a-seamless-loop-with-a-crossfade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!