encoders | 15 Nov 2018

x264, x265 and VP9: popular encoding options and trends



Motivation

It began 10 years ago in 2008. In fact, it had began earlier, but in 2008 our group released first report on x264 encoding options analysis. This report presents encoding presets that give better encoding performance (better speed of quality) than default options which are included in --preset. The results of codec launches on 3 videos with different encoding parameters from a cartesian product of 7 encoder’s options were explored. These encoding options were the subject of the investigation: Partitions (--partitions, partition search types), B-Frames (--bframes, number of consecutive B-frames between I and P), Reference Frames (--ref, maximum number of reference frames), Motion Estimation Method (--me, the way motion is detected), Subpixel Motion Estimation (--subme, determines how x264 makes decisions about motion estimation), Mixed References (--mixed-refs, allows x264 to have greater control over “Reference Frames”), Weighted Prediction (--weightb, turns on weighted prediction for B-frames)

The report in available here. It includes comments in russian, but charts and presets are presented in english.

Despite the limited number of studied options in this 2008 investigation the authors found several presets which decreases bitrate on ~9.5% in average with the same video quality and encoding speed, or increase encoding speed on 15% with the same video quality and bitrate.

Today we’d say that the study made with such small number of videos is not so representative. However, the authors had to limit test set with three videos because options analysis was made by brute-force search from all combinations which required several thousands encoder launches for each video. Actually, a number of studied encoding options is also not very big - in the study one fifth part of all x264 options in those version was analysed. Today number of options has increased almost three times:

Picture-1

You may have already guessed why this report was mentioned. Today we continue analysing video codecs including new study of encoding options efficiency. Fortunately, hardware capabilities now allow to conduct investigations on a larger number of videos and to analyst more encoding options. Nonetheless, in our world even modern codecs are still far from an ability to make brute-search for encoding options. Let’s consider our favourite example for x264 encoder: brute-search for all values of it’s encoding options for only 500-frames video will last ~2.2∗10^13 centuries of continuous calculations, which is equivalent to ~488 000 ages of the Earth.

Picture-2{}

This example is presented for calculations on Core i7-4770, but I suppose you agree with the fact that parallelizing won’t help in this case :)

There are several ways for reducing a number of analysed encoding options, which we have to apply in our study. The first one which comes into mind is to exclude options which depends on other options. They give no effect when those “parent” options are turned off, so in this case we will get the same results from launches with actually same encoding presets. The next step is more complicated: we need to choose encoding options for which we would start our analysis. In this post, we consider one of possible approaches, whis is based on an analysis of options popularity among professional users of codecs.

Data sources

In general codec users are oriented on the increase of compression rate rather than the increase of encoding speed. For companies, the decrease of encoded video file size causes more valuable savings of storage and transmission than savings of computing resources. Computing resources of end users today allow them to encode videos with any speed/quality rate which is easy to do by choosing appropriate --preset. But, x264 received --preset option only in 2008, so how codec users choose encoding options before that? We decided to analyse forums which are popular among codec users to find the most frequent encoding settings and to obtain statistics of their popularity by year. For this purpose we choose the following forums: Doom9, VideoHelp, Selur, Gleitz and FFMpeg Mailing lists. Table 1 shows a number of obtained user presets for analysis.

  x264 x265 VPx
Number of messages with encoding presets 18427 2222 597

Table 1. Number of messages in which encoding launches for three codecs lines were found.

Let’s start from analysing the results for x264 encoder.

The influence of developing --preset option

Before appearing --preset option users utilised options like --subme (determines how x264 makes decisions about motion estimation), --me (the way motion is detected), --bframes (number of b-frames for each frame), --pass (controls what statistics x264 will do with the --stats file), or --direct (prediction mode for ‘direct’ motion vectors). These encoding options controls the most important operations in video compression. Their variations could lead to unexpectable encoding result, and probably it was hard to choose all of them manually which caused hot topics on forums where users were sharing with different encoding launch lines. Picture 3 shows the distribution of popular options from 2005 until 2009.

Picture-3

Picture 3. X264 options popularity from 2005 until 2009 (before developing --preset).

After 2009 when x264 developers introduced --preset it immediately started to gain popularity, and after a year in 2010 it already begane the most popular option. This was the period when users were varying the most high number of x264 options (Picture 4).

Picture-4

Picture 4. X264 options popularity from 2009 until 2013 (5 years after developing –preset).

Since then, usage of --preset is increasing: different presets take from 5% (in 2013) to 12% (in 2018) of all encoding options:

Picture-5

Picture 5. X264 options popularity from 2013 until 2018.

Now, let’s consider what presets are the most popular among x264 users. For all analysed period from 2005 until 2018 veryslow, slow and ultrafast presets are the most popular and faster, superfast and placebo are the least popular.

Picture-6

Picture 6. Distribution of popular --preset values for all time since 2005.

The trend in popular presets by year confirms the state about quality-oriented use cases, however recently (after 2014) ultrafast preset became the second popular after slow while only slow presets were the most popular from 2009 until 2012.

Picture-7

Picture 7. Distribution of popular --preset values from 2009 until 2012.

OK, we see that most of codec users prefer to use --preset rather than suffer with a choice of appropriate options values. But there are also another highly popular options which you could see on the charts: --bitrate and --ref. Why don’t we consider their appearance?

Picture-8

Picture 8. Distribution of popular --preset values from 2014 until 2018.

Rate-control: CRF, Bitrate and QP

First of all, we should point that we don’t pay much attention to these options because they both controls the compression rate in general, so their values are too different for every user and use case. That is why we don’t drilldown the distribution of popular bitrates. Nonetheless, there is interesting notice in users’ preference between different rate-control options. For example, --qp option was not popular at all time, but --crf and --bitrate changes their popularity by year.

In the beginning, --bitrate was the most common way to limit encoded file size. But, since 2012 and until nowadays --crf states at the leading position. Moreover, --crf has already overtooks --bitrate by the proportion of usage.

Picture-9-1

Picture-9-2

Picture 9. Distribution of popular --preset values from 2014 until 2018.

Conclusion

On overall charts (Pictures 1, 2, 3) we see, that many options were popular in the end of 2000s. But since then we observe the decrease in the number of used options. You could ask: why is this so important? People are seemed happy to use default presets which are stable and give good results?

We started our study from learning default presets, and guess what: x264 default presets haven’t been updated since 2010! The correct conclusion is: codec tuning by choosing encoding options give reasonable gain for encoding performance. And finally we show as an example in support for this rule one of our results:

Picture-10

Default presets and evaluated pareto-optimal set of encoding presets for x264 on Apple tree video sequence

But this is the other story…:) Thank you for reading, and choose fine options for your videos!

Interactive Charts

You can see other interesting dependinces on interactive charts:

About the Author

EVT team

Increase codec profit by deep tuning