Resource icon

Low latency, high performance x264 options for for most streaming services (Youtube, Facebook,...)

Reference links:
  1. Youtube recommended streaming encoder settings
  2. x264 fullhelp
  3. x264 settings basic wiki
  4. Another x264 settings basic wiki
  5. Presets comparison table
  6. Explanation of x264 tunes
Basic output settings:
  • Rate control: CBR
  • Keyframe Interval: 2
  • Preset: superfast (ultrafast doesn't use cabac)
  • Profile: main (baseline doesn't use cabac)
x264 custom options and tunes: (step-by-step adding, space between options)
  1. bframes=2
  2. Replace unnecessary superfast settings with some ultrafast settings, also add some fastdecode and zerolatency settings:
    b-adapt=0 partitions=none scenecut=0 no-weightb weightp=0 sliced-threads
  3. Tunes: here are some sets of extra options for each tune you pick. psnr, ssim and fastdecode aren't recommended for Youtube streaming. Choose one of them to use.
Set #1: Low Latency, High Performance
  • film/animation/grain/stillimage: aq-mode=0 subme=0 no-deblock
  • zerolatency: aq-mode=0 subme=0 no-deblock sync-lookahead=3
Set #2: Low Latency
  • film/animation/grain/stillimage/zerolatency: force-cfr aq-mode=0 subme=0 no-deblock
Set #3: Balanced
  • film: aq-mode=0 subme=0
  • animation/grain/stillimage: subme=0
  • zerolatency: aq-mode=0 subme=0 no-deblock sync-lookahead=3
Set #4: Quality (maintains the settings of each tune)​
  • film: aq-mode=0 subme=0 trellis=1
  • animation: subme=6
  • grain: subme=0 trellis=1
  • stillimage: subme=6 trellis=1
  • zerolatency: force-cfr aq-mode=0 subme=0 no-deblock
Check your Youtube settings:
For low latency and normal latency, turn on DVR may add a few seconds to your latency.​
  • Youtube recommends CABAC. Context-adaptive binary arithmetic coding (CABAC) is a form of entropy encoding, not available when using ultrafast.
  • bframes: sets the maximum number of concurrent B-frames that x264 can use. B-frames are similar to P-frames, except they can use motion prediction from future frames as well. This can lead to significantly better efficiency in terms of compression ratio. Youtube recommended value is 2.
  • b-adapt: set the adaptive B-frame placement decision algorithm. This setting controls how x264 decides between placing a P- or B-frame. 0=disabled: pick B-frames always.
  • partitions: H.264 video is split up into 16x16 macroblocks during compression. These blocks can be further split up into smaller partitions, which is what this option controls. ultrafast value=none.
  • scenecut: sets the threshold for I/IDR frame placement. ultrafast value=0. Setting scenecut to 0 is equivalent to setting no-scenecut.
  • no-weightb: H.264 allows you to 'weight' references in B-frames, which allows you to change how much each reference affects the predicted picture. This disables that feature.
  • weightp: enables use of explicit weighted prediction to improve compression in P-frames. Higher modes are slower.
  • sliced-threads: enables slice-based threading. This threading method produces lower quality results than the default method both compression and efficiency-wise, but adds no encoding latency.
  • aq-mode: Adaptive Quantization Mode. Without AQ, x264 tends to underallocate bits to less-detailed sections.
  • subme: set the subpixel estimation complexity. Using a value less than 2 will enable a faster, and lower quality lookahead mode.
  • no-deblock: deblock controls the loop filter (aka inloop deblocker), which is part of the H.264 standard. It is very efficient in terms of encoding time vs. quality gained. ultrafast value uses no-deblock, which completely disables the loop filter.
  • sync-lookahead: sets the number of frames to be used as a buffer for threaded lookahead. sync-lookahead=0 disables threaded lookahead, which allows lower latency at the cost of reduced performance, default=bframes+1.
  • force-cfr: if using ffms2 or lavf demuxers, timecodes are copied from the input file, provided the output file is not raw. This option disables this, and forces x264 to generate its own.
  • film and zerolatency don't need aq. animation, grain and stillimage use psy-rd 1st/2nd value which requires subme>=6/trellis>=1.
  • psy-rd: Psychovisually optimized rate-distortion optimization. the human eye doesn't just want the image to look similar to the original, it wants the image to have similar complexity. Therefore, we would rather see a somewhat distorted but still detailed block than a non-distorted but completely blurred block. The result is a bias towards a detailed and/or grainy output image, a bit like xvid except that its actual detail rather than ugly blocking.
  • trellis: performs trellis quantization to increase efficiency. From 0 to 2, higher value slower speed.
  • grain use deadzone. The deadzone value sets the level of fine detail that x264 will arbitrarily drop without attempting to preserve. Very fine detail is both hard to see and expensive to encode, dropping this detail without attempting to preserve it stops wasting bits on such a low-return section of the video. Although it was said to be incompatible with trellis, deadzone is still active when using with trellis=1.
  • 1537369692525.png
    40.8 KB · Views: 11,214
First release
Last update
0.00 star(s) 0 ratings