How to Flip a Video Vertically with FFmpeg vflip

This guide provides a quick and straightforward demonstration of how to flip a video vertically using the FFmpeg command-line tool. You will learn the exact command-line syntax for the vflip filter, how to apply it to your video files, and how to combine it with other filters for advanced video manipulation.

The Basic Vertical Flip Command

To flip a video vertically (upside down), you need to use the video filter flag (-vf) followed by the vflip filter. Run the following command in your terminal:

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

Here is a breakdown of what this command does: * -i input.mp4: Specifies the path to your input video file. * -vf "vflip": Applies the video filter named vflip, which mirrors the video along the horizontal axis. * output.mp4: Specifies the name of the newly created output file.

Preserving Audio Quality

By default, FFmpeg will re-encode the audio stream. To speed up the process and preserve the exact quality of your original audio, you should copy the audio stream instead of re-encoding it by using the -c:a copy parameter:

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

Controlling Video Quality and Codec

If you want to ensure the output video maintains high quality, you can explicitly specify the video codec (like H.264) and set a Constant Rate Factor (CRF). A CRF value between 18 and 23 offers an excellent balance between quality and file size:

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

Doing a Vertical and Horizontal Flip Simultaneously

If you want to flip the video both vertically and horizontally (which effectively rotates the video 180 degrees), you can chain the vflip and hflip filters together, separated by a comma:

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