Skip to content
systemcoding.dev
Media

Rotate 90 degrees with transpose=1

Rotate video 90 degrees clockwise in FFmpeg 7.1 with transpose=1, and use 2 for counter-clockwise or two filters for a half turn.

1 min read
Summarize in AI

transpose rotates by 90 degrees and swaps the width and height. The value picks the direction.

Shell
ffmpeg -i landscape.mp4 -vf "transpose=1" -c:v libx264 -crf 22 -c:a copy portrait.mp4
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 portrait.mp4
Text
1080,1920

Value 1 is 90 degrees clockwise, and 2 is 90 degrees counter-clockwise. The other two, 0 and 3, rotate and also flip vertically. For 180 degrees, chain it twice as transpose=1,transpose=1, or use hflip,vflip, which avoids a size swap. The full list is in the transpose filter documentation.

The filter decodes and re-encodes the picture, so it costs quality and time, unlike the rotation metadata in the display rotation row. FFmpeg also applies a phone's rotation flag by itself while transcoding, so check whether the source carries one first: transposing a file that is already flagged can give you the wrong result twice over. For an arbitrary angle there is the rotate filter.

Taggedffmpeg
Share

More snippets

Media

List ALSA devices with aplay -l

List the playback cards and devices ALSA sees with aplay -l from alsa-utils 1.2, and turn the output into a hw:card,device name.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.