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
transposefilter values and rotation directions- 90° clockwise, counter-clockwise, and 180° rotation commands
hflip(horizontal flip) andvflip(vertical flip)- Fixing smartphone portrait video orientation
- Metadata rotation vs. re-encoding — differences and when to use each
- Combining rotation with resizing
- Five common errors and fixes
- Five frequently asked questions
transpose Filter Value Reference
| Value | Alias | Transformation |
|---|---|---|
0 | cclock_flip | 90° counter-clockwise + vertical flip |
1 | clock | 90° clockwise (most common case) |
2 | cclock | 90° counter-clockwise |
3 | clock_flip | 90° 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
transposebeforescale— 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
| Method | Processing | Quality | Compatibility | Speed |
|---|---|---|---|---|
Metadata edit (-c copy) | Tag change only | No loss | Player-dependent | Fast |
transpose filter | Full re-encode | Slight change | Works in all players | Normal |
When to use which:
- Avoid re-encoding (quality priority) → metadata edit
- Ensure correct display everywhere →
transposefilter
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
| Goal | Command |
|---|---|
| 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 / Filter | Meaning | Use When |
|---|---|---|
-vf transpose=1 | 90° clockwise rotation | Fixing smartphone portrait video |
-vf transpose=2 | 90° counter-clockwise | Correcting over-rotated footage |
-vf hflip | Horizontal mirror | Selfie flip, mirror effect |
-vf vflip | Vertical mirror | Upside-down footage fix |
-c copy | No re-encoding | Metadata-only rotation |
-c:a copy | Lossless audio copy | When 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
Related Articles
- Scale and Resize Video — scale Filter Guide
- FFmpeg Command Basic Syntax — Inputs, Filters, and Outputs
- Trim and Cut Video — Complete Guide
- Add Watermark and Logo Overlay to Video
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