Fix upside-down iPhone videos with mencoder
Accidentally shoot a video upside-down with your iPhone? Don't worry, it's easy to create a flipped copy that retains just about all the quality. Here's how to do it using free tools on Mac OS X, though this should work on any *nix platform.
Use MacPorts to install mencoder with the H.264codec.
$> sudo port -d install mplayer-devel +mencoder_extras
Use mencoder to make a flipped copy of your video
$> mencoder -oac pcm -ovc x264 -vf flip,mirror -of lavf -x264encopts subq=6:partitions=all:me=umh:frameref=5:bframes=3:b_pyramid=1:weight_b:threads=auto input.mov -o output.mov
Of course, replace input.mov with the path to your input movie.
Ideally we would just flip the video without re-encoding it, but turns out this is impossible. I'm not a video encoding expert, but this will produce a copy of your video that has no noticeable quality degradation. I like H.264's quality/compression ratio, so I grabbed a few of their recommended high quality settings. One minor issue is that the flipped video has no video stream, only audio, in Quicktime Player 10.0. Oddly, they'll play normally in a browser with the Quicktime plugin. Plus the videos will upload to Flickr or YouTube just fine.
See the difference for yourself
Original, raw video (10 MB)
Flipped, re-encoded video (7.3 MB)