A few months ago I purchased a “Google Phone”: a HTC Magic running the Linux-based Android operating system. I am incredibly pleased with this device.
Today I wanted to convert some video that I recorded on a Nikon Coolpix camera into a format that would play nicely on my Android phone. The resolution needed to be scaled down for the small screen, and I knew that h264 was the best video codec. After some searching online, and a bit of experimenting, I found that this worked wonderfully:
ffmpeg -i input.avi -aspect 3:2 -s 400x300 -vcodec libx264 -b 480k -r 30 -acodec libfaac -ac 1 -ab 32k -padtop 10 -padbottom 10 -padleft 40 -padright 40 -sameq -pass 1 output.mp4
This is a two-pass process, and so this command should be repeated a second time with the last option changed to “-pass 2”.
The “pad” options are to make the geometry work. The screen on the HTC Magic has a resolution of 480×320 pixels, which is a 3:2 aspect ratio. The video I was converting had an aspect ratio of 4:3, and so it conveniently scaled to 400×300. The paddings fill the video out to the full 480×320, ensuring that the aspect ratio is right during playback.