phayz's blog

…it's time for a new phayz of life

HowTo: Rotate a video using ffmpeg

Note:I am using Linux and have not tested this on other operating systems, so your results may vary.

I recently received a video from someone with a request to post it to a video hosting site. It all sounded simple until I found that the video had been recorded using an iPad in landscape mode so when I played the video the image was rotated. Before posting it I was going to have to rotate the video so that playback looked normal but how was I going to do that?

I first considered a video editor but the ones I considered had too many dependencies so I continued my search and eventually found a solution here:, which gave instructions on using ffmpeg’s “transpose” feature to rotate the video.

For my task here’s the command line I used. This is to entered as one line, but may be appear wrapped in your browser:

ffmpeg -i <input_video_filename> -vf "transpose=1" -r 30 -sameq -acodec copy <output_video_filename>

The “transpose” function is one of ffmpeg’s many video filters which, according to the ffmpeg man page is used to “Transpose rows with columns in the input video and optionally flip it.” Below is a list of other transpose parameters and what they do. For full details, refer to the transpose video filter section of ffmpeg’s man page for details of the necessary values.

0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip

Note: In this example I used three additional parameters:

  • “-acodec copy” parameter, which instructs ffmpeg to copy the audio, not process it again (Note: Thanks to a comment on this blog entry from Tim;
  • “-sameq” parameter so that the video’s original quality was not lost during the rotation because without it ffmpeg degraded quality;
  • “-r 30” to maintain a framerate of 30 frames per second.

8 responses to “HowTo: Rotate a video using ffmpeg

  1. Vinod 28 December 2011 at 6:23 pm

    it’s working for me. Thank you for the info

  2. self 23 March 2012 at 6:32 am

    I added -vf “transpose=1″ to the additional command line parameters in WinFF and it gave me an “unrecognized option ‘-vf'”

  3. Tim 1 July 2012 at 6:44 am

    you have to replace the quotes with real ones, since your blog transforms them, also ‘-acodec copy’ is recommended, so the audio is not encoded again.

    • phayz 15 October 2012 at 7:59 am


      Thanks for your reply. I’ll fix the quotes and add the ‘-acodec copy’ option as you suggest.

      Yes, I know this is a *very* late reply.

  4. urik 22 July 2012 at 8:29 pm

    I tried this command line on a w7 64bits and it didnt give me any error messags and didnt rotate the video.
    Do u know why?

    • phayz 15 October 2012 at 8:25 am

      When I have time available I’ll try this on Windows 7 64-bit. Until then I can only suggest searching elsewhere for a solution. ffmpeg is cross-platform, so the same command should give the same result on all supported operating systems. In my case I am using Linux and I have added a note about that at the very top of the blog post.

  5. deborah 7 September 2012 at 10:54 am

    same here, error, not working

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: