How to Flip Video Vertically with FFmpeg

This article explains how to use the FFmpeg vflip video filter to flip videos vertically (upside down). You will learn the basic command syntax for vertical flipping, how to combine it with other filters like horizontal flipping, and how to apply these changes while maintaining optimal video and audio quality.

Basic Vertical Flip Command

To flip a video vertically, use the -vf (video filter) flag followed by the vflip filter. The basic command structure is as follows:

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

Here is what each part of the command does: * -i input.mp4: Specifies the path to your input video file. * -vf "vflip": Applies the video filter named vflip to flip the image upside down. * output.mp4: Specifies the name and format of the resulting output file.

Flipping Vertically and Horizontally

If you need to flip your video both vertically and horizontally (which is equivalent to a 180-degree rotation), you can chain the vflip and hflip filters together by separating them with a comma:

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

Preserving Video and Audio Quality

By default, FFmpeg will re-encode the video stream when applying filters. To ensure the output maintains high video quality and to avoid unnecessary re-encoding of the audio track, you can specify the audio codec to be copied directly and set a constant rate factor (CRF) for the video:

ffmpeg -i input.mp4 -vf "vflip" -c:a copy -crf 20 output.mp4