First, you need to follow installing these packages on your ubuntu machine. Mine was installed on Hardy, haven’t tested the command yet now that I have upgraded to Lucid.
ffmpeg -i "Output_Video_File.flv" -vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -subq 7 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 "Output_Video_File.mp4"
This also works on .avi and .mpg as the source video.
Update: Howto link for Lucid
