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

clockwise
ffmpeg -i landscape.mp4 -vf "transpose=1" -c:a copy rotated.mp4

transpose=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

  1. Rotate 90 degrees counter-clockwise

    transpose=2 turns the other way. Same 1080x1920 output.

    counter-clockwise
    ffmpeg -i landscape.mp4 -vf "transpose=2" -c:a copy ccw.mp4
  2. Rotate 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.mp4
  3. Mirror the picture

    hflip swaps left and right, the usual fix for a selfie camera; vflip swaps top and bottom.

    mirror
    ffmpeg -i landscape.mp4 -vf hflip -c:a copy mirrored.mp4
  4. Change only the rotation flag

    -display_rotation sets the rotation players apply, in degrees counter-clockwise, so -90 means a quarter turn clockwise. With -c copy nothing 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

The flags in these commands
FlagWhat it doesUsed here
transpose=1Rotates 90 degrees clockwise and swaps width and heightClockwise
transpose=2Rotates 90 degrees counter-clockwiseCounter-clockwise
transpose=0, transpose=3Rotate and mirror in one step; 0 is the default when you give no valueNot used
hflipMirrors the picture left to rightMirror, 180 degrees
vflipMirrors the picture top to bottom180 degrees
-display_rotation -90Sets the rotation flag, in degrees counter-clockwise, without touching the framesFlag only
-c:a copyKeeps the audio as it is while the video is re-encodedAll 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.

terminalTry it
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"]
  }'
rotated.mp4 from the API: 1080x1920 after transpose=1.Input: landscape.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.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains