Nearest x265 preset

2023-04-192023-07-20

Given encoding settings from MediaInfo, this page will figure out the nearest x265 presetx265 has ten predefined presets of encoder parameters: ultrafast, superfast, veryfast, faster, fast, medium (default), slow, slower, veryslow, and placebo. to replicate those settings. One can input the entire MediaInfo output or just the "Encoding settings" line.

Nearest preset is ultrafast, with 0 additional parameters.

Caveats

There are a few caveats to this that would not fit in sidenotes.

Firstly, not all parameters are recognized yet. x265 has a lot of optionsRough estimate: document.querySelectorAll('.option').length === 225, and while implementing the presets themselves was simple enoughThe parameters affected by each preset are available in a convenient table that is easy enough to parse with some JavaScript., it is the default parameters that are the most incomplete here. I have made an effort to add the ones I saw the most often across the encodes I tested, cross-referencing the documentation along the way, but still I ended up with 137 or so options out of the 225 or so available. This is why one can take an encode that they know the original settings for (maybe they did the encode themselves), input it into this page, and get more flags back than they expected. The intended value here is more in the preset estimation rather than perfectly replicating the original x265 command.

Secondly, some parameters are intentionally omitted in the above output for brevity's sake. These fall within four categories:

  1. The parameter's default value is undefined ("not signaled" in the words of the x265 docs). Examples include --chromaloc, --display-window, and --videoformat.

  2. The parameter is not documented as a command line option. Examples include analysis-reuse-level, decoder-max-rate, and right.

  3. The parameter's default is not documented, or the default depends on the value of another parameter. Examples include --dhdr10-opt and --hevc-aq.

  4. The parameter has no effect on the encoded result. Example: --csv.

Incorrect documentation

Some of the x265 documentation is incorrect or outdated when it comes to the defaults of some parameters, and I have accounted for that here. Here are some of the discrepancies between the documentation and the source code:

SettingDocumentationSource
b-intradisabledenabled
early-skipdisabledenabled
max-merge23

There are also some undocumented changes surrounding presets:

  1. ultrafast, superfast: aq-strength set to 0.
  2. slow, slower, veryslow, placebo: psy-rdoq set to 1, lookahead-slices disabled.
  3. placebo: rskip disabled, tskip enabled.

Future ideas

x264 version? The parsing and diffing logic could be reused, but the thought of having to input another hundred settings does not sound fun.

After presets are applied there are optional tunings; we should be able to find the nearest preset and tuning.