When using my Canon IXUS 40 digital camera to record short videos I sometimes accidently rotate the camera 90 degrees. Of course this isn’t a problem when taking photos since it’s very simple to rotate an image using Photoshop, GIMP, ImageMagick, etc.
The solution might seem less obvious when dealing with video files. Fortunately, there’s this great tool called
mencoder (which is part of MPlayer) which let’s us fix things like this:
mencoder -ovc lavc -lavcopts vcodec=mjpeg -vop rotate=1 -oac copy input.avi -o tmp1.avi
This works well for my kind of camera which saves video as MJPEG in 320×240 resolution. The resulting file
tmp1.avi will in my case be a 240×320 MJPEG clip.
Now 240×320 is quite an odd aspect ration (3:4).
mencoder fix this too:
mencoder -ovc lavc -lavcopts vcodec=mjpeg -vop expand=427:320 -oac copy tmp1.avi -o tmp2.avi
mencoder -ovc lavc -lavcopts vcodec=mjpeg -vop scale=320:240 -oac copy tmp2.avi -o output.avi
The first command will expand the video to 427×320 which is roughly 4:3. The video will be placed in the center and black borders will be added to the left and right sides.
The final command scales the video down to 320×240. Please note that this step lowers the quality of the video. But if you want to playback the video on something like a standalone DVD player you might have to use a standard resolution like this one.
Congratulations! You now have a nice 320×240 video clip.