VP9 HDR Encoding Flags for libvpx

This article provides a direct guide to the command-line flags required to enable High Dynamic Range (HDR) encoding using the libvpx library (specifically for VP9 video). You will learn the exact parameters needed for color space, pixel format, and transfer characteristics to produce HDR10 or HLG compliant video files using FFmpeg with libvpx-vp9.

To successfully encode HDR video using libvpx, you must use the VP9 codec, as VP8 does not support HDR. Encoding HDR requires shifting to a 10-bit color depth profile and explicitly signaling the HDR metadata so playback devices can recognize and display the wider color gamut and dynamic range.

Essential Command-Line Flags

The following flags must be passed to your encoder (typically via FFmpeg) to enable HDR:

1. Enable 10-bit Profile

2. Set 10-bit Pixel Format

3. Define the Color Primaries

4. Set the Transfer Characteristics (HDR Type)

You must choose the transfer function based on whether you are encoding HDR10 (PQ) or HLG: * For HDR10 (PQ): -color_trc smpte2084 * For HLG: -color_trc arib-std-b67

5. Set the Color Space Matrix

6. Set the Color Range


Static Metadata Flags (For HDR10)

If you are encoding HDR10, you should also include mastering display metadata and Content Light Level (CLL) metadata so compatible TVs can map the brightness levels correctly.


Complete Command-Line Example

Here is a complete FFmpeg command-line example utilizing libvpx-vp9 to encode an HDR10 video:

ffmpeg -i input.mp4 \
  -c:v libvpx-vp9 \
  -profile:v 2 \
  -pix_fmt yuv420p10le \
  -color_primaries bt2020 \
  -color_trc smpte2084 \
  -colorspace bt2020nc \
  -color_range tv \
  -b:v 15M \
  -crf 15 \
  output.webm