ffmpeg -i in.mp4 -vf transpose=1 out.mp4 turns a video 90 degrees clockwise, 1920x1080 into 1080x1920, and transpose=2 turns it the other way. ReelSDK rotates a 10-second clip for under half a cent at $0.02 per compute minute.
Rotate and flip a video with ffmpeg
transpose turns the picture by 90 degrees and swaps width and height; ReelSDK's API runs it as is but refuses the rotation flag that skips the re-encode. For 180 degrees and mirrors, hflip and vflip do the work.
GuidesUpdated
ffmpeg -i landscape.mp4 -vf "transpose=1" -c:a copy rotated.mp4transpose=1 rotates every frame clockwise, so a 1920x1080 landscape clip becomes a 1080x1920 portrait one. The video is re-encoded and the audio copied.
Variations
The other commands you will need
Rotate 90 degrees counter-clockwise
transpose=2turns the other way. Same 1080x1920 output.counter-clockwise ffmpeg -i landscape.mp4 -vf "transpose=2" -c:a copy ccw.mp4Rotate 180 degrees
Flipping both ways is the same as turning the picture upside down, and the size stays 1920x1080.
upside-down ffmpeg -i landscape.mp4 -vf "hflip,vflip" -c:a copy upside-down.mp4Mirror the picture
hflipswaps left and right, the usual fix for a selfie camera;vflipswaps top and bottom.mirror ffmpeg -i landscape.mp4 -vf hflip -c:a copy mirrored.mp4Change only the rotation flag
-display_rotationsets the rotation players apply, in degrees counter-clockwise, so -90 means a quarter turn clockwise. With-c copynothing is re-encoded, so it takes a fraction of a second, and the frames stay stored at 1920x1080.flag ffmpeg -display_rotation -90 -i landscape.mp4 -c copy tagged.mp4
The flags
The flags in these commands
| Flag | What it does | Used here |
|---|---|---|
transpose=1 | Rotates 90 degrees clockwise and swaps width and height | Clockwise |
transpose=2 | Rotates 90 degrees counter-clockwise | Counter-clockwise |
transpose=0, transpose=3 | Rotate and mirror in one step; 0 is the default when you give no value | Not used |
hflip | Mirrors the picture left to right | Mirror, 180 degrees |
vflip | Mirrors the picture top to bottom | 180 degrees |
-display_rotation -90 | Sets the rotation flag, in degrees counter-clockwise, without touching the frames | Flag only |
-c:a copy | Keeps the audio as it is while the video is re-encoded | All re-encodes |
Sources: ffmpeg filters: transpose, ffmpeg filters: hflip, ffmpeg documentation: video options, checked November 2026.
Rotate the pixels or set a flag
There are two ways to turn a video. transpose, hflip and vflip change the pixels, so every frame is re-encoded and the result looks the same in every player. -display_rotation leaves the frames alone and writes a rotation value players are meant to apply; that took a fraction of a second on our clip because nothing was encoded.
We checked that the flag points the same way as the filter: the first frame decoded from the flagged file was pixel for pixel the same as transpose=1 applied to that frame. Software that ignores the flag still shows the original 1920x1080 picture, so rotate the pixels when the video goes to people you don't control.
Why a phone video plays sideways
When a file looks upright in one player and sideways in another, it carries a rotation flag. ffmpeg applies it when it decodes, because -autorotate is on by default, so a re-encode writes upright pixels and drops the flag.
That also means a filter you add sees the picture already turned. If the video is upright in ffmpeg's output but you want it turned further, add transpose on top. To work on the stored frames instead, put -noautorotate before -i.
From landscape to portrait
Rotating a landscape clip gives a portrait video, but the picture lies on its side. For a vertical 9:16 video with the scene upright, crop or scale instead: the crop guide cuts a 9:16 window out of a 16:9 frame, and vertical video dimensions lists the sizes each platform wants.
Without installing ffmpeg
The same command as one API call
Send the same args to POST /v1/ffmpeg with the video's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this rotation finished in about 10 seconds and cost under half a cent. The rotation flag is the one thing that doesn't carry over: the API answers -display_rotation with 400 INVALID_REQUEST and args[0]: -display_rotation is not supported, so rotate the pixels with transpose there.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"landscape.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
},
"args": [
"-i", "landscape.mp4", "-vf", "transpose=1", "-c:a", "copy",
"rotated.mp4"
],
"outputs": ["rotated.mp4"]
}'FAQ
Questions, answered
How do I rotate a video 90 degrees with ffmpeg?
Use -vf transpose=1 for 90 degrees clockwise or transpose=2 for counter-clockwise. Width and height swap, so our 1920x1080 clip came out 1080x1920.
How do I rotate a video 180 degrees with ffmpeg?
Chain both flips: -vf "hflip,vflip". The size stays the same; our 1920x1080 clip stayed 1920x1080.
Can ffmpeg rotate a video without re-encoding?
Only by setting the rotation flag: ffmpeg -display_rotation -90 -i in.mp4 -c copy out.mp4 took a fraction of a second. The frames stay as they were, and software that ignores the flag shows them unrotated.
How do I mirror or flip a video horizontally?
Use -vf hflip for a left-to-right mirror and -vf vflip for top to bottom. Both re-encode the video; add -c:a copy to keep the audio as it is.
Can I rotate a video with an API?
Yes. Send the transpose command to POST https://api.reelsdk.com/v1/ffmpeg; it runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second, and failed jobs are free. The API refuses -display_rotation, so rotate the pixels.
- Crop a video with ffmpegCut a frame down with crop=w:h:x:y: a centered 9:16 or square crop, a fixed region, and cropdetect to find black bars.
- Vertical video dimensionsThe 9:16 sizes TikTok, Instagram Reels and YouTube Shorts ask for, and the ffmpeg commands that turn any clip into 1080x1920.
- Resize a video with ffmpegScale a video with scale=w:h: keep the aspect ratio with -2, fit a 1080x1920 frame with pad, and fix the odd-size error.
- Blurred background video with ffmpegFit a 16:9 clip into a 9:16 frame over a blurred copy of itself: scale, crop, gblur and overlay in one filter graph.
- ffmpeg -filter_complex explainedLabels, commas and semicolons: how a filtergraph wires inputs to outputs, with four working graphs and the errors they fix.
- Vertical videoTurn 16:9 footage into a 1080x1920 vertical video with a blurred fill in one ffmpeg call, about a quarter cent per 30 s clip.
- FFmpeg onlineRun your own ffmpeg command on your files in the browser, free and without installing or uploading anything.
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
