View Full Version : Documentation for x264 switches?
omf
22nd March 2008, 18:27
I've been looking around and found several bits of information here and there, but is there a generally-accepted good source of documentation for the x264 options? (Other than the source code itself, of course...)
bob0r
22nd March 2008, 18:29
Maybe this helps:
http://www.digital-digest.com/articles/x264_options_page1.html
omf
22nd March 2008, 18:34
Maybe this helps:
http://www.digital-digest.com/articles/x264_options_page1.html
Great guide, but I was concerned that it's nearly a couple of years old now.
Do the developers usually maintain documentation when switches are added or default values changed?
MuLTiTaSK
22nd March 2008, 18:38
http://avidemux.org/admWiki/index.php?title=H264
http://trac.handbrake.fr/wiki/x264Options
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html#menc-feat-x264-encoding-options
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html#CODEC%20SPECIFIC%20ENCODING%20OPTIONS%20(MENCODER%20ONLY)
http://gabext.com/dts/DTSGuide.html
http://mewiki.project357.com/wiki/X264_Settings
x264 core:58 r786 aa5391a
Syntax: x264 [options] -o outfile infile [widthxheight]
Infile can be raw YUV 4:2:0 (in which case resolution is required),
or YUV4MPEG 4:2:0 (*.y4m),
or AVI or Avisynth if compiled with AVIS support (yes).
Outfile type is selected by filename:
.264 -> Raw bytestream
.mkv -> Matroska
.mp4 -> MP4 if compiled with GPAC support (yes)
Options:
-h, --help List the more commonly used options
--longhelp List all options
Frame-type options:
-I, --keyint <integer> Maximum GOP size [250]
-i, --min-keyint <integer> Minimum GOP size [25]
--scenecut <integer> How aggressively to insert extra I-frames [40]
--pre-scenecut Faster, less precise scenecut detection.
Required and implied by multi-threading.
-b, --bframes <integer> Number of B-frames between I and P [0]
--no-b-adapt Disable adaptive B-frame decision
--b-bias <integer> Influences how often B-frames are used [0]
--b-pyramid Keep some B-frames as references
--no-cabac Disable CABAC
-r, --ref <integer> Number of reference frames [1]
--no-deblock Disable loop filter
-f, --deblock <alpha:beta> Loop filter AlphaC0 and Beta parameters [0:0]
--interlaced Enable pure-interlaced mode
Ratecontrol:
-q, --qp <integer> Set QP (0=lossless) [26]
-B, --bitrate <integer> Set bitrate (kbit/s)
--crf <float> Quality-based VBR (nominal QP)
--vbv-maxrate <integer> Max local bitrate (kbit/s) [0]
--vbv-bufsize <integer> Enable CBR and set size of the VBV buffer (kbit) [0]
--vbv-init <float> Initial VBV buffer occupancy [0.9]
--qpmin <integer> Set min QP [10]
--qpmax <integer> Set max QP [51]
--qpstep <integer> Set max QP step [4]
--ratetol <float> Allowed variance of average bitrate [1.0]
--ipratio <float> QP factor between I and P [1.40]
--pbratio <float> QP factor between P and B [1.30]
--chroma-qp-offset <integer> QP difference between chroma and luma [0]
-p, --pass <1|2|3> Enable multipass ratecontrol
- 1: First pass, creates stats file
- 2: Last pass, does not overwrite stats file
- 3: Nth pass, overwrites stats file
--stats <string> Filename for 2 pass stats ["x264_2pass.log"]
--rceq <string> Ratecontrol equation ["blurCplx^(1-qComp)"]
--qcomp <float> QP curve compression: 0.0 => CBR, 1.0 => CQP [0.60]
--cplxblur <float> Reduce fluctuations in QP (before curve compression) [20.0]
--qblur <float> Reduce fluctuations in QP (after curve compression) [0.5]
--zones <zone0>/<zone1>/... Tweak the bitrate of some regions of the video
Each zone is of the form
<start frame>,<end frame>,<option>
where <option> is either
q=<integer> (force QP)
or b=<float> (bitrate multiplier)
--qpfile <string> Force frametypes and QPs
Analysis:
-A, --partitions <string> Partitions to consider ["p8x8,b8x8,i8x8,i4x4"]
- p8x8, p4x4, b8x8, i8x8, i4x4
- none, all
(p4x4 requires p8x8. i8x8 requires --8x8dct.)
--direct <string> Direct MV prediction mode ["spatial"]
- none, spatial, temporal, auto
--direct-8x8 <-1|0|1> Direct prediction size [-1]
- 0: 4x4
- 1: 8x8
- -1: smallest possible according to level
-w, --weightb Weighted prediction for B-frames
--me <string> Integer pixel motion estimation method ["hex"]
- dia: diamond search, radius 1 (fast)
- hex: hexagonal search, radius 2
- umh: uneven multi-hexagon search
- esa: exhaustive search
- tesa: hadamard exhaustive search (slow)
--merange <integer> Maximum motion vector search range [16]
--mvrange <integer> Maximum motion vector length [-1 (auto)]
--mvrange-thread <int> Minimum buffer between threads [-1 (auto)]
-m, --subme <integer> Subpixel motion estimation and partition
decision quality: 1=fast, 7=best. [5]
--b-rdo RD based mode decision for B-frames. Requires subme 6.
--mixed-refs Decide references on a per partition basis
--no-chroma-me Ignore chroma in motion estimation
--bime Jointly optimize both MVs in B-frames
-8, --8x8dct Adaptive spatial transform size
-t, --trellis <integer> Trellis RD quantization. Requires CABAC. [0]
- 0: disabled
- 1: enabled only on the final encode of a MB
- 2: enabled on all mode decisions
--no-fast-pskip Disables early SKIP detection on P-frames
--no-dct-decimate Disables coefficient thresholding on P-frames
--nr <integer> Noise reduction [0]
--deadzone-inter <int> Set the size of the inter luma quantization deadzone [21]
--deadzone-intra <int> Set the size of the intra luma quantization deadzone [11]
Deadzones should be in the range 0 - 32.
--cqm <string> Preset quant matrices ["flat"]
- jvt, flat
--cqmfile <string> Read custom quant matrices from a JM-compatible file
Overrides any other --cqm* options.
--cqm4 <list> Set all 4x4 quant matrices
Takes a comma-separated list of 16 integers.
--cqm8 <list> Set all 8x8 quant matrices
Takes a comma-separated list of 64 integers.
--cqm4i, --cqm4p, --cqm8i, --cqm8p
Set both luma and chroma quant matrices
--cqm4iy, --cqm4ic, --cqm4py, --cqm4pc
Set individual quant matrices
Video Usability Info (Annex E):
The VUI settings are not used by the encoder but are merely suggestions to
the playback equipment. See doc/vui.txt for details. Use at your own risk.
--overscan <string> Specify crop overscan setting ["undef"]
- undef, show, crop
--videoformat <string> Specify video format ["undef"]
- component, pal, ntsc, secam, mac, undef
--fullrange <string> Specify full range samples setting ["off"]
- off, on
--colorprim <string> Specify color primaries ["undef"]
- undef, bt709, bt470m, bt470bg
smpte170m, smpte240m, film
--transfer <string> Specify transfer characteristics ["undef"]
- undef, bt709, bt470m, bt470bg, linear,
log100, log316, smpte170m, smpte240m
--colormatrix <string> Specify color matrix setting ["undef"]
- undef, bt709, fcc, bt470bg
smpte170m, smpte240m, GBR, YCgCo
--chromaloc <integer> Specify chroma sample location (0 to 5) [0]
Input/Output:
-o, --output Specify output file
--sar width:height Specify Sample Aspect Ratio
--fps <float|rational> Specify framerate
--seek <integer> First frame to encode
--frames <integer> Maximum number of frames to encode
--level <string> Specify level (as defined by Annex A)
-v, --verbose Print stats for each frame
--progress Show a progress indicator while encoding
--quiet Quiet Mode
--no-psnr Disable PSNR computation
--no-ssim Disable SSIM computation
--threads <integer> Parallel encoding
--thread-input Run Avisynth in its own thread
--non-deterministic Slightly improve quality of SMP, at the cost of repeatability
--no-asm Disable all CPU optimizations
--visualize Show MB types overlayed on the encoded video
--sps-id <integer> Set SPS and PPS id numbers [0]
--aud Use access unit delimiters
hope they help
Dark Shikari
22nd March 2008, 19:08
My guide (http://ffmpeg.x264.googlepages.com/).
Schrade
22nd March 2008, 20:33
Dark Shikari, awesome guide! That was just what I was looking for.
By any chance do you know of an ffmpeg that has been patched with your VAQ patch yet?
Dark Shikari
22nd March 2008, 20:39
Dark Shikari, awesome guide! That was just what I was looking for.
By any chance do you know of an ffmpeg that has been patched with your VAQ patch yet?Doubtful, if you want to encode with libx264 in ffmpeg, you'll have to build your own libx264.
omf
24th March 2008, 23:52
Thanks for all the great links/info!
SuNova
19th October 2016, 18:19
My guide (http://ffmpeg.x264.googlepages.com/).
Sorry for bumping (too) old threads.
Dark Shikari your guide is no longer accessible. Can you correct the URL and give it to me?
Anyway let me say something as I'm bumping.
I'm a newbie in encoding realm. I only stick to x264 because I need to, and I believe in "Don't trust who you don't know". So I believe I can't properly use encoder setting if I don't know exactly what they do.
I mean, yes there are many people out there who say trellis is good it sharpens hard parts or psy-trellis softens or such things, but I need to really know what trellis does in order to know situations I need it most.
So, I want some kinda guide which not only explains x264 switches, but also explain what they exactly do. I don't need such guides which say "Hey buddy you know CABAC rocks you gotta use it". I just want to know what CABAC really does (all of above examples are only examples I'm not asking for info here). Also, as I'm not an encoder developer like Dark Shikari (and my brain is not filled with what encoder really does, just like his own profile pic :D ), so mentioned guide should be understandable for a newbie.
I know I'm really searching for paradise :D but any good resources will be welcome.
Oh and please if it's possible give me some resources about effect of different switches on decoding. I think I'm pulling too much heat of those poor mobile CPUs :devil:
Thanks guys
sneaker_ger
19th October 2016, 19:22
In short:
1. choose preset for speed/compression trade-off
2. choose tuning for e.g. hollywood movie ("film"), grainy or high-bitrate movie ("grain") or cartoon/anime ("animation").
3. limit according to playback device, e.g. --level 4.0 --vbv-maxrate 20000 --vbv-bufsize 20000
4. find crf value that gives you a file size and quality compromise you are happy with (most people choose between 18 and 23, lower means better quality/bigger file)
5. leave all other settings at default unless you know exactly what you are doing
http://www.chaneru.com/Roku/HLS/X264_Settings.htm
Oh and please if it's possible give me some resources about effect of different switches on decoding. I think I'm pulling too much heat of those poor mobile CPUs :devil:
Pretty much any mobile hardware today has H.264 hardware decoding. The settings usually don't affect heat/battery much as long as they are compatible with the hardware decoder.
SuNova
20th October 2016, 18:55
In short:
1. choose preset for speed/compression trade-off
2. choose tuning for e.g. hollywood movie ("film"), grainy or high-bitrate movie ("grain") or cartoon/anime ("animation").
3. limit according to playback device, e.g. --level 4.0 --vbv-maxrate 20000 --vbv-bufsize 20000
4. find crf value that gives you a file size and quality compromise you are happy with (most people choose between 18 and 23, lower means better quality/bigger file)
5. leave all other settings at default unless you know exactly what you are doing
http://www.chaneru.com/Roku/HLS/X264_Settings.htm
Pretty much any mobile hardware today has H.264 hardware decoding. The settings usually don't affect heat/battery much as long as they are compatible with the hardware decoder.
The problem is I encode for mobile devices. So consider limited mobile data, various target hardware configs and offcourse, it's mobile not PC.
So I should put too much time on encode (that's ok for me) and get a reasonable playable result. That's why I insist on knowing details. for example I know p4x4 slows down decoding and the quality gain is very little so I disable it. Or I know CABAC is slow but because I encode at low bitrates (lower than 2mbps and mostly under 1mbps) leaving it on will help. But my knowledge about other parameters is limited
sneaker_ger
20th October 2016, 19:25
The problem is I encode for mobile devices. So consider limited mobile data, various target hardware configs and offcourse, it's mobile not PC.
So I should put too much time on encode (that's ok for me) and get a reasonable playable result.
But those are already taken care of in my "guide"? Point 3 addresses compatibility with devices and Internet speed, point 4 about limited data (i.e. file size/average bitrate). If you want more control over average bitrate than crf gives then use --bitrate instead of --crf. (Optimally with two passes, i.e. --pass 1 then again --pass 2)
Since there are literally thousands of different devices it is not possible to give advice that just works everywhere. Not possible. If you want more info you need to be way more specific about your exact requirements.
That's why I insist on knowing details. for example I know p4x4 slows down decoding and the quality gain is very little so I disable it. Or I know CABAC is slow but because I encode at low bitrates (lower than 2mbps and mostly under 1mbps) leaving it on will help. But my knowledge about other parameters is limited
The presets are already designed to find optimal compression at a given speed. You are likely to shoot yourself in the foot if you try to mess with the detailed settings. Don't. The developers already did the work for you when they designed the presets. (point 5 in the guide)
SuNova
20th October 2016, 22:14
https://drive.google.com/open?id=0B8g1ASw9j5m2TUNjbXVPVDA2akE
Can you guide me about this?
My friends say it has slower playback comparing with 15fps version (same encoding settings)
cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=tesa / subme=11 / psy=1 / fade_compensate=0.00 / psy_rd=1.00:0.10 / mixed_ref=1 / me_range=36 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=1 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=1 / b_pyramid=0 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=infinite / keyint_min=30 / scenecut=40 / intra_refresh=0 / rc=2pass / mbtree=0 / bitrate=291 / ratetol=1.0 / qcomp=1.00 / qpmin=0 / qpmax=69 / qpstep=22 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=2:1.00
sneaker_ger
20th October 2016, 22:29
Like I said, more fps require more processing power.
bframes shouldn't affect decoding speed much. Mostly resolution, fps, bitrate, bitdepth and --no-cabac --no-deblock --no-weightb --weightp 0 (--tune fastdecode)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.