Every video frame can carry a description of its colors: which primaries, transfer function and matrix the picture uses, whether it is HDR, and the static HDR10 metadata of the mastering display. Sources write this description to the frame as strings; outputs and encoders read it to signal the right format downstream. This article lists the keys, their values, who sets them and who uses them. Pixel formats, 10-bit processing and HDR preview are covered in HDR and 10bit video processing.
The keys are frame strings: read them with MFStrGet and set them with MFStrSet, as described in
Frame metadata: MFStrGet, MFStrSet, MFDataGet and MFDataSet.
They only describe the picture: changing a key does not convert the pixels.
Color keys
| Key | Values | Meaning |
|---|---|---|
v_colors | BT601, BT709, BT2020 | Color primaries. File decoders always set it: from the stream, or, when the stream does not say, BT601 up to 625 lines and BT709 above. |
v_transfer | BT601, BT709, BT2020, HLG, PQ | Transfer function (opto-electronic transfer). |
v_hdr | SDR, HDR, PQ, HLG | HDR signal type. PQ is HDR10 (SMPTE ST 2084), HLG is Hybrid Log-Gamma. Consumers that need the transfer function use v_hdr when v_transfer is missing. |
v_matrix | BT601, BT709, BT2020, BT2100 | YUV matrix coefficients. Set only when the source describes them; BT2100 is ICtCp. |
v_color_range | mpeg, jpeg, unspecified | Video range: mpeg is limited (16–235 for 8 bit), jpeg is full. |
HDR10 static metadata
The mastering display metadata (SMPTE ST 2086) and the content light levels describe the display on which the HDR program was graded. They matter for PQ; HLG does not use them.
| Key | Unit | Meaning |
|---|---|---|
hdr.primary_red.x, hdr.primary_red.y, hdr.primary_green.x, hdr.primary_green.y, hdr.primary_blue.x, hdr.primary_blue.y | CIE 1931 chromaticity, decimal (for example 0.708) | Primaries of the mastering display |
hdr.white_point.x, hdr.white_point.y | CIE 1931 chromaticity, decimal (D65 is 0.3127, 0.3290) | White point of the mastering display |
hdr.max_luminance, hdr.min_luminance | cd/m² (for example 1000 and 0.0001) | Luminance range of the mastering display |
hdr.max_cll, hdr.max_fall | cd/m² | Maximum content light level and maximum frame-average light level |
hdr.primary_red.x_den and the other _den keys | Integer | Denominator of the value in the stream (50000 for chromaticity, 10000 for luminance in HEVC). The file reader sets them; the FFmpeg encoding path uses them to rebuild the exact fractions. |
Sources
| Source | Keys |
|---|---|
| Files (MFile, MFReader), FFmpeg and NVIDIA decoders | v_colors and v_color_range always (the reader option video.color_range overrides the range); v_transfer and v_matrix when the stream describes them; v_hdr for PQ and HLG; the mastering display keys hdr.* with their _den keys when the stream has mastering display metadata. Files do not give hdr.max_cll and hdr.max_fall. |
| Blackmagic input | v_hdr (SDR, HDR, PQ, HLG) and v_colors from the DeckLink frame metadata. For an HDR input also the hdr.* keys, including hdr.max_cll and hdr.max_fall, which are also published as stat::hdr.*. No v_transfer and no v_matrix. |
| AJA input | v_hdr, v_colors and, for HLG and PQ, v_transfer, from the VPID of the SDI signal. |
| Bluefish444 input | v_hdr, v_colors and, for HLG and PQ, v_transfer, from the input signal. |
| NDI input | v_colors, v_transfer, v_matrix and, for PQ and HLG, v_hdr. |
Inputs set no key that the signal does not describe: a missing key means "unknown", not SDR.
Consumers
| Consumer | What it does with the keys | Renderer or writer properties that override the frame |
|---|---|---|
| Blackmagic output | When the card supports HDR metadata and both the frame and the output format are 10 bit, sends the HDR type from v_hdr and the colorimetry from v_colors (BT.601 only for SD, BT.2020 only for UHD; PQ and HLG use BT.2020). For PQ it also sends the mastering display and light levels from the hdr.* keys; a missing key gets a default: BT.2020 primaries, D65, 1000 and 0.0001 cd/m², MaxCLL 1000, MaxFALL 50. | v_hdr (SDR, HDR, PQ, HLG), v_colors (Auto, BT709, BT2020, BT601) |
| DELTACAST output | For 10-bit output, signals the colorimetry from v_colors (BT.2020 or BT.709; BT.709 when the key is missing) and the transfer function from v_hdr (PQ or HLG). | v_colors (Auto, BT709, BT2020), v_hdr (Auto, PQ, HLG) |
| Bluefish444 output | Signals the transfer function from v_transfer (or v_hdr when v_transfer is missing) and the colorimetry from v_colors. HLG and PQ are sent only with 10-bit YUV (v210) output. | v_hdr (auto, SDR, HLG, PQ), v_transfer (used when v_hdr is auto), v_colors (auto, BT601, BT709, BT2020) |
NVENC encoders (n264, n265, nav1 and the lossless ones, MFCodecs encoder) | Write the color description of the stream (VUI) from v_colors, v_transfer (or v_hdr), v_matrix and v_color_range. | Writer options color_primaries, color_trc, colorspace, color_range; see Audio and video codecs |
FFmpeg encoders (for example libx265) | The encoded frame gets the range, the primaries, the transfer function from v_transfer, the matrix from v_matrix and the mastering display metadata from the hdr.* keys. Whether the encoder writes them to the stream depends on the encoder and its options. | Options of the encoder |
| AJA output | Does not read the keys. |
Set the renderer properties with PropsSet on MFRenderer, or with the device:: prefix on MRenderer
(device::v_hdr). A forced value applies to every frame; leave the property empty (or Auto) to follow the frame.
The FFmpeg encoding path reads only v_transfer, not v_hdr. A Blackmagic input sets only
v_hdr, so set v_transfer on the frames yourself when you encode such a signal with an FFmpeg encoder.
Reading the keys
// MFormats: frame from SourceFrameGet. MPlatform: the frame of OnFrameSafe, cast to IMFFrame.
frame.MFStrGet("v_hdr", out string hdr); // "PQ", "HLG", "SDR", "HDR" or empty
frame.MFStrGet("v_colors", out string primaries); // "BT2020", "BT709", "BT601" or empty
frame.MFStrGet("v_transfer", out string transfer);
frame.MFStrGet("hdr.max_luminance", out string maxLuminance);
if (!string.IsNullOrEmpty(maxLuminance))
{
double nits = double.Parse(maxLuminance, System.Globalization.CultureInfo.InvariantCulture);
Console.WriteLine($"{hdr}, {primaries}, mastering display up to {nits} cd/m2");
}
Marking frames as HDR10
When a source delivers PQ pictures without a description (for example frames you create yourself), describe them before they
reach the output or the encoder. Use decimal points in the values, independent of the system locale. The FFmpeg encoding
path builds the fractions of the mastering display from the _den keys, so set them too.
static void SetHdrValue(IMFFrame frame, string key, string value, string denominator)
{
frame.MFStrSet(key, value);
frame.MFStrSet(key + "_den", denominator);
}
frame.MFStrSet("v_hdr", "PQ");
frame.MFStrSet("v_transfer", "PQ");
frame.MFStrSet("v_colors", "BT2020");
frame.MFStrSet("v_matrix", "BT2020");
// Mastering display: P3 primaries, D65 white point, 1000 cd/m2
SetHdrValue(frame, "hdr.primary_red.x", "0.680", "50000");
SetHdrValue(frame, "hdr.primary_red.y", "0.320", "50000");
SetHdrValue(frame, "hdr.primary_green.x", "0.265", "50000");
SetHdrValue(frame, "hdr.primary_green.y", "0.690", "50000");
SetHdrValue(frame, "hdr.primary_blue.x", "0.150", "50000");
SetHdrValue(frame, "hdr.primary_blue.y", "0.060", "50000");
SetHdrValue(frame, "hdr.white_point.x", "0.3127", "50000");
SetHdrValue(frame, "hdr.white_point.y", "0.3290", "50000");
SetHdrValue(frame, "hdr.max_luminance", "1000", "10000");
SetHdrValue(frame, "hdr.min_luminance", "0.0001", "10000");
// Content light levels (used by the Blackmagic output)
frame.MFStrSet("hdr.max_cll", "1000");
frame.MFStrSet("hdr.max_fall", "400");
To make one output send HDR for all frames, without changing the frames, force it on the renderer instead:
// MFormats
renderer.PropsSet("v_hdr", "PQ");
renderer.PropsSet("v_colors", "BT2020");
// MPlatform
m_objRenderer.PropsSet("device::v_hdr", "PQ");
m_objRenderer.PropsSet("device::v_colors", "BT2020");
The output must also be 10 bit: Blackmagic, DELTACAST and Bluefish444 send HDR signaling only for 10-bit output. Marking an SDR picture as PQ does not make it HDR; it only makes the display interpret it wrongly.
Still have questions?
Tell us what didn’t work or what you’d like clarified.