How to Flip Video Horizontally with FFmpeg

Flipping a video horizontally—often referred to as mirroring—is a common editing task easily achieved using FFmpeg’s built-in hflip video filter. This article provides a quick, step-by-step guide on how to use the hflip filter to mirror your videos, including the exact command line syntax and options for preserving audio quality.

To flip a video horizontally using FFmpeg, you need to use the video filter flag (-vf) followed by the hflip filter. The basic command structure is as follows:

ffmpeg -i input.mp4 -vf hflip output.mp4

Command Breakdown:

Preserving Audio Quality

By default, FFmpeg will re-encode both the video and the audio. To speed up the process and prevent any loss in audio quality, you can instruct FFmpeg to copy the audio stream directly without re-encoding it. Use the -c:a copy stream specifier:

ffmpeg -i input.mp4 -vf hflip -c:a copy output.mp4

Combining hflip with Other Filters

If you need to perform multiple transformations at once, such as flipping the video horizontally and vertically (which is equivalent to a 180-degree rotation), you can chain filters together using a comma:

ffmpeg -i input.mp4 -vf "hflip,vflip" -c:a copy output.mp4