{"id":33454,"date":"2021-03-09T16:18:27","date_gmt":"2021-03-09T16:18:27","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=33454"},"modified":"2025-08-25T06:28:18","modified_gmt":"2025-08-25T06:28:18","slug":"single-command-rotate-video-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2021\/03\/single-command-rotate-video-ubuntu-linux\/","title":{"rendered":"[Quick Tip] Single Command to Rotate a Video in Ubuntu Linux"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-7023\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/08\/videocutter-icon245.png\" alt=\"\" width=\"245\" height=\"250\" \/><\/p>\n<p>Got a video playing upside down? Here&#8217;s an easy way to rotate it via a single command in Ubuntu.<\/p>\n<p>There are a few video players, e.g., SMPlayer, support for rotating by 90 degrees clockwise or counter-clockwise during video playback.<\/p>\n<p>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.<\/p>\n<div id=\"attachment_33455\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-33455\" class=\"size-full wp-image-33455\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/03\/before-rotate.png\" alt=\"upside down video\" width=\"600\" height=\"372\" \/><p id=\"caption-attachment-33455\" class=\"wp-caption-text\">An upside down video<\/p><\/div>\n<h4>1. Install FFmpeg:<\/h4>\n<p>Firstly install FFmpeg if you don&#8217;t have it. FFmpeg is a large suite of libraries and programs for handling multi-media files and streams.<\/p>\n<p>It is very popular and most likely already installed on your system, if you have any audio, video, and other multimedia relevant applications installed.<\/p>\n<p>To make sure, open terminal (Ctrl+Alt+T) and run command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33456\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/03\/apt-ffmpeg.png\" alt=\"\" width=\"600\" height=\"202\" \/><\/p>\n<h4>2. Command to rotate video:<\/h4>\n<p>Now you can run the single command to rotate a video:<\/p>\n<pre style=\"border: none;\">ffmpeg -i input-video.mp4 -vf \"transpose=1\" -acodec copy output-video.mp4<\/pre>\n<p>Before this command, you may first navigate to the video folder either via cd command (e.g., <code style=\"border: none;\">cd ~\/Videos<\/code>), or in file browser go to the folder and right-click blank area and select &#8220;Open in Terminal&#8221;.<\/p>\n<p>In the command, the number in &#8220;<code style=\"border: none;\">transpose=1<\/code>&#8221; can also be:<\/p>\n<ul>\n<li><b>0<\/b> &#8211; means rotate by 90 degrees counterclockwise and flip<\/li>\n<li><b>1<\/b> &#8211; means rotate by 90 degrees clockwise<\/li>\n<li><b>2<\/b> &#8211; means rotate by 90 degrees counterclockwise<\/li>\n<li><b>3<\/b> &#8211; means rotate by 90 degrees clockwise and flip<\/li>\n<\/ul>\n<p>(Thanks to <i>Roman Sheydvasser<\/i>) <del datetime=\"2023-02-09T05:05:26+00:00\">Add <code>-c copy<\/code> (or <code>-codec copy<\/code>) will copy all the frames instead of <i>doing decode -&gt; filter -&gt; encode<\/i> process. It will speed up the command quite a lot!<\/del><\/p>\n<p>In my case, the command is:<\/p>\n<pre style=\"border: none;\">ffmpeg -i ~\/Videos\/aisha.mp4 -vf \"transpose=1\" -acodec copy ~\/Videos\/aisha-rotated.mp4<\/pre>\n<p>This command however will re-encode the video. Depends on the video size and your CPU, the process may take a few minutes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33457\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/03\/video-rotate.png\" alt=\"\" width=\"600\" height=\"387\" \/><\/p>\n<h4>Optional<\/h4>\n<p>The last command can take quite a few minutes since it needs to re-encode the video. As a workaround, user can use this command instead to do the rotation in the metadata.<\/p>\n<pre>ffmpeg -i input-video.mp4 -map_metadata 0 -metadata:s:v rotate=\"90\" -codec copy output-video.mp4<\/pre>\n<p>The command is fast and will work for video players (such as VLC and MPV) that support can handle rotation metadata.<\/p>","protected":false},"excerpt":{"rendered":"<p>Got a video playing upside down? Here&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[594],"class_list":["post-33454","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-ffmpeg"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=33454"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33454\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=33454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=33454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=33454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}