How to Find Video Color Space Using FFprobe
To determine the color space, color primaries, and color transfer characteristics of a video file, you can use FFprobe, the command-line media analyzer bundled with FFmpeg. This article provides the exact commands needed to extract this metadata quickly, explains what the command arguments mean, and details how to format the output for easy reading.
The Basic Command
To extract only the color space information from a video file, run the following command in your terminal:
ffprobe -v error -select_streams v:0 -show_entries stream=color_space,color_primaries,color_transfer -of default=noprint_wrappers=1 video.mp4Command Breakdown
-v error: Suppresses the default configuration and library banner warnings, ensuring you only see the requested metadata or actual errors.-select_streams v:0: Targets the first video stream of the file, ignoring audio, subtitles, or other data tracks.-show_entries stream=color_space,color_primaries,color_transfer: Instructs FFprobe to only display these three specific color-related metadata fields.-of default=noprint_wrappers=1: Formats the output as simplekey=valuepairs without wrapping them in generic program brackets.
Expected Output
After running the command, FFprobe will return output similar to this:
color_range=tv
color_space=bt709
color_primaries=bt709
color_transfer=bt709
Common values you might encounter include: *
bt709: Standard definition/High definition
(SDR) color space, common for HD web video. *
bt2020nc / arib-std-b67 /
smpte2084: High Dynamic Range (HDR) color spaces
used in 4K UHD videos. * bt470bg /
smpte170m: Standard definition (PAL/NTSC) color
spaces.
Exporting Output as JSON
If you are scripting or integrating this command into an application,
you can request the output in JSON format by changing the output format
(-of) argument:
ffprobe -v error -select_streams v:0 -show_entries stream=color_space,color_primaries,color_transfer -of json video.mp4This returns a clean JSON object:
{
"programs": [],
"streams": [
{
"color_range": "tv",
"color_space": "bt709",
"color_primaries": "bt709",
"color_transfer": "bt709"
}
]
}