Is there a way to change the rotation angle of a video file?
I have a couple of videos in the wrong direction so all I wanted is to correct it.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityYou can also use ffmpeg and the commandline (taken from Rotating videos with FFmpeg):
Rotate 90 clockwise:
ffmpeg -i in.mov -vf "transpose=1" out.mov
For the transpose parameter you can pass:
0 = 90CounterCLockwise and Vertical Flip (default) 1 = 90Clockwise 2 = 90CounterClockwise 3 = 90Clockwise and Vertical Flip
And to flip it horizontally (ffmpeg documentation):
Flip the input video horizontally.
For example to horizontally flip the video in input with `ffmpeg':
ffmpeg -i in.avi -vf "hflip" out.avi
Nota bene 1
Older versions of Ubuntu supplied avconv
instead of ffmpeg
. In this case just change ffmpeg
to avconv
:
avconv -i in.mov -vf "transpose=1" out.mov
Nota bene 2
If the output is a .mp4
video you has to add strict -2
before the output file to avoid error message :
ffmpeg -i in.mp4 -vf "transpose=1" -strict -2 out.mp4
-sameq
doesn't mean 'same quality', it is actually a very limited option that is almost never practically useful, and has been removed from recent versions of ffmpeg precisely because its name causes confusion.
ffmpeg
I had to specify the codec / library explicitly: ffmpeg -i in.mp4 -vcodec libx264 -vf "transpose=2" out.mkv
. If it says Unknown encoder libx264
, you need to install the appropriate libavcodec-extra
package.
If you are asking for rotate a video 90º or 180º, you should use avidemux.
sudo apt-get update
sudo apt-get install avidemux
And you're done.
Do you mean rotation on playback or converting it to a rotated version?
As a commandline-user I normally use mplayer:
Playback:
mplayer -vf rotate=1 videofile.mp4
(rotate can have values from 0 to 7, 1 rotates 90deg clockwise)
Convert (requires transcoding):
mencoder -vf rotate=1 videofile.mp4 -oac copy -of lavf -lavfopts format=mp4 -ovc lavc -lavcopts vcodec=mpeg4 -o newfilename.mp4
(you can use other video codecs as well, this is just an example)
And here is a graphical tool to do the latter: kdenlive (a kde application from the universe)
mplayer -vf flip,mirror videofile.mkv
mplayer -vf flip,mirror
everything is fine. But when I try to convert it, using mencoder -vf flip,mirror
, it is still rotated by 90°. Is there a different syntax for mencoder
to flip a video by 180°?
If you just want to view a movie in a different orientation, as of Totem 3.1.4 (in Raring 13.04 and beyond), there is a "rotation plugin" which you can turn on (edit/plugins), and then rotate e.g. via ctrl-r.
I think proper rotation should be automatic when there is rotation metadata, and I commented on a relevant Totem bug here: Bug 701950 – Iphone Movies
There are also ways to do this in mplayer (and to convert to a rotated movie with mencoder), e.g.
mplayer -vf rotate file.mov
or
mencoder file.mov -oac lavc -ovc x264 -vf rotate=1 -o file-rotated.mov
mplayer -vf rotate=1,rotate=1 file.mp4
that is, two 90 degree rotations in a row.
The best option (in my opinion!) is OpenShot, you simply follow these easy steps:
OpenShot crops the video when rotated from landscape to portrait. To compensate, I tried these steps and it worked. Hope it works for you too.
In this way, you would find the video least cropped and it should not be noticeable.
A simple tool that can also rotate is transmageddon. Install it with
sudo apt install transmageddon
then load your file into it and choose the rotation position