Ch. 14 · HDR Workflow in Practice

한국어日本語
8 min

Encoding 10-bit HDR10 with x265

Setting the three color tags and HDR10's static metadata directly with x265 options, and how to read what the values mean.

In the Chapter 10 exercise we passed over hdr10=1 with a note that "master-display and max-cll values must also be specified separately." This time we fill in those values. The target is PQ, BT.2020, 10-bit, 4:2:0 HEVC (Main10).

An x265 encode with HDR10 static metadata specified directly (values are examples)
ffmpeg -i input_hdr.mov \
  -c:v libx265 -preset slow -crf 20 \
  -pix_fmt yuv420p10le -profile:v main10 \
  -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc \
  -x265-params "hdr10=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):max-cll=1000,400" \
  -an output_hdr10.mp4

How to read the master-display value

FieldExample valueMeaning
G(x,y)G(13250,34500)Green primary coordinates. The unit is 0.00002, so this is (0.265, 0.690)
B(x,y)B(7500,3000)Blue primary coordinates (0.150, 0.060)
R(x,y)R(34000,16000)Red primary coordinates (0.680, 0.320)
WP(x,y)WP(15635,16450)D65 white point (0.3127, 0.3290)
L(max,min)L(10000000,1)The unit is 0.0001 nit, so the maximum is 1,000 nits and the minimum is 0.0001 nit

These coordinates are the common notation for content mastered with DCI-P3 primaries and a D65 white point. Actual values must always follow the monitor and editing software you mastered with.

Don't copy the example values

master-display and max-cll are fields that record a fact about how the video was actually mastered. Read the values already in the source with ffprobe and carry them over as they are, or use the values your editing software reports. If you enter values that don't match, the display will tone map using wrong information. If you don't know the values, leaving them blank is better than making them up.

Reading the HDR metadata in the source (side data of the first frame)
ffprobe -v error -select_streams v:0 -read_intervals "%+#1" \
  -show_frames -show_entries frame=color_space,color_transfer,color_primaries:frame_side_data_list \
  input_hdr.mov
  • `-pix_fmt yuv420p10le`: 10-bit. If you drop to 8-bit, PQ's wide brightness range gets squeezed into fewer steps, and banding is likely to show up in gentle gradients like the sky (see bit depth in Chapter 1).
  • `repeat-headers=1`: repeats the parameter-set headers (VPS, SPS, PPS) at every keyframe, so decoding can still start when you begin playback partway through or cut the file into segments.
  • **Set -color_* and colorprim=... together**: it's safest to specify both, so the same values end up on the container side and in the bitstream (VUI).

For a feel for choosing CRF values and presets, the approach is the same as for SDR: see the CRF Recommender and the lab article. Just remember that this site's measured data was taken with SDR 8-bit clips. There is no guarantee that the same CRF gives the same quality on HDR 10-bit video.

BandingBanding

A phenomenon where a smooth change in brightness shows up as stair-step bands. It stands out when the bit depth is low.

repeat-headersrepeat-headers

An x265 option. Repeats the VPS, SPS and PPS headers at every keyframe.

VUIVideo Usability Information

The area inside the bitstream where the color gamut, transfer function, matrix, and similar information is written.

Check yourself

What is the right attitude when setting the master-display value?