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).
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.mp4These 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.
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.
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-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.
A phenomenon where a smooth change in brightness shows up as stair-step bands. It stands out when the bit depth is low.
An x265 option. Repeats the VPS, SPS and PPS headers at every keyframe.
The area inside the bitstream where the color gamut, transfer function, matrix, and similar information is written.
What is the right attitude when setting the master-display value?