Concat a video with itself, but in reverse, using ffmpeg

帅比萌擦擦* 提交于 2019-12-18 12:33:20

问题


I was able to reverse with:

ffmpeg -i input.mp4 -vf reverse output_reversed.mp4

And I can concat with:

ffmpeg -i input.mp4 -i input.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4

But can I concat with a reverse version of the video, with a single command?

What I am trying to achieve is a ping pong effect, where the video plays once, then plays backwards right after.

Thanks!


回答1:


Technically, you can do it using

ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][0:a][r] [0:a]concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4

But the reverse filter will use a lot of memory for large videos. I've added a fifo filter to avoid frame drops. But test and see. (I haven't reversed the audio)

If your clip has no audio, the above command will throw an error – instead, use:

ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" output.mp4


来源:https://stackoverflow.com/questions/42257354/concat-a-video-with-itself-but-in-reverse-using-ffmpeg

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