Like many people I receive video media from family members and friends on line. Sometimes for I receive videos that are shot in portrait mode instead of landscape. I used to find this quite annoying until I figured out how to rotate a video under Linux. All that is needed to rotate the video is mencoder. It comes bundled with the king of media players MPlayer.
Command to rotate a video is:
mencoder -ovc lavc -vop rotate=1 -oac copy input.mpg -o output.mpg
The rotate=1 can be replaced with whatever option best suits your needs. Rotating video options are below:
0 Rotate by 90 degrees clockwise and flip (default).
1 Rotate by 90 degrees clockwise.
2 Rotate by 90 degrees counterclockwise.
3 Rotate by 90 degrees counterclockwise and flip.
I have broken down the command and options below for those that are interested.
-ovc Output Video Codec. This is what codec mencoder should use when creating the video. The command above uses the libavcodec. This is known for quality. “mencoder -ovc help” will display all of the video codecs available
-vop still works but has been replaced with -vf. It is used to setup a chain of video filters in our case it is used to rotate each frame. See the above table to find out what rotate mode you need. Up-side-down videos can be rotated by doing rotate=1 twice.
-oac Output Audio Codec. If you would like to specify an audio codec to use this is where it should be done. “mencoder -oac help” will show all of the available audio codecs. Choosing an audio time adds encoding time but it can greatly reduce or increase file size. I use the copy codec to copy the exact sound from the original first. Then if I wish to reduce file size I can reduce the quality or change the codec afterwards.
input.mpg is the input file and will have to be changed for the file that you wish to rotate. The -o option is used to specify the output file. This must not be left out or mencoder will give an error and your file will not be written.
Now that your done reading all about how to rotate a video with Linux you can give it a try. By having a command line application rotating a whole directory of images can be done in minimal time without human interaction. Try rotating a hundred movies without user interaction in Windows Movie Maker!