Configure uhd-bd Option in FFmpeg libx265

This guide explains how to configure the uhd-bd option in the FFmpeg libx265 encoder to produce Ultra HD Blu-ray compatible HEVC videos. You will learn the required FFmpeg syntax, key parameter combinations, and a practical command-line example to ensure your encoded video adheres to official UHD Blu-ray specifications.

Enabling the uhd-bd Option

The uhd-bd option is a flag within the libx265 encoder that restricts the encoding process to comply with the Ultra HD Blu-ray specification. To enable this option in FFmpeg, you must pass it inside the -x265-params argument.

The basic syntax for enabling the option is:

-c:v libx265 -x265-params uhd-bd=1

Mandatory Complementary Settings

Simply enabling uhd-bd=1 is not enough to create a fully compliant UHD Blu-ray stream. You must also configure specific color depths, chroma subsampling, and Video Buffer Verifier (VBV) settings.

  • Color Format: UHD Blu-ray requires 10-bit color depth and 4:2:0 chroma subsampling. In FFmpeg, this is set using -pix_fmt yuv420p10le.
  • VBV Restrictions: You must set maximum bitrate and buffer size limits to prevent playback hardware from stuttering. The maximum video bitrate for UHD Blu-ray is typically 100 Mbps (100,000 kbps), with a matching buffer size.
  • Color Primaries (HDR): If encoding HDR10 content, you must specify the BT.2020 color space, SMPTE 2084 transfer characteristics, and non-constant luminance matrix.

Full Command Example

Below is a complete FFmpeg command to transcode a video into a compliant UHD Blu-ray HEVC stream:

ffmpeg -i input.mp4 -c:v libx265 -pix_fmt yuv420p10le \
-x265-params uhd-bd=1:vbv-maxrate=100000:vbv-bufsize=100000:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:aud=1:repeat-headers=1 \
-c:a copy output.ts

Parameter Breakdown:

  • -c:v libx265: Selects the HEVC/H.265 encoder.
  • -pix_fmt yuv420p10le: Sets the pixel format to 10-bit YUV 4:2:0.
  • uhd-bd=1: Enables UHD Blu-ray compatibility mode in x265.
  • vbv-maxrate=100000: Sets the maximum peak bitrate to 100,000 kbps.
  • vbv-bufsize=100000: Sets the VBV buffer size to 100,000 kb.
  • colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc: Flags the video stream as HDR10 using the BT.2020 color space.
  • aud=1: Forces the encoder to write Access Unit Delimiters, which are required for Blu-ray stream parsing.
  • repeat-headers=1: Forces the encoder to repeat VPS/SPS/PPS headers at every keyframe, ensuring the Blu-ray player can decode the stream at any entry point.