Rescale 1080p to 720p with ffmpeg

I use the ubuntu v8.10 (intrepid ibex) distribution.

At first I could not tell ffmpeg to use the h264 codec no matter what I tried. It seems ubuntu comes with a stripped version.
Then I realised my only other option was to build it from source.
Fortunately there is great howto detailing the exact steps for my linux distribution.

Follow the instructions to the letter and you should have no problem. At this time I use r17987 (from the trunk).

To rescale a movie to 720p in one pass:
ffmpeg -i in.mpg -s 1280x720 -acodec copy -sameq -sws_flags lanczos -f mpegts -vcodec libx264 -threads 0 out.mpg

The flag 'lanczos' is reputed to give the best rescaling results.

For a 2-pass I used presets based on these:

I managed to get it working after a fair bit of tweaking:

1st pass:
ffmpeg -i in.mpg -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 2772k -bt 2772k -s hd720 -sws_flags lanczos out.mpg

2nd pass:
ffmpeg -i in.mpg -pass 2 -vcodec libx264 -vpre hq -b 2772k -bt 2772k -map 0.0:0.0 -map 0.3:0.1 -map 0.2:0.2 -acodec copy -scodec copy -s hd720 -sws_flags lanczos -y -f avi -threads 0 out.mpg

hq preset:
I had to comment the 'bf' option, would report invalid with it.

fastfirstpass preset, changed these 2 lines (IIRC):


Of course

Elementary my dear Watson!