Rotate Video 180 Degrees with FFmpeg Transpose

This article provides a quick, step-by-step guide on how to rotate a video 180 degrees using the transpose video filter in FFmpeg. You will learn the exact command-line syntax required to chain the transpose filter, as well as a common alternative filter configuration for achieving the same result.

Using the Transpose Filter for 180-Degree Rotation

The FFmpeg transpose filter natively supports 90-degree rotation increments. To rotate a video 180 degrees using this filter, you must chain two 90-degree transpose operations together.

The parameter values for the transpose filter are:

  • 1: Rotates 90 degrees clockwise.
  • 2: Rotates 90 degrees counterclockwise.

To rotate the video 180 degrees, use the following command:

ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" output.mp4

Command Breakdown:

  • -i input.mp4: Specifies the path to your input video file.
  • -vf "transpose=1,transpose=1": Applies the video filter graph. The first transpose=1 rotates the video 90 degrees clockwise, and the second transpose=1 rotates it another 90 degrees clockwise, resulting in a total rotation of 180 degrees.
  • output.mp4: Specifies the name of the rotated output file.

Alternative Method: Using hflip and vflip

While chaining the transpose filter works perfectly, it can be computationally intensive because it processes the pixel grid orientation twice. A more efficient way to achieve a 180-degree rotation in FFmpeg is by combining the horizontal flip (hflip) and vertical flip (vflip) filters.

Run the following command for a faster 180-degree rotation:

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

This method flips the video both horizontally and vertically, achieving an identical 180-degree rotation with better processing performance.