How to Combine hflip and vflip in FFmpeg

Flipping a video both horizontally and vertically in FFmpeg is a common task when correcting video orientation or creating mirror effects. This article provides the exact command-line syntax required to combine the hflip and vflip video filters into a single command, ensuring a fast and efficient execution without the need for multiple rendering passes.

To combine horizontal and vertical flips in a single FFmpeg command, you must chain the two filters together using a comma (,) within the video filter (-vf) argument.

The Standard Command

Use the following command structure to apply both filters:

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

How It Works

  • -i input.mp4: Specifies the path to your source video file.
  • -vf: Tells FFmpeg that you are applying video filters.
  • "hflip,vflip": This is the filter chain. The comma acts as a connector, telling FFmpeg to first apply the horizontal flip (hflip) and then apply the vertical flip (vflip) to the output of the first filter before rendering.
  • output.mp4: The name of the newly flipped video file.

Performance Optimization (Copying Audio)

By default, FFmpeg will re-encode the audio stream. To speed up the process and preserve the original audio quality without re-encoding, add the -c:a copy flag:

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

This command applies the visual flip effects to the video stream while copying the audio stream directly, saving processing time and system resources.