How to Set libx265 Level in FFmpeg

This article provides a quick guide on how to configure the level parameter in the libx265 encoder using FFmpeg. You will learn the correct command-line syntax, understand the difference between standard FFmpeg flags and x265-specific parameters, and see practical examples to ensure your HEVC/H.265 encoded videos are compatible with target playback devices.

To configure the H.265/HEVC level in FFmpeg using the libx265 encoder, you can use two different methods: the native FFmpeg -level option or the encoder-specific -x265-params option.

The most straightforward way to set the level is by using the standard -level flag. FFmpeg automatically maps this value to the corresponding H.265 Level Indicator (level-idc).

For example, to set the level to 5.1:

ffmpeg -i input.mp4 -c:v libx265 -level 5.1 output.mp4

In HEVC, levels are specified with a decimal point (e.g., 4.0, 5.0, 5.1, 6.2).

Method 2: Using -x265-params

Alternatively, you can pass the parameter directly to the underlying libx265 library using the -x265-params argument. In x265, the level parameter is defined as level-idc.

To specify the level using this method, multiply the level number by 10 (for example, level 5.1 becomes 51, level 4.0 becomes 40):

ffmpeg -i input.mp4 -c:v libx265 -x265-params level-idc=51 output.mp4

To pass multiple parameters together, separate them with a colon:

ffmpeg -i input.mp4 -c:v libx265 -x265-params level-idc=51:high-tier=1 output.mp4

Why Define the Level Parameter?

The level parameter defines a set of constraints—such as maximum resolution, frame rate, and bitrate—that a decoder must support to play back the video. Specifying a level is critical when targeting hardware with limited decoding capabilities, such as smart TVs, older tablets, or mobile devices.

If you do not specify a level, libx265 will automatically select the lowest possible level that accommodates your video’s resolution, frame rate, and bitrate.

Standard/High Tier Selection

HEVC levels are divided into two tiers: Main tier (for most consumer applications) and High tier (for demanding professional applications). By default, libx265 assumes the Main tier unless specified otherwise.

If you need to force the High tier along with your level, use the -x265-params option:

ffmpeg -i input.mp4 -c:v libx265 -x265-params level-idc=5.1:high-tier=1 output.mp4