Skip to main content

Overview

High Dynamic Range (HDR) video captures a wider range of brightness and colors than Standard Dynamic Range (SDR), providing:
  • Brighter highlights (up to 10,000 nits vs 100 nits for SDR)
  • Deeper blacks with more shadow detail
  • Wider color gamut (BT.2020 vs BT.709)
  • More realistic and immersive viewing experience
node-webcodecs supports HDR encoding through color space metadata configuration.

HDR Standards

HDR10

Most Common HDR Format
  • BT.2020 color primaries
  • PQ (ST.2084) transfer function
  • 10-bit color depth
  • Static metadata

HLG

Broadcast HDR
  • BT.2020 color primaries
  • HLG transfer function
  • Backward compatible with SDR
  • No metadata needed

Dolby Vision

Premium HDR
  • Dynamic metadata
  • Proprietary encoding
  • Best quality
  • Limited support

HDR10+

Enhanced HDR10
  • Dynamic metadata
  • Scene-by-scene optimization
  • Open standard
  • Growing support

Quick Start: HDR10 Encoding

Color Space Parameters

Color Primaries

Defines the color gamut (range of colors):
Wide Color Gamut for HDR
  • Covers ~75% of visible colors
  • Standard for HDR10, HLG
  • Much wider than BT.709 (SDR)
  • Used in UHD/4K content
Standard Dynamic Range
  • Covers ~35% of visible colors
  • Standard for HD TV, web video
  • Most common color space
Digital Cinema / Apple Displays
  • Covers ~45% of visible colors
  • Used in cinema projection
  • Native to Apple displays
  • Between BT.709 and BT.2020

Transfer Function

Defines how brightness values are encoded:
Perceptual Quantizer
  • Absolute brightness encoding
  • 0-10,000 nits range
  • Best quality HDR
  • Requires display calibration
  • Most common HDR transfer function
Hybrid Log-Gamma
  • Relative brightness encoding
  • Backward compatible with SDR
  • No metadata needed
  • Common in broadcast
  • Simpler than PQ
Standard Dynamic Range
  • Gamma 2.2 / 2.4 encoding
  • 0-100 nits range
  • Used for SDR content

Matrix Coefficients

Defines RGB ↔ YUV conversion:

Color Range

Complete HDR10 Example

HLG (Hybrid Log-Gamma) Encoding

HLG is simpler than PQ and backward-compatible with SDR displays:
HLG Benefits:
  • No metadata required
  • Works on SDR displays (degrades gracefully)
  • Common in broadcast (BBC, NHK)
  • Simpler than HDR10
HLG Limitations:
  • Relative (not absolute) brightness
  • Slightly lower quality than PQ
  • Less common in streaming

Verifying HDR Metadata

After encoding, verify the HDR metadata with ffprobe:
Expected Output:
  • color_primaries=bt2020 ✓ Wide color gamut
  • color_transfer=smpte2084 ✓ PQ (ST.2084)
  • color_space=bt2020nc ✓ BT.2020 non-constant luminance
  • color_range=tv ✓ Limited range (16-235)

HDR Codec Support

Best Codecs for HDR

10-Bit and 12-Bit Encoding

HDR requires higher bit depth to avoid banding:
Bit Depth Importance
  • 8-bit: 256 levels per channel (SDR)
  • 10-bit: 1,024 levels per channel (HDR10 standard)
  • 12-bit: 4,096 levels per channel (Dolby Vision)
Higher bit depth prevents banding in HDR’s wider dynamic range.

Platform-Specific HDR Support

macOS (VideoToolbox)

VideoToolbox automatically handles 10-bit encoding for HDR.

Windows / Linux (NVIDIA NVENC)

NVENC supports 10-bit HEVC on newer GPUs (GTX 1000+).

Intel QuickSync

QuickSync supports 10-bit HEVC on 7th gen Core+ (Kaby Lake+).

Common Issues

Issue: HDR metadata not preserved

Solution: Ensure color space is specified in both encoder config AND per-frame:

Issue: Banding in gradients

Cause: 8-bit encoding for HDR content Solution: Use 10-bit codec and increase bitrate:

Issue: Colors look washed out

Cause: Incorrect color space or transfer function Solution: Verify color space settings match your source:

Best Practices

HEVC (H.265) provides the best compression and widest HDR support.
HDR needs 25-50% more bitrate than SDR for equivalent quality:
Always verify HDR output on actual HDR displays:
  • Apple XDR Display
  • HDR TVs
  • HDR monitors
SDR displays cannot show true HDR.
Not all devices support HDR. Encode both versions:

Next Steps

Hardware Acceleration

GPU-accelerated HDR encoding

HDR Examples

Complete HDR encoding examples

Color Space API

VideoColorSpace reference

Real-World Demo

Production HDR workflows