本文介绍了使用 ffmpeg 将视频与自身连接起来,但反过来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够逆转:
ffmpeg -i input.mp4 -vf reverse output_reversed.mp4
我可以连接:
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.
谢谢!
推荐答案
从技术上讲,您可以使用
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
但是对于大视频,反向过滤器会占用大量内存.我添加了一个 fifo
过滤器来避免掉帧.但测试看看.(我没调音频)
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
这篇关于使用 ffmpeg 将视频与自身连接起来,但反过来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!