[FFmpeg-user] Automatically ensuring level-conformance for H.264 encodes

Francois Visagie francois.visagie at gmail.com
Sun Nov 2 11:04:22 CET 2014

> -----Original Message-----
> From: ffmpeg-user-bounces at ffmpeg.org [mailto:ffmpeg-user-
> bounces at ffmpeg.org] On Behalf Of Carl Eugen Hoyos
> Sent: 01 November 2014 12:06
> To: ffmpeg-user at ffmpeg.org
> Subject: Re: [FFmpeg-user] Automatically ensuring level-conformance for
> H.264 encodes
> Francois Visagie <francois.visagie <at> gmail.com> writes:
> > The main aim of the attached utilities is to automatically ensure the
> > H.264 level-conformance of arbitrary encodes.
> > In other words, the utilities make it unnecessary to guess and/or
> > discover the required settings through trial-and-error test encodes.
> This sounds to me as if setting the H264 level through FFmpeg does not
> Is that correct?

It's a little more subtle than that; I'll try to explain.

1. When using presets, in my testing (lib)x246 does not use '--level m.n'/'
-x264opts level=m.n' to govern refs. In this scenario refs are governed by
preset alone in accordance with the preset settings listed by  x264
--fullhelp. (Although besides the point, (lib)x264 is actually prepared to
write specified level metadata that differs from the level encoded to, at
least when the latter is lower.)

2. The ffmpeg option '-level x.y' does set refs correctly, even when using
libx264 presets.

3. However, '-level x.y' is undocumented, while the '-x264opts' pass-through
mechanism is.

https://trac.ffmpeg.org/ticket/3947#ticket addresses 1, 2 and 3.

None of the above presents a problem when the target device manufacturer
specifies conservative individual maxima for _all_ parameters that govern
encoding level (e.g. frame size, frame rate, bitrate etc.), as well as for

a. Still, adhering to such conservative maxima might lead to sub-optimal
encodes. E.g., when using less than the specified maximum frame size, a
higher bitrate and/or refs value could have been used within the limits of
the specified level.
b. In all other cases - even when maximum level is specified - it is up to
the user to determine whether desired frame size, frame rate, bitrate etc.
will result in a conformant output level, at least. (When not using ffmpeg
and '-level x.y' the user will also need to determine the corresponding
maximum refs value for the particular combination of parameters.)

c. When the user is not concerned with conforming to a _specific_ level but
just conformance to whatever output level the encoder decides on, in most
cases 1. above will ensure that output is non-level-conformant. This is
especially true when using preset veryslow, which always sets refs to 16.
This can be overcome by specifying either '-level x.y' or refs directly, but
in either case the user needs to know the resulting output level in advance.

h264level and ffx264 address a, b and c.

> How can I reproduce this?
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user

More information about the ffmpeg-user mailing list