Configure libx265 Profile Parameter in FFmpeg

This article provides a straightforward guide on how to configure the profile parameter for the libx265 (HEVC) encoder in FFmpeg. You will learn the correct command-line syntax, the available profile options—such as main, main10, and mainstillpicture—and how to apply them to optimize your video encoding workflow for compatibility and color depth.

To configure the profile in FFmpeg using the libx265 encoder, you use the -profile:v flag. This parameter tells the encoder which HEVC profile standard to target, ensuring the output video is compatible with specific playback devices.

Basic Syntax

The standard syntax for setting the profile is:

ffmpeg -i input.mp4 -c:v libx265 -profile:v <profile_name> output.mp4

Replace <profile_name> with one of the supported HEVC profiles.

Supported libx265 Profiles

The three most common profiles used with libx265 are:

The Relationship Between Profile and Pixel Format

When setting a profile, you must ensure your pixel format (-pix_fmt) matches the color depth of that profile. If there is a mismatch, FFmpeg may output an error or override your settings.

Example 1: Force Main (8-bit) Profile

To encode a highly compatible 8-bit HEVC video, pair the main profile with the yuv420p pixel format:

ffmpeg -i input.mp4 -c:v libx265 -profile:v main -pix_fmt yuv420p output.mp4

Example 2: Force Main 10 (10-bit) Profile

For high-quality 10-bit encodes, pair the main10 profile with the yuv420p10le pixel format:

ffmpeg -i input.mp4 -c:v libx265 -profile:v main10 -pix_fmt yuv420p10le output.mp4

Passing Parameters Directly to x265

Alternatively, you can configure the profile directly inside the -x265-params option. This is useful if you are passing multiple x265-specific variables at once:

ffmpeg -i input.mp4 -c:v libx265 -x265-params profile=main10 -pix_fmt yuv420p10le output.mp4

Using either -profile:v or the -x265-params method will successfully limit the HEVC stream to your specified profile constraint.