Skip to main content

VideoColorSpace

The VideoColorSpace class describes the color representation of video content. It specifies how color values should be interpreted, including the color gamut (primaries), brightness encoding (transfer), and YUV conversion (matrix).

Quick Example


Constructor

Creates a new VideoColorSpace from initialization data.
init
VideoColorSpaceInit
Optional configuration object for the color space.

Properties

All properties are readonly after construction.
primaries
VideoColorPrimaries | null
required
The color primaries defining the color gamut. Returns null if not specified.
transfer
VideoTransferCharacteristics | null
required
The transfer characteristics (gamma/EOTF) for brightness encoding. Returns null if not specified.
matrix
VideoMatrixCoefficients | null
required
The matrix coefficients for RGB-to-YUV conversion. Returns null if not specified.
fullRange
boolean | null
required
Whether full range (0-255) or limited range (16-235) is used. Returns null if not specified.

Methods

toJSON()

Returns a plain object representation of the color space, suitable for serialization.
Returns: A VideoColorSpaceInit object containing all color space properties.

Color Primaries

Color primaries define the color gamut (range of colors) that can be represented.
The standard for HD television and web video. Covers approximately 35% of visible colors. This is the default for most SDR content and should be used for web distribution.
The standard for HDR and UHD content. Covers approximately 75% of visible colors. Required for HDR10 and HLG content. Use with pq or hlg transfer functions.
Used in digital cinema projection and Apple displays. Covers approximately 45% of visible colors. A middle ground between BT.709 and BT.2020.

Transfer Characteristics

Transfer characteristics (also called EOTF - Electro-Optical Transfer Function) define how brightness values are encoded.
The standard gamma curve for SDR content. Uses approximately 2.4 gamma with a linear segment near black. Use for all standard web and broadcast video.
The transfer function for HDR10 content (SMPTE ST.2084). Encodes absolute brightness up to 10,000 nits. Provides the best HDR quality but requires display calibration. Most common HDR format.
A relative brightness encoding that is backward-compatible with SDR displays. Used primarily in broadcast (BBC, NHK). Simpler than PQ and degrades gracefully on SDR displays.
No gamma correction applied. Values represent linear light intensity. Used for compositing and color grading workflows, not for display.

Matrix Coefficients

Matrix coefficients define how RGB values are converted to/from YUV color space.
For HDR content, always use bt2020-ncl (non-constant luminance). The bt2020-cl (constant luminance) variant exists but is rarely used in practice.

Common Presets

BT.709 SDR (Standard Web Video)

Use for: HD video, web streaming, YouTube, social media.

BT.2020 HDR10

Use for: 4K HDR content, Netflix, Apple TV+, streaming HDR.

BT.2020 HLG

Use for: Broadcast HDR, live TV, SDR-compatible HDR.

DCI-P3 (Apple Devices)

Use for: Apple displays, wide-gamut SDR content.

Full Range RGB (Computer Graphics)

Use for: Screen capture, computer graphics, game footage.

VideoColorSpaceInit Interface

The initialization object used to construct a VideoColorSpace.
All properties are optional. Unspecified properties default to null, meaning the value is unknown or unspecified.

Type Definitions

VideoColorPrimaries

VideoTransferCharacteristics

VideoMatrixCoefficients


Usage with VideoEncoder

Specify color space when encoding to ensure proper metadata in the output:

See Also

VideoFrame

Raw video frame with color space metadata

VideoEncoder

Encode frames with color space configuration

HDR Encoding Guide

Complete guide to HDR video encoding

VideoDecoder

Decode video with color space preservation