FFmpeg · Command Guide

How to Rotate or Flip a Video With FFmpeg

Fixing an upside-down or sideways clip — usually from a phone recorded in the wrong orientation, or metadata that a platform doesn't respect.

Fixing an upside-down or sideways clip — usually from a phone recorded in the wrong orientation, or metadata that a platform doesn't respect.

The command

ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4

What each flag does

transpose=1Rotates 90 degrees clockwise. Use 2 for 90° counter-clockwise, or chain transpose=1,transpose=1 for 180°.

Where this goes wrong

Sometimes a clip looks upside down in one player but correct in another — that means the file has a rotation metadata flag rather than actually rotated pixels. Re-rotating the pixels on top of that metadata produces a video that's rotated twice in players that respect the flag.

Fixing rotation metadata instead of the pixels

ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=0 output.mp4

This strips the rotation flag entirely without touching the actual video data — instant, and the right fix when the pixels are already correct but a stray flag is causing inconsistent playback.

Flipping instead of rotating

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

Use vflip for a vertical (upside-down) flip instead of horizontal mirroring.

After the command

Orientation fixes are a raw-footage cleanup step — the kind of thing worth automating once and forgetting, same philosophy behind a locked video template.

See the templates

Common questions

How do I know if it's a metadata issue or actual rotation?+
Check with ffprobe input.mp4 — look for a rotate tag in the stream metadata. If it's present and non-zero, that's likely the cause.
Does rotating with transpose cost quality?+
Yes, slightly — transpose requires re-encoding since it rearranges pixel data, unlike a metadata fix which is lossless and instant.
Can I rotate by an arbitrary angle, not just 90/180/270?+
Yes, with the rotate filter (different from the metadata tag) — e.g. rotate=5*PI/180 for a 5-degree tilt, though this requires padding to avoid cropping corners.