How to Reverse a Video using FFmpeg

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.

ffmpeg.exe -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
Founder at OTTVerse

Krishna Rao Vijayanagar, Ph.D., is the Editor-in-Chief of OTTVerse, a news portal covering tech and business news in the OTT industry.

With extensive experience in video encoding, streaming, analytics, monetization, end-to-end streaming, and more, Krishna has held multiple leadership roles in R&D, Engineering, and Product at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers and speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.

Pallycon Broadcast Asia Show 2024

3 thoughts on “How to Reverse a Video using FFmpeg”

  1. 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.

  2. Pingback: Stack Videos Horizontally, Vertically, in a Grid With FFmpeg - OTTVerse

  3. Pingback: FFMPEG Tutorial basics – Blogs- Outsource-online Internet Solutions

Leave a Comment

Your email address will not be published. Required fields are marked *

Enjoying this article? Subscribe to OTTVerse and receive exclusive news and information from the OTT Industry.