Rotate and flip video with FFmpeg: phone footage, EXIF metadata, and the right approach
Rotate phone-shot video to correct orientation, flip horizontally for mirror effect, or strip EXIF rotation metadata that confuses some players.
When to use this
You rotate or flip video for phone-shot content recorded sideways (orientation metadata works in some players, fails in others — re-encoding with the correct rotation is universal), creating mirror effects (selfie-mode where on-screen text needs to read correctly), or generating multiple aspect-ratio variants from one source. The orientation problem is more common than most teams realize: iOS records EXIF rotation tags that desktop players ignore.
Command variants
ffmpeg -i input.mp4 \
-vf "transpose=1" \
-c:v libx264 -preset medium -crf 21 \
-c:a copy \
output.mp4transpose=1 rotates 90° clockwise. transpose=2 rotates 90° counter-clockwise.
ffmpeg -i input.mp4 \
-vf "transpose=1,transpose=1" \
-c:v libx264 -preset medium -crf 21 \
-c:a copy \
output.mp4Chain two transposes for 180°. Or use -vf "hflip,vflip" which is equivalent.
ffmpeg -i input.mp4 \
-vf "hflip" \
-c:v libx264 -preset medium -crf 21 \
-c:a copy \
output.mp4Mirrors left-right. Useful for selfie-mode video where on-screen text needs to read correctly.
ffmpeg -i input.mp4 \
-metadata:s:v rotate=0 \
-c copy \
output.mp4Removes the rotation metadata without re-encoding. Useful when player support is uneven.
What each parameter does
transpose=N0=90° counter-clockwise + vertical flip, 1=90° clockwise, 2=90° counter-clockwise, 3=90° clockwise + vertical flip. Most common: 1 (clockwise) and 2 (counter-clockwise).
hflipHorizontal flip (left-right mirror).
vflipVertical flip (top-bottom flip).
-metadata:s:v rotate=0Set the video stream's rotation metadata to 0 without re-encoding. Stream-copy with this flag strips the rotation tag.
What this outputs
A re-encoded (or stream-copied) video file with the rotation/flip applied. Re-encoding is required for transpose/hflip/vflip; stream-copy works only for metadata stripping.
Pitfalls
- EXIF rotation metadata is interpreted differently across players. Web/Chrome usually respects it; QuickTime sometimes doesn't; FFmpeg-based tooling sometimes mishandles it. For universal playback, re-encode with the correct rotation rather than relying on metadata.
- Stripping metadata without re-encoding doesn't change pixel data — players that ignored the tag will still play correctly; players that respected the tag will now show the original (uncorrected) orientation.
- Rotating/flipping resets aspect ratio. Players display the new orientation natively but downstream tooling may need explicit aspect-ratio updates.
- Phones often record at high resolution (4K/60fps) — rotating these is expensive. For social-media output where lower resolution is acceptable, scale before rotating to save compute.
- Transpose chains (transpose=1,transpose=1 for 180°) are equivalent to hflip+vflip but slightly slower. Use hflip+vflip for 180° rotations.
At production scale
Rotation requires re-encoding (libx264-bound), so it's not free at scale. For UGC pipelines processing phone-shot content, the rotation step roughly doubles the encoding cost. NVENC GPU encoding handles rotation natively at GPU speeds.
MpegFlow detects orientation metadata at ingest and routes phone-shot content to a rotation stage automatically. The audit log records both the original and corrected orientation.
- FFmpeg
- rotate
- flip
- video-operations