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.mp4What each flag does
| transpose=1 | Rotates 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.mp4This 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.mp4Use vflip for a vertical (upside-down) flip instead of horizontal mirroring.
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 templatesCommon questions
How do I know if it's a metadata issue or actual rotation?+
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?+
Can I rotate by an arbitrary angle, not just 90/180/270?+
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.