Flip Video Horizontally with FFmpeg hflip

This article provides a quick and straightforward guide on how to flip a video horizontally using FFmpeg’s built-in hflip video filter. You will learn the exact command-line syntax required to mirror your video files, understand the key parameters of the command, and see practical examples for processing your media efficiently.

To flip a video horizontally (creating a mirror effect), you need to use FFmpeg’s video filter graph option (-vf) followed by the hflip filter.

The Basic Command

Open your terminal or command prompt and run the following command:

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

Command Breakdown

Optimizing the Process

Applying a video filter requires FFmpeg to re-encode the video stream. However, you do not need to re-encode the audio stream. To save processing time and maintain original audio quality, you can copy the audio track directly using the -c:a copy parameter:

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

Specifying Video Quality and Codecs

If you want to control the quality of the output video during the re-encoding process, you can specify the video codec (such as H.264) and the Constant Rate Factor (CRF). A CRF value between 18 and 23 offers a good balance between quality and file size:

ffmpeg -i input.mp4 -vf "hflip" -c:v libx264 -crf 23 -c:a copy output.mp4