X264 Defaults Changing, Plus a Few More

Well, it has been a while now hasn't it? Okay, well lets start off with some "industry" news. It appears that Dark Shikari over on the Doom9 forums has announced that the defaults for X264 (the free implementation of the H.264 encoder standard) are infact changing. The reason most often stated is "to make it faster and easier for users to select encoding options".

The new, tentative, defaults are as follows:

--subme 7 --bframes 3 --weightb --8x8dct --ref 3 --mixed-refs --trellis 1 --crf 23 --threads auto --no-psnr --no-ssim

As stated by Dark Shikari:

Logic behind this change: x264 should be by default High Profile and generate relatively high quality, but not entirely max itself out; it should be a reasonable speed/quality tradeoff. UMH is probably a bit too costly speed-wise to set as the default.

The "UMH" that is he is referring to, for those of you who don't know, is a form of motion search called Uneven Multi-Hexagon. It generally offers very good results, but at a large cost in speed.

In addition to changing the default options, there will be three more command line flags that are being added to simplify the encode process. Read: Make it easier and faster to select "good" settings for a particular video source.

1) Preset§

The first flag is that of the --preset flag. The preset flag will offer 7 new options, each of which offers a quick selection for desired encoding selections.

Here are the 7 options:

ultrafast:

--ref 1 --scenecut 0 --nf --no-cabac --bframes 0 --partitions none --no-8x8dct --me dia --subme 0 --aq-mode 0

veryfast:

--partitions i8x8,i4x4 --subme 1 --me dia --ref 1 --trellis 0

fast:

--mixed-refs 0 --ref 2 --subme 5

medium:

<defaults>

slow:

--me umh --subme 8 --ref 5 --b-adapt 2 --direct auto

slower:

--me umh --subme 9 --ref 8 --b-adapt 2 --direct auto --partitions all --trellis 2

placebo:

--me tesa --subme 9 --merange 24 --ref 16 --b-adapt 2 --direct auto --partitions all --no-fast-pskip --trellis 2 --bframes 16

2) Profile§

Next to be added is the --profile option.  This option will override all settings except for two, select cases: encoding interlaced or lossless material. If you attempt to encode either interlaced content or lossless content while setting a --profile option, the encoder will exit with an error. The reason for this is that interlaced and lossless content require very specific settings and proper encoding would be hindered under normal circumstances.

The profiles being offered are baseline, main and high. You can see this Wikipedia articlefor more information about each profile.

To summarize, each profile offers a range of encoding settings that aim to fulfill specific requirements. This often has uses when encoding for specific devices, such as a standalone Bluray player, or an iPod. Again, read the article if you are still curious.

3) Tune§

The --tune option was introduced so as to be able to quickly "tune" specific x264 settings towards a particular source type. For example, the setting that offer similar quality for both film and animation can be vastly different. The main items adjusted by the --tune option are the AQ, psy-RD/trellis, and deblocking strength. In addition, b-frames and reference may be adjusted but there is still some minor dispute on the specific settings.

Currently the two options available are:
film:

--deblock -1:-1 --psy-rd 1.0:0.15

animation:

--ref (previousref==1?1:MIN(previousref*2,16)) --deblock 1:1 --psy-rd 0.4:0 --aq-strength 0.6 --bframes 5

What that last bit of code on the --ref option does is compare the desired refs that you set, and if you chose 1, it will chose 1, or the minimal value of your desired reference frames times 2 compared against 16 references frames. So, if  I were to call x264 with the following options:

--ref 6 --tune animation

Then my final encode settings would result in a total of 12 reference frames, since 6 * 2 < 16.

That about wraps it up. If you want more information on any of these new changes, simply click the links I posted earlier in the article, as Dark Shikari goes into greater and greater detail about what each option means and how it will affect your encodes. Feel free to post any questions or comments!