How to Rotate Video with FFmpeg Transpose

Rotating a video is a common post-production task, and FFmpeg makes it highly efficient using the transpose video filter. This article provides a quick, practical guide on how to use the FFmpeg transpose filter to rotate your videos 90, 180, or 270 degrees, and how to combine rotation with flipping using simple command-line arguments.

To rotate a video in FFmpeg, you use the -vf (video filter) flag followed by the transpose filter and its corresponding numerical value.

The Transpose Filter Values

The transpose filter accepts the following integer values to determine the direction of rotation and flipping:

Basic Command Examples

Rotate 90 Degrees Clockwise

To rotate your video 90 degrees clockwise, use transpose=1:

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

Rotate 90 Degrees Counter-Clockwise

To rotate your video 90 degrees counter-clockwise, use transpose=2:

ffmpeg -i input.mp4 -vf "transpose=2" output.mp4

Rotate 180 Degrees

The transpose filter itself only handles 90-degree steps. To rotate a video 180 degrees, you can chain two transpose filters together:

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

Alternatively, you can achieve a 180-degree rotation more efficiently by using the horizontal flip (hflip) and vertical flip (vflip) filters together:

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

Rotate 270 Degrees Clockwise

Rotating 270 degrees clockwise is the same as rotating 90 degrees counter-clockwise. You can use:

ffmpeg -i input.mp4 -vf "transpose=2" output.mp4

Avoiding Re-encoding (When Applicable)

Note that using video filters like transpose requires FFmpeg to re-encode the video stream, which takes processing time. If you want to rotate the video instantly without re-encoding, you can try changing the rotation metadata instead:

ffmpeg -i input.mp4 -metadata:s:v rotate="90" -codec copy output.mp4

Note: Metadata rotation relies on the media player to respect the orientation tag. If compatibility is your priority, using the transpose filter to hard-recode the rotation is the recommended method.