[Quick Tip] Single Command to Rotate a Video in Ubuntu Linux

March 9, 2021 — 1 Comment

Got a video playing upside down? Here’s an easy way to rotate it via a single command in Ubuntu.

There are a few video players, e.g., SMPlayer, support for rotating by 90 degrees clockwise or counter-clockwise during video playback.

If you want to make it permanent by exporting video rotated, besides using a heavy video editing tool, e.g., Pitivi and Openshot, the single command in this tutorial may help.

upside down video

An upside down video

1. Install FFmpeg:

Firstly install FFmpeg if you don’t have it. FFmpeg is a large suite of libraries and programs for handling multi-media files and streams.

It is very popular and most likely already installed on your system, if you have any audio, video, and other multimedia relevant applications installed.

To make sure, open terminal (Ctrl+Alt+T) and run command:

2. Command to rotate video:

Now you can run the single command to rotate a video:

ffmpeg -i input-video.mp4 -vf "transpose=1" output-video.mp4

Before this command, you may first navigate to the video folder either via cd command (e.g., cd ~/Videos), or in file browser go to the folder and right-click blank area and select “Open in Terminal”.

In the command, the number in “transpose=1” can also be:

  • 0 – means rotate by 90 degrees counterclockwise and flip
  • 1 – means rotate by 90 degrees clockwise
  • 2 – means rotate by 90 degrees counterclockwise
  • 3 – means rotate by 90 degrees clockwise and flip

In my case, the command is:

ffmpeg -i ~/Videos/aisha.mp4 -vf "transpose=1" ~/Videos/aisha-rotated.mp4

And depends on the video size and your CPU, the process may take a few minutes.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected]

One response to [Quick Tip] Single Command to Rotate a Video in Ubuntu Linux

  1. Awesome.
    I could have held the phone landscape to the binocular. I hardly ever take video. Of course HD is horizontal-is-wide. I could have guessed.
    My 11 year old desktop took 3.5 minutes to process a 43 second clip. I bet it would be faster if i got ffmpeg to use the video card. The video card can scale a video while displaying it and still be mostly idle. Oh look. A 23 page PDF on how to do that.
    https://developer.download.nvidia.com/compute/redist/ffmpeg/1511-patch/FFMPEG-with-NVIDIA-Acceleration-on-Ubuntu_UG_v01.pdf

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.