wiki:Encoding

Version 4 (modified by dirk, 11 years ago) (diff)

--

How to encode video in H264 format

back

We have successfully been using ffmpeg/libx264 with two pass encoding using the following commands:

  options="-vcodec libx264 -b 512k -bf 3 -subq 6 -cmp 256 -refs 5 -qmin 10 \
           -qmax 51 -qdiff 4 -coder 1 -loop 1 -me hex -me_range 16 -trellis 1 \
           -flags +mv4 -flags2 +bpyramid+wpred+mixed_refs+brdo+8x8dct \
           -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -g 250 \
           -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71"

  ffmpeg -y -i "$X" -an -pass 1 -threads 2 $options "$tmpfile"

  ffmpeg -y -i "$X" -acodec libfaac -ar 44100 -ab 96k -pass 2 \
         -threads 2 $options "$tmpfile"

  qt-faststart "$tmpfile" "$outfile"

The last line 'qt-faststart' is (currently) optional. It doesn't hurt though and it even may save a little time on the server which is hosting the movie files.