colormatrix supports only 8bpc (8-bit per component) pixel formats, whereas colorspace supports 10bpc, 12bpc also.
They both do only YUV to YUV colorspace conversion YUV to RGB, and scaling requires swscale.
Video filter colorspace, colormatrix have the following relationship: (for both aforementioned purposes) (.and seems to be a more reliable choice for all these swscale hazards) There's also a filter using the external library zscale. Conversion between different color properties (bit-depth, range, matrix, transfer characteristics, primaries) can be done using the colorspace or colormatrix video filter. How to convert between colorspaces using FFmpeg?Ĭonversion between RGB/YUV is typically done using swscale.
The RGB/XYZ matrix, in AVFrame-> color_primaries.
transformation characteristics), in AVFrame-> color_trc
The YUV/RGB transformation matrix, in AVFrame-> colorspace.
The signal range, in AVFrame-> color_range.
The format (type and bit-depth), in AVFrame-> format.
The conversion matrix between the linearized RGB and the device-independent XYZ colorspace.įFmpeg stores all these properties in the AVFrame struct:.
The linearization function from RGB to a linear RGB signal.
The transformation matrix between YUV and RGB.
(YUV only, unlikely a problem for other type of signals.) (Note: "Full range" refers to the YUV component values being in the range 0–255, whereas "restricted range" has values between 16–235)
Whether the signals are full range or restricted range.
Whether the pixel buffer contains RGB, YUV or some other type of signals, and the bit-depth.
In practical terms, the things you care are: In FFmpeg, colorspaces are represented in the form of pixel format. These standards describe not just things like how to convert a YUV signal to RGB, but also how a RGB signal should be represented in terms of photon emission, in a device-independent way.
BT.2020 ("Ultra-High-Definition" or UHD).
The conversion between YUV pixel buffer representation and its visual representation depends on the type of the YUV represented in the pixel buffers, which are essentially device-dependent. In the following, the term YUV is used as in the FFmpeg pixel formats, referring to YCbCr in digital video. For more info read the respective Wikipedia article. Y'UV on other other hand specifies a colorspace consisting of luma (Y') and chrominance (UV) components. A more accurate term for how color is stored in digital video would be YCbCr. Note: The term "YUV" is ambiguous and often used wrongly, including the definition of pixel formats in FFmpeg.