---
title: "Rotate a Video With FFmpeg: 90°, 180° | rotate.video"
description: "Copy-paste FFmpeg commands to rotate a video 90°, 180° or 270°, flip it, or change only the rotation flag without re-encoding. Or skip the terminal."
url: https://rotate.video/rotate-video-ffmpeg
---

Free · runs in your browser

# How to rotate a video with FFmpeg

Tested commands for quarter turns, flips and lossless rotation flags, plus the gotcha that turns a clip twice. Rather click than type? The tool is right here.

**Quick answer:** to turn a video 90° clockwise, run `ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4`. Use `transpose=2` for 90° anticlockwise, and `hflip,vflip` for 180°. Those commands re-encode the picture. To change only the orientation flag, with no re-encode at all, use `ffmpeg -display_rotation:v:0 -90 -i input.mp4 -c copy output.mp4`.

We ran every command on this page with FFmpeg 7.1 on a 1920×1080 H.264 clip then checked each output’s orientation and frame size and compared the alternatives frame by frame. The options are the same on Windows, macOS and Linux; only the batch loops differ.

## Rotate a video with FFmpeg in four steps

1. ### Install FFmpeg
On Windows, run `winget install Gyan.FFmpeg`; on a Mac with Homebrew, `brew install ffmpeg`; on Linux, use your package manager. Check it with `ffmpeg -version`.
2. ### Work out which way to turn
Play the clip. If the top of the picture needs to go to the right, you want clockwise (`transpose=1`); if it needs to go left, anticlockwise (`transpose=2`).
3. ### Run the command
Open a terminal in the folder with the clip and run the command for your turn, with your own file names. `-c:a copy` keeps the sound exactly as it was.
4. ### Check the result
Open the new file in a couple of players. If it has been turned twice, the source had a rotation flag; the troubleshooting section below explains why.

## Rotate 90° clockwise or anticlockwise with transpose

The `transpose` filter turns the picture a quarter at a time and swaps the width and height, so a 1920×1080 clip comes out 1080×1920.

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

`transpose=1` turns 90° clockwise and `transpose=2` turns 90° anticlockwise. The values 0 and 3 also flip the picture as they turn (0 is anticlockwise plus a vertical flip, 3 is clockwise plus a vertical flip), which is rarely what a sideways phone clip needs.

Add `:passthrough=portrait` (as in `transpose=1:passthrough=portrait`) to leave clips that are already taller than they are wide alone. That’s handy when you run one command over a mixed folder.

## Rotate a video 180°

```
ffmpeg -i input.mp4 -vf "hflip,vflip" -c:a copy output.mp4
```

Flipping both ways gives exactly the same picture as a half turn, in a single filter pass. `transpose=2,transpose=2` produces an identical result; in our test the two outputs matched frame for frame. The frame size doesn’t change. For phone clips that only play upside down somewhere, see [fixing an upside-down video](https://rotate.video/rotate-video-180-degrees).

## Flip a video horizontally or vertically

```
ffmpeg -i input.mp4 -vf hflip -c:a copy output.mp4
```

```
ffmpeg -i input.mp4 -vf vflip -c:a copy output.mp4
```

`hflip` mirrors left to right, which un-mirrors a backwards webcam or selfie recording ([why recordings come out mirrored](https://rotate.video/mirrored-video)). `vflip` mirrors top to bottom. To flip and turn in one pass, chain the filters with a comma, for example `-vf "transpose=1,hflip"`.

## Lossless: change only the rotation flag

MP4 and MOV files can carry a display matrix that tells players which way up to show the picture. Changing it rewrites a few bytes in the file’s header and copies the video stream untouched, so it takes seconds and costs nothing in quality.

```
ffmpeg -display_rotation:v:0 -90 -i input.mp4 -c copy output.mp4
```

`-display_rotation` is an input option, so it goes before `-i`, and it counts anticlockwise: `-90` shows the video turned 90° clockwise, `90` turns it anticlockwise and `180` turns it upside down. It **replaces** any rotation already in the file rather than adding to it, so for a phone clip that already carries a flag, give the final orientation you want; `0` clears the flag.

The option arrived in FFmpeg 6\. On current builds the older `-metadata:s:v:0 rotate=90` trick only writes a text tag that players ignore, which we confirmed on 7.1\. There is also `-display_hflip` to flag a mirror image, but fewer players honour it, so use `hflip` for anything you’re going to share.

Browsers, VLC, QuickTime and phone galleries all respect the flag. Some older TVs, hardware players and editing apps ignore it and show the stored orientation, so re-encode with `transpose` for those. [Rotating without losing quality](https://rotate.video/rotate-video-without-losing-quality) explains the trade-off in more detail.

## Keep the quality and the sound when you re-encode

Any `-vf` filter means the video is encoded again. FFmpeg’s default for MP4 is libx264 at CRF 23, which is fine for sharing but softer than a phone original. Set the quality yourself for a closer match:

```
ffmpeg -i input.mp4 -vf "transpose=1" -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4
```

A lower CRF means higher quality and a bigger file; 18 is usually indistinguishable from the source. `-c:a copy` keeps the soundtrack bit for bit. Add `-movflags +faststart` if the file will play from a website, so playback can begin before the download finishes. To keep an iPhone HEVC clip in HEVC, use `-c:v libx265 -crf 22 -tag:v hvc1`; Apple’s players need the `hvc1` tag.

## Why the video turned twice, and other surprises

* **Turned twice.** FFmpeg applies a source’s rotation flag before your filters (autorotate). If you add `-noautorotate`, the original flag is copied to the output on top of your `transpose`, and players turn the picture again. In our test that produced a portrait file still flagged −90°. Leave autorotate on, which is the default.
* **Still sideways after a flag change.** The player ignores display matrices. Re-encode with `transpose` so the pixels themselves turn.
* **The turn looks backwards.** `-display_rotation` counts anticlockwise while `transpose=1` is clockwise. If a metadata change goes the wrong way, swap the sign.
* **No sound in the output.** Some sources have audio that MP4 can’t hold as it is. Replace `-c:a copy` with `-c:a aac -b:a 192k`.

## Rotate by any angle

```
ffmpeg -i input.mp4 -vf "rotate=3*PI/180:fillcolor=black" -c:a copy output.mp4
```

The `rotate` filter takes radians, so multiply degrees by PI/180; positive values turn clockwise. It keeps the original frame size, so the corners of the turned picture are cut off and the gaps are painted with `fillcolor`. To zoom past the gaps, add `scale` and `crop` after it, or use the Straighten slider with **Fill** in the tool above, which works out the zoom for you ([straightening a tilted video](https://rotate.video/straighten-tilted-video)).

## Rotate every video in a folder

In Windows PowerShell, from the folder with the clips:

```
Get-ChildItem *.mp4 | ForEach-Object { ffmpeg -i $_.Name -vf "transpose=1" -c:a copy ("rotated-" + $_.Name) }
```

In Terminal on macOS or Linux (bash or zsh):

```
mkdir -p rotated && for f in *.mp4; do ffmpeg -i "$f" -vf "transpose=1" -c:a copy "rotated/$f"; done
```

Both leave the originals alone. Swap in any of the filters above, or the `-display_rotation … -c copy` form for a lossless batch.

## Or skip the terminal

For a clip or two, the tool at the top of this page does the same jobs with buttons. With the default settings, **Turn right** and **Turn left** write the rotation flag like `-display_rotation` (lossless and almost instant), **Mirror** is `hflip`, **Flip vertically** is `vflip`, and **Maximum compatibility** under More options bakes the turn into the pixels like `transpose`. It runs in the browser on Windows, Mac, Linux and [Chromebook](https://rotate.video/rotate-video-chromebook), and nothing is uploaded.

## FFmpeg rotation FAQ

### Does FFmpeg rotate re-encode the video?

With `transpose`, `hflip`, `vflip` or `rotate`, yes: filters change the pixels, so the video stream is encoded again. Changing only the display rotation with `-display_rotation` and `-c copy` re-encodes nothing.

### Why does my video still look sideways after setting the rotate flag?

Either the player ignores rotation metadata, or the command used the old `-metadata:s:v rotate=` form, which current FFmpeg writes as a plain tag. Put `-display_rotation` before `-i`, or re-encode with `transpose` so the picture itself turns.

### Which transpose value is clockwise?

`transpose=1` is 90° clockwise and `transpose=2` is 90° anticlockwise. 0 and 3 add a vertical flip to the turn.

### How do I rotate by an arbitrary angle in FFmpeg?

Use the `rotate` filter in radians, for example `rotate=5*PI/180` for 5° clockwise. The corners are cut off and filled with `fillcolor` unless you scale and crop afterwards.

### How do I rotate a video without losing the audio?

Add `-c:a copy` so the soundtrack is copied untouched while only the picture is processed. With `-c copy` for a flag-only change, both streams are copied.

### Do the same commands work on an iPhone MOV?

Yes. iPhone clips already carry a rotation flag, which FFmpeg applies before your filters, so judge the turn from how the clip looks in a player. More on these files in [rotating a MOV file](https://rotate.video/rotate-mov-file).

## More rotation and flip guides

* [ Rotate a video online Turn any video 90°, 180° or 270° in your browser. Quarter turns are lossless. ](https://rotate.video/)
* [ Rotate a video without losing quality Which turns are lossless, which settings break that, and how to check. ](https://rotate.video/rotate-video-without-losing-quality)
* [ Rotate a MOV file from an iPhone or camera MOV in, MP4 out, with HEVC clips copied untouched on a quarter turn. ](https://rotate.video/rotate-mov-file)
* [ How to rotate a video in Windows Clipchamp on Windows 10 and 11, or a lossless MP4 turn in the browser. ](https://rotate.video/rotate-video-windows)
* [ How to rotate a video on a Mac QuickTime Player, Photos, iMovie, or a lossless turn in Safari. ](https://rotate.video/rotate-video-mac)
* [ Rotate a video in DaVinci Resolve Inspector rotation, flips, vertical timelines and the Deliver page. ](https://rotate.video/rotate-video-davinci-resolve)
* [ How to rotate a video on a Chromebook Turn a clip in Chrome and save it to Downloads, with no app needed. ](https://rotate.video/rotate-video-chromebook)
