TechEarl

How to Reverse a Video with ffmpeg

Reverse a video with ffmpeg using the reverse filter for picture and areverse for sound. Why you must write to a new output file, and why you trim before you reverse.

Ishan Karunaratne⏱️ 6 min readUpdated
Share thisCopied
Reverse a video from the command line with ffmpeg: the reverse video filter, the areverse audio filter, and the new-output-file rule that keeps the source intact.

To reverse a video with ffmpeg, run the reverse video filter and write the result to a new file:

bash
ffmpeg -i input.mp4 -vf reverse reversed.mp4

That plays the picture backwards but leaves the audio untouched, so the sound runs forward over a reversed image. To reverse the sound too, add the areverse audio filter:

bash
ffmpeg -i input.mp4 -vf reverse -af areverse reversed.mp4

The single most important thing on this page is the output filename. Use a name that is different from the input. A common copy-pasted command reverses a file onto itself (ffmpeg -i clip.mp4 -vf reverse clip.mp4), and ffmpeg opens that same file for writing while it is still reading from it. The result is a truncated, corrupted clip and a lost original. There is no undo. Always reverse into a fresh path.

Reverse the picture only (drop the audio)

If you want a silent reversed clip, do not reverse the audio backwards, just discard it. -an means "no audio":

bash
ffmpeg -i input.mp4 -vf reverse -an reversed.mp4

This is the right command for a reversed loop, a boomerang-style effect, or any clip where the original audio would be noise played backwards. Dropping the track is also faster and uses less memory than reversing it.

Reverse both the picture and the sound

For a clip where the reversed audio is the point (speech played backwards, a sound effect run in reverse), pair the two filters. -vf is the video filter chain, -af is the audio filter chain:

bash
ffmpeg -i input.mp4 -vf reverse -af areverse reversed.mp4

reverse flips the order of the video frames; areverse flips the order of the audio samples. Run them together and the whole clip plays end-to-start, picture and sound in step.

Why you should trim first: the memory trap

Here is the catch that bites people on anything longer than a short clip: the reverse filter buffers the entire video stream into memory before it can write the first reversed frame. It has to, because the last frame of the input becomes the first frame of the output, so ffmpeg cannot emit anything until it has read everything. A few seconds of 1080p is fine. A feature-length file will exhaust your RAM, swap hard, or get killed outright.

So reverse a segment, not the whole movie. Trim the part you actually want first, then reverse that. Seeking before -i makes the cut fast, and the trimmed file is what you reverse:

bash
# Cut a ~4 second segment from around 12 seconds, no re-encode
# -c copy snaps to the nearest keyframe, so the cut is fast but not frame-exact
ffmpeg -ss 00:00:12 -t 4 -i input.mp4 -c copy segment.mp4

# Reverse the short segment (cheap on memory)
ffmpeg -i segment.mp4 -vf reverse -af areverse reversed.mp4

You can also do it in one command with the trim filters, but the two-step version is easier to reason about and lets you check the segment before you commit to reversing it. See trim and cut a video with ffmpeg for the full set of trimming options, including -to for an absolute end timestamp and the keyframe-versus-frame-accurate tradeoff.

areverse is cheaper on memory than reverse because audio samples are tiny next to decoded video frames, but it still buffers the whole audio stream. The video side is the one that hurts, so the trim-first rule is about the picture.

If a video genuinely must be reversed in full and it does not fit in RAM, the workaround is to split it into chunks, reverse each chunk, then concatenate them back together in reverse chunk order. That is a real technique but a rare need; for almost everything, trim the segment you want and reverse that.

A note on quality

-vf reverse re-encodes the video (you cannot stream-copy a filtered stream), so the output is a fresh encode at ffmpeg's defaults. If you care about the encode, add the usual libx264 controls:

bash
ffmpeg -i segment.mp4 -vf reverse -af areverse -c:v libx264 -crf 18 -preset slow reversed.mp4

Lower -crf is higher quality (18 is visually near-lossless for x264); -preset slow spends more time for a smaller file. These are the same knobs covered in the ffmpeg commands cheat sheet.

FAQ

See also

Sources

Authoritative references this article was fact-checked against.

Tagsffmpegreverse videoareversevideo filterCLIcommand linevideo editing

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Tech Architect · Software Engineer · AI/DevOps

Tech architect and software engineer with 20+ years building software, Linux systems, and DevOps infrastructure, and lately working AI into the stack. Currently Chief Technology Officer at a healthcare tech startup, which is where most of these field notes come from.

Keep reading

Related posts

How to Crop a Video with ffmpeg

Crop a video with ffmpeg's crop filter: crop=w:h:x:y from the top-left origin, centered crops with in_w/in_h expressions, square crops for social, and cropdetect to strip black bars automatically.

How to Trim or Cut a Video with ffmpeg

Trim or cut a video from the command line with ffmpeg: the fast lossless -c copy way, the keyframe gotcha that makes your cut land early, and the frame-accurate re-encode. With -ss and -to/-t explained.

How to Speed Up or Slow Down a Video with ffmpeg

Change a video's speed from the command line with ffmpeg: setpts for the video, atempo for the audio, why you still chain atempo in steps of 2.0 even though it now accepts up to 100, and keeping both tracks in sync.