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:  Extract Frames using FFmpeg: A Comprehensive Guide

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

Krishna Rao Vijayanagar, Ph.D., is the Editor-in-Chief of OTTVerse, a news portal covering tech and business news in the OTT industry.

With extensive experience in video encoding, streaming, analytics, monetization, end-to-end streaming, and more, Krishna has held multiple leadership roles in R&D, Engineering, and Product at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers and speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.

4 thoughts on “How to Rotate A Video using FFmpeg Easily – OTTVerse”

  1. Daniel Lewiston

    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.

  2. Dear Krishna (nice name)
    I rotate image with rotate filter
    ffmpeg -i input.bmp -vf rotate=PI/6 out.bmp
    it sreate 4 black corners, is there way to set white?

Leave a Comment

Your email address will not be published. Required fields are marked *

Enjoying this article? Subscribe to OTTVerse and receive exclusive news and information from the OTT Industry.