How to Rotate A Video using FFmpeg Easily – OTTVerse

Sometimes when a video is captured wrong due to bad technique or simply bad luck, its useful to have a simple way to rotate it either clockwise or anti-clockwise.

Lucky for us, FFmpeg has a filter to rotate a video by specifying the direction. It takes a video as the input and a set of commands that you can use to instruct FFmpeg on how to rotate the video, and then FFmpeg will take care of the rest.

How to Rotate a Video 90° With FFmpeg?

Here is the command line for rotating a video using FFmpeg’s transpose filter.

ffmpeg -i inputVideo.mp4 -vf "transpose=dir=1" rotatedVideo.mp4

You are using the transpose filter using -vf in FFmpeg. This takes a set of parameters to control the direction of the transpose/flip/rotate operation and to prevent the transpose from taking place.

Let’s learn more about this.

Here are the options that are available in FFmpeg to rotate a video. You can either mention a number from 0 – 4 or the words cclock_flip, clock, cclock, or clock_flip.

0/cclock_flip = 90 degrees CounterCLockwise and Vertical Flip (default)
1/clock = 90 degrees Clockwise

2/clock = 90 degrees CounterClockwise
3/clock_flip = 90 degreeClockwise and Vertical Flip

How to Rotate a Video 180° With FFmpeg?

Let’s look at this use case now. How do you rotate a video 180° using the transpose command?

ffmpeg -i inputVideo.mp4 -vf "transpose=dir=2:transpose=dir=2" rotatedVideo.mp4

I used the ParkJoy sequence and flipped it 180 using this command. You can see the result for yourself in the video below. So basically, you are instructing FFmpeg to rotate the video 90 degrees counter-clockwise two times which totals up to 180 degrees.

Related:  LCEVC vs. AVC - Incredible 28% Gain at 3x Speed

How to Prevent Rotation for Landscape or Portrait Modes?

A typical use case for this is for post-processing videos captured from your mobile phone – some are probably in portrait mode and some are in landscape mode.

Now, if you use FFmpeg to process them as a batch, you probably want a way to tell FFmpeg to not rotate videos that are either in landscape or portrait mode.

Thankfully, there is an option for that as well in FFmpeg’s transpose filter.

ffmpeg.exe -i parkjoy.mp4 -vf "transpose=dir=2:passthrough=landscape" parkjoy-90-flip.mp4

The above commandline says that FFmpeg should transpose the video 90 degrees CounterClockwise ONLY if the video is NOT landscape mode.


I hope you understood how to rotate a video using FFmpeg. If you liked this, please let us know in the comments section, share the post with your friends, and check out the rest of our FFmpeg tutorials.

krishna rao vijayanagar
Krishna Rao Vijayanagar

I’m Dr. Krishna Rao Vijayanagar, founder of OTTVerse. I have a Ph.D. in Video Compression from the Illinois Institute of Technology, and I have worked on Video Compression (AVC, HEVC, MultiView Plus Depth), ABR streaming, and Video Analytics (QoE, Content & Audience, and Ad) for several years.

I hope to use my experience and love for video streaming to bring you information and insights into the OTT universe.


  1. Could it be “transpose=dir=2:transpose=dir=2” should be “”transpose=dir=2,transpose=dir=2” ?

  2. Especially since this was the very first thing that I needed to do with FFmpeg, I found this tutorial very helpful. Thank you Mr. Krishna Rao Vijayanagar for taking the time to help others by sharing your knowledge and posting the tutorials here.

Leave a Reply

Your email address will not be published.