Smartphone portrait video appearing sideways on your PC? Need to flip a video horizontally for a mirror effect? FFmpeg’s transpose filter fixes rotation in a single command. Understanding the difference between pixel re-encoding and metadata-only rotation lets you choose the fastest approach for your use case. Time to complete: 10 minutes.

Tested with: FFmpeg 6.1 (ubuntu-latest / GitHub Actions CI-validated)


What You Will Learn

  1. transpose filter values and rotation directions
  2. 90° clockwise, counter-clockwise, and 180° rotation commands
  3. hflip (horizontal flip) and vflip (vertical flip)
  4. Fixing smartphone portrait video orientation
  5. Metadata rotation vs. re-encoding — differences and when to use each
  6. Combining rotation with resizing
  7. Five common errors and fixes
  8. Five frequently asked questions

transpose Filter Value Reference

ValueAliasTransformation
0cclock_flip90° counter-clockwise + vertical flip
1clock90° clockwise (most common case)
2cclock90° counter-clockwise
3clock_flip90° clockwise + vertical flip

Command Examples

1. 90° Clockwise (Fix Smartphone Portrait Video)

# Fix portrait video appearing sideways in players
ffmpeg -i input.mp4 -vf transpose=1 -c:a copy output.mp4
  • transpose=1 — 90° clockwise (the most common fix for portrait mode video)
  • -c:a copy — copy audio without re-encoding

2. 90° Counter-Clockwise

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

3. 180° Rotation

# Chain transpose twice for 180°
ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" -c:a copy output.mp4

# Alternative: hflip + vflip (may be faster)
ffmpeg -i input.mp4 -vf "hflip,vflip" -c:a copy output.mp4

4. Horizontal Flip (Left-Right Mirror)

# Mirror left to right — selfie videos, mirror effects
ffmpeg -i input.mp4 -vf hflip -c:a copy output.mp4

5. Vertical Flip (Top-Bottom Mirror)

# Flip upside down — fix accidentally inverted recordings
ffmpeg -i input.mp4 -vf vflip -c:a copy output.mp4

6. Rotate + Resize in One Pass

# Rotate 90° clockwise, then resize to 720p
ffmpeg -i input.mp4 -vf "transpose=1,scale=1280:-2" -c:v libx264 -crf 23 -c:a copy output.mp4

Always apply transpose before scale — the scale filter sees the post-rotation dimensions.

7. Check Smartphone Video Rotation Metadata

# Inspect the rotate tag
ffprobe -v error -select_streams v:0 \
  -show_entries stream_tags=rotate \
  -of default=noprint_wrappers=1 input.mp4

Example output: rotate=90 → needs transpose=1


Metadata Rotation vs. Re-encoding Comparison

MethodProcessingQualityCompatibilitySpeed
Metadata edit (-c copy)Tag change onlyNo lossPlayer-dependentFast
transpose filterFull re-encodeSlight changeWorks in all playersNormal

When to use which:

  • Avoid re-encoding (quality priority) → metadata edit
  • Ensure correct display everywheretranspose filter

Metadata-only fix:

# Reset rotation tag to 0 without touching video pixels
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=0 output.mp4

Quick Reference Table

GoalCommand
90° clockwise-vf transpose=1
90° counter-clockwise-vf transpose=2
180°-vf "transpose=1,transpose=1" or "hflip,vflip"
Horizontal flip-vf hflip
Vertical flip-vf vflip
90° clockwise + vertical flip-vf transpose=3

Option Reference

Option / FilterMeaningUse When
-vf transpose=190° clockwise rotationFixing smartphone portrait video
-vf transpose=290° counter-clockwiseCorrecting over-rotated footage
-vf hflipHorizontal mirrorSelfie flip, mirror effect
-vf vflipVertical mirrorUpside-down footage fix
-c copyNo re-encodingMetadata-only rotation
-c:a copyLossless audio copyWhen applying video filters

Troubleshooting

Problem 1: Video Is Still Tilted After Rotation

Cause: Wrong transpose value (1 = clockwise, 2 = counter-clockwise confusion)
Fix: Try the other value:

# Try transpose=1 first; if the result is backwards, use transpose=2
ffmpeg -i input.mp4 -vf transpose=1 -c:a copy test.mp4

Problem 2: Output File Shows No Rotation

Cause: Incorrect -vf syntax
Fix: Check quotation and syntax:

# Wrong
ffmpeg -i input.mp4 -vf=transpose=1 output.mp4

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

Problem 3: Trailing option(s) found Error for 180° Rotation

Cause: Missing double quotes when chaining multiple filters
Fix: Wrap chained filters in double quotes:

# Wrong
ffmpeg -i input.mp4 -vf transpose=1,transpose=1 output.mp4

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

Problem 4: Video Still Appears Sideways After Metadata Edit

Cause: The player ignores the rotate metadata tag
Fix: Use transpose to rotate the actual video pixels:

ffmpeg -i input.mp4 -vf transpose=1 -c:v libx264 -crf 23 -c:a copy output.mp4

Problem 5: Resolution Is Unexpected After 90° Rotation

Cause: 90° rotation swaps width and height (1920×1080 → 1080×1920)
Fix: Add a scale filter after rotation:

# Rotate then scale with aspect ratio preserved
ffmpeg -i input.mp4 -vf "transpose=1,scale=1080:-2" -c:v libx264 -crf 23 output.mp4

FAQ

Q1. Should I always use transpose=1 for sideways smartphone video?
A. In most cases yes — transpose=1 (90° clockwise) fixes the most common portrait orientation issue. But check the rotate tag with ffprobe first: rotate=90 → use transpose=1; rotate=270 → use transpose=2.

Q2. Can I rotate without re-encoding?
A. Yes — using metadata only: ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=0 output.mp4. No pixels are changed, but the result depends on whether the player respects the metadata tag.

Q3. How do I convert iPhone/Android portrait video to landscape?
A. Use transpose=1 to rotate 90° clockwise. The aspect ratio changes, so combine with a scale filter if needed.

Q4. Can I rotate to an arbitrary angle like 45°?
A. Yes — use the rotate filter (areas outside the original frame become black):

# 45-degree rotation
ffmpeg -i input.mp4 -vf "rotate=PI/4" -c:v libx264 -crf 23 output.mp4

Q5. How do I batch-rotate multiple videos?

for f in *.mp4; do
  ffmpeg -nostdin -i "$f" -vf transpose=1 -c:a copy "rotated_${f}" -y
done


Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (GitHub Actions runner)
Primary sources: ffmpeg.org/ffmpeg-filters.html / ffmpeg.org/ffmpeg.html / trac.ffmpeg.org/wiki/RotateVideo