Feb 08 2011
I'd like to share a quick tip on rotating video files.
I'm always frustrated with taking videos with my phone. Single handedly it's easiest to do it when the phone is upright and not in landscape mode. But the files are always saved in landscape mode, which makes them rotated when you watch.
Although there are plenty of GUI software to do it, using the command line is faster and can also be batched!
This is the basic syntax
./ffmpeg -vf transpose=0 -i input.mp4 output.avi
-vf transpose=0 to rotate 90 deg clockwise. If you get the "Unrecognized option 'vf'" error, you need to configure & build ffmpeg with
--enable-filters (or at least without
--disable-filters), and check with
ffmpeg -filters that you get them to show up.
Also, I always get very lousy video quality when using the plain vanilla settings. It turns out the problem is with the frame rate. If you leave it as-is the (default) mpeg compression makes a lot of I and P frames, and too few B frames. So set it up explicitly.
I ended up with
ffmpeg -vf transpose=0 -i input.mp4 -r 30 output.avi
Update [3/1/11]: Actually just using
-vf transpose=0 will flip the video horizontally as well, which is undesirable in some cases. To counter that I use:
-vf "transpose=0,hflip=0", and it resolves the problem.
Again, pretty simple thing to do:
mencoder input.mp4 -nosound -o characters-resize-turn.avi -vf rotate=0 -ovc lavc -lavcopts vcodec=mpeg4 -ofps 30
Note that I kill the audio with
-nosound, and again set the frame rate
-ofps 30 or else I get the "duplicate frames" problem.