It’s very easy to reverse a video using FFmpeg because FFmpeg has a built-in
reverse filter that can do this job for both audio and video! Let’s learn how in this tutorial and some gotcha’s that you should avoid.
Reverse a Video using FFmpeg
Here it is! A simple one-liner that takes your video and reverses it.
ffmpeg -i originalVideo.mp4 -vf reverse reversedVideo.mp4
And if you want to reverse the audio and video, all you gotta do is use this command.
-i originalVideo.mp4 -vf reverse -af areverse reversedVideo.mp4
It’s as simple as that.
I used it on the Parkjoy sequence downloaded from xiph. Note, that the original video is in
y4m format and I first transcoded it to H.264/AVC using
crf=1 and then added timestamps for this fun experiment.
If you want to learn how to add timestamps to your video using the
drawtext filter, then read this tutorial on OTTVerse.com.
Here is the original sequence
And here is the reversed sequence – fun right?
Caution for Large Files
The problem with the
reverse filter is that it loads the sequence into memory and if you try this on large sequences, you could very easily run out of memory.
The solution for this is to split your video into small pieces or segments, reverse each of them, and join them in the reverse order (yea, remember that!).
If you don’t know how to cut a video into small pieces, check out our tutorial on trimming or cutting videos.
Krishna Rao Vijayanagar
Krishna Rao Vijayanagar, Ph.D. is the Editor-in-Chief of OTTVerse, a news portal covering technological and business news in the OTT space. With extensive experience in video compression, ABR streaming, video analytics, monetization, and more, Krishna has held multiple roles in R&D, Engineering, and Product ownership at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers on the latest trends in OTT and frequently speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.
3 thoughts on “How to Reverse a Video using FFmpeg”
Great! Sir, when I’m trying to concat the reversed and original video it is slowing down the video automatically. How can I do that using re-record? Both of the files being to same codec and extensions.
Pingback: Stack Videos Horizontally, Vertically, in a Grid With FFmpeg - OTTVerse
Pingback: FFMPEG Tutorial basics – Blogs- Outsource-online Internet Solutions