one pass:

ffmpeg -i input -acodec libfaac -ab 128k -vcodec libx264 -vpre slow -crf 22(smaller value=higher quality/bitrate) -threads 0 output.mp4


Instead of using -crf you use a determined bitrate which can be useful while converting some kind of videos and permit to have a stable output size

ffmpeg -y -i “input” -an -vcodec libx264 -vpre medium_firstpass -b 800k -threads 8 -f mp4 /dev/null

ffmpeg -y -i “input” -acodec libfaac -ab 128k -vcodec libx264 -vpre medium -b 800k -threads 8 output.mp4

small variation: if I am encoding a video that contains a dolby 5.1 audio channel , then I put:

-acodec libfaac -ar 44100 -ab 128k -ac 2

via Flowplayer Forums – Perfecting h264 conversion with ffmpeg.