May 5, 2022

How to rotate a video

We are often asked to create videos that are meant to be viewed in "tall" mode -- i.e., on a phone help upright. Typically, the original footage was either shot on a smartphone in portrait mode, or else shot using a professional camera positioned sideways, at a 90 degree angle. Too often, the resulting capture  ends up stored in the standard 16:9 ratio and format. In many such cases, the first thing we need to do is to rotate the video.

In other (and fewer) words, we receive this:

but what we really need is this:

There are many ways to go about rotating a video source. I'll reserve the preferred method for last.


The first way is to use the built-in functionality of the video editor. Most editors, from popular online platforms such as Canva to desktop non-linear video editors like Kdenlive and Adobe Premiere, include an option to either rotate the source video automatically, or else create a copy of the source video in the correct format. However, relying on the editor to modify the source material is not ideal, as it tends to muddle the workflow and confuse the authors of future iterations (including yourself,)


The second way is to use a free online tool -- such as Kapwing (here) or Clideo (here). While this solution is convenient (as long as you have a fast Internet connection), the process is somewhat cumbersome and not very scalable. Additionally, the processing of high-resolution (4K and 8K) footage, or any clip of significant size or length for that matter, is likely to be limited by what those browser-based tools can reliably handle.


There is a third way, which gets the job done perfectly in just a few seconds. It uses a short command line and  ensures that you will retain the source material in your work space.

  1. Navigate to the folder that contains the video file you want to rotate.
  2. Open a terminal in that folder.
  3. Edit the line below to match the necessary file names.
    1. Replace with the name and extension of your source file.
    2. Replace Target.mp4 with the name and extension of the final, rotated video file.
    3. Note that ffmpeg will automatically convert the file to the format indicated by the extension of the target filename. In the example line, the quicktime (.mov) file named Source will be converted to an mp4 video named Target.
    4. Replace the number within quotation marks with the amount (in degrees) you want the video to be rotated. A negative amount will rotate the frame clockwise, and vice versa.
  4. Paste the command line in the terminal.
  5. Repeat for each video file you want to rotate.

Use the line below (simply click on it to copy it to your clipboard):

ffmpeg -i -metadata:s:v rotate="-90" -codec copy target.mp4

Make sure you have the latest version of ffmpeg installed on your computer.

Warning: Undefined array key "preview" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comments-list.class.php on line 90

Warning: Undefined array key "preview" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comments-list.class.php on line 102

Warning: Undefined array key "preview" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comments-list.class.php on line 113

Warning: Undefined array key "action" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comments-list.class.php on line 113

Warning: Undefined array key "preview" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comment-form.class.php on line 75

Warning: Undefined array key "preview" in /home/codecide/public_html/wp-content/plugins/oxygen/component-framework/components/classes/comment-form.class.php on line 79
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram