x264 Recommendations for FFmpeg

x264 Quality Settings

If in doubt, use CRF 21.

If it’s live action content and you really care about it, use the film tuning (-tune film).

CRF Use case
16 to 19 For super-high quality, effectively lossless for most intents and purposes. Going lower than 16 is generally a waste.
19 to 21 Good for a “distribution” or “access” copy.
21 to 24 When quality should be good but file size matters.
24 to 28 When you really don’t care.

x264 Parameters

Parameters to pretty much always use:

me=umh — better motion estimation

subme=9 — subpixel refinement on all frames

fast_pskip=0 or no-fast-pskip=1 — slight quality increase; worth it IMO

b-adapt=2 — a better B-frame decision mode

aq-mode=2 — better adaptive quantization

ref=4 — four reference frames (it may be better to just leave this at default of 3 reference frames, see reference #4 on this page)

Parameters that depend on frame rate:

Frames per second keyint bframes
24 240 6
25 250 6
30 300 6
50 500 7
60 600 7

FFmpeg params

Quick command line snippets for use in ffmpeg:

24 fps:

    -x264-params keyint=240:bframes=6:ref=4:me=umh:subme=9:no-fast-pskip=1:b-adapt=2:aq-mode=2
  

25 fps:

    -x264-params keyint=250:bframes=6:ref=4:me=umh:subme=9:no-fast-pskip=1:b-adapt=2:aq-mode=2
  

30 fps:

    -x264-params keyint=300:bframes=6:ref=4:me=umh:subme=9:no-fast-pskip=1:b-adapt=2:aq-mode=2
  

50 fps:

    -x264-params keyint=500:bframes=7:ref=4:me=umh:subme=9:no-fast-pskip=1:b-adapt=2:aq-mode=2
  

60 fps:

    -x264-params keyint=600:bframes=7:ref=4:me=umh:subme=9:no-fast-pskip=1:b-adapt=2:aq-mode=2
  

References

  1. https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
  2. http://www.chaneru.com/Roku/HLS/X264_Settings.htm
  3. https://trac.ffmpeg.org/wiki/Encode/H.264
  4. https://forum.videohelp.com/threads/368496-Number-of-reference-frames-x264