<p>Well, and yeah, all answers are wrong here. HDR is only the new transfer function, PQ or HLG. So that means you need to look into that, PQ is SMPTE 2084 and HLG is ARIB STD-B67.</p>
<p>Yes, 8 bit file tagged as PQ will be played as HDR.</p>
<p>Yes, 10 bit files tagged as BT.2020 transfer are SDR, because BT.2020 transfer is the same as BT.709 and BT.601. Moreover Rec. BT.2020 is SDR only spec., HDR was defined in BT.2100. Master files of Hollywood used 10 bit in SDR for a long time.</p>
<p>Yes, you need to color manage BT.2020 primaries to your primaries. Just as before PAL primaries were supposed to be color managed to what display primaries are.</p>
<p>Yes, it is 0.0001 to 10000 nits, not 0.001 to 4000 in PQ. Yes, 65 Y' is actually 0.00005 nits and 64 Y' is 0.000000 nits. Black body.</p>
<p>Yes, BT.2390 EETF dynamical tone mapper is mandatory unless the master display is full 10000 nits.</p>
<p>Yes, almost all movies are inside P3-D65 inside BT.2020, only Planet Earth 2 and Matrix are not and some others. That changed in 2022, since Netflix allowed to use BT.2020 primaries for their JPEG2000 masters.</p>
<p>Yes, film cameras supported HDR back in 1970s and they are nowadays converted to PQ and image format .pcd (Photo CD) supported HDR and WCG.</p>

CC BY-SA 4.0
2022-01-04T14:25:33.953Z
thanks for this helpful answer - but what does this mean in practical terms? how should we check for HDR with ffmpeg?
danday74
CC BY-SA 4.0
2022-01-04T14:28:42.503Z
ffprobe file, look for smpte2086 or arib transfer.
Валерий Заподовников
CC BY-SA 4.0
2022-01-04T14:33:23.020Z
color_space=bt2020nc ... color_transfer=arib-std-b67 ... color_primaries=bt2020 ... this is what I have ... IF color_primaries === 'bt2020' && (color_transfer.startsWith('arib') || color_transfer.startsWith('smpte')) ... does this check sound correct? the other guys refer to smpte2084 not smpte2086 which is why I used startsWith
danday74
CC BY-SA 4.0
2022-01-04T14:48:58.937Z
smpte 2084, yes, a typo. No, primaries are not required.
Валерий Заподовников
CC BY-SA 4.0
2022-01-04T14:54:36.830Z
many thanks much appreciated
danday74
CC BY-SA 4.0
2023-05-29T02:07:26.423Z
I have an HLG HDR video, and I can't figure out how to identify it in MediaInfo. Looks like a regular file; not a special HDR one. It definitely plays back in HDR. What's the trick?
Kevin Ghadyani
CC BY-SA 4.0
2023-05-29T04:09:06.883Z
@KevinGhadyani What does Mediainfo say for transfer function?
Валерий Заподовников
CC BY-SA 4.0
2023-05-29T04:50:16.990Z
I'm not seeing anything called "transfer function". But as an update, that file was mislabeled I'm thinking. My TV didn't go into HLG mode when playing it on my SHIELD. I downloaded an HLG file from YouTube, and "transfer characteristics" properly shows HLG. I wonder if that other video was mislabeled: https://4kmedia.org/lg-cymatic-jazz-hdr-hlg-uhd-4k-demo/
Kevin Ghadyani
CC BY-SA 4.0
2023-05-29T18:11:33.087Z
@KevinGhadyani The MPEG-TS file from 4kmedia is labeled Transfer characteristics    : HLG / BT.2020 (10-bit), so it is indeed HLG. So?
Валерий Заподовников
CC BY-SA 4.0
2023-05-30T00:14:33.647Z
It is. When using MKVToolNix, it removed it. It all makes sense now.
Kevin Ghadyani
CC BY-SA 4.0
2021-05-15T12:56:09.723Z
2022-12-25T09:02:32.953Z
2022-12-25T09:02:32.953Z
Валерий Заподовников
<p>This answer relies on but simplifies the answer by Валерий Заподовников who seems to know his stuff.</p>
<pre><code>ffprobe -v quiet -show_streams -select_streams v:0 video.mp4 | grep ^color_transfer=
</code></pre>
<p>IF color_transfer EQUALS <code>arib-std-b67</code> OR <code>smpte2084</code> THEN the video is HDR</p>

CC BY-SA 4.0
2022-04-29T14:19:58.933Z
Thanks, this answer helped me most.
Is there a way to do a grep where it just shows a result when we have arib-std-b67 OR smpte2084, and not output anything when that is NOT the case?
I want to use this in a batch file for a lot of movies at once.
Sander Bouwhuis
CC BY-SA 4.0
2022-12-25T08:53:00.683Z
Indeed, correct.
Валерий Заподовников
CC BY-SA 4.0
2022-01-04T15:16:51.380Z
2022-01-04T15:16:51.380Z
danday74
<p>I've found how to get this information from color primaries attribute. Considering color primaries BT.2020 as a HDR video.</p>

<pre><code>mediainfo video.mp4 --Inform="Video;%colour_primaries%"
</code></pre>

<p>In this example above, if the return of the command is <strong>BT.2020</strong> so I consider the video as HDR. 
Otherwise SDR.</p>

CC BY-SA 3.0
2018-01-06T20:53:31.087Z
Technically, that will only determine if a video is WCG.  To test for HDR-ness, you also need to check that the transfer function is one of the HDR flavors.
Jason Conrad
CC BY-SA 3.0
2018-04-21T02:17:55.960Z
Nice to know @JasonConrad . So could I consider PQ and HLG as valid transfer functions for and HDR video?
Douglas Lise
CC BY-SA 3.0
2018-04-22T07:10:25.490Z
Yes. I *think* that the color space, transfer function, and bit depth (HDR also needs to be 10 bits per channel) are enough to minimally qualify video as HDR, but there are different flavors and specifications.
Jason Conrad
CC BY-SA 3.0
2017-12-14T18:34:26.527Z
2017-12-14T18:34:26.527Z
Douglas Lise
<p>Checking <code>color_primaries</code> is the right approach. I use <code>ffprobe</code> to get the JSON output. Then you can parse the JSON output instead of searching for a string in the normal output.</p>
<pre><code>$ ffprobe -v error -show_streams -select_streams v:0 -of json -i test.mp4
{
    &quot;streams&quot;: [
        {
            &quot;index&quot;: 0,
            &quot;codec_name&quot;: &quot;hevc&quot;,
            &quot;codec_long_name&quot;: &quot;H.265 / HEVC (High Efficiency Video Coding)&quot;,
            &quot;color_transfer&quot;: &quot;arib-std-b67&quot;,
            &quot;color_primaries&quot;: &quot;bt2020&quot;,
            &quot;refs&quot;: 1,
            // …
       }
    ]
}
</code></pre>

CC BY-SA 4.0
2020-12-06T16:05:45.953Z
2020-12-06T16:05:45.953Z
Sam Soffes
<p>Assuming your file is <code>${F}</code>, the below is an efficient means I have been able to create:</p>

<pre><code>COLORS=$(ffprobe -show_streams -v error "${F}" |egrep "^color_transfer|^color_space=|^color_primaries=" |head -3)
for C in $COLORS; do
        if [[ "$C" = "color_space="* ]]; then
                COLORSPACE=${C##*=}
        elif [[ "$C" = "color_transfer="* ]]; then
                COLORTRANSFER=${C##*=}
        elif [[ "$C" = "color_primaries="* ]]; then
                COLORPRIMARIES=${C##*=}
        fi      
done    
if [ "${COLORSPACE}" = "bt2020nc" ] &amp;&amp; [ "${COLORTRANSFER}" = "smpte2084" ] &amp;&amp; [ "${COLORPRIMARIES}" = "bt2020" ]; then 
        echo ${F}
fi
</code></pre>

<p>I use this inside a looping function to know when to use <a href="https://github.com/Fmstrat/ffmkv" rel="noreferrer">https://github.com/Fmstrat/ffmkv</a> to create an SDR version of a video on one of the presets.</p>

CC BY-SA 4.0
2019-10-21T13:48:33.447Z
Note, this defaults to the top video stream. I use `-select_stream` when I need to be specific. And you'll want to reset the variables in a loop.
Fmstrat
CC BY-SA 4.0
2020-08-18T21:31:20.660Z
So you assume that these parameters must be satisfied:

ColorSpace = bt2020nc;
ColorTransfer = smpte2084;
ColorPrimaries = bt2020;

Looks good. Thanks.
Douglas Lise
CC BY-SA 4.0
2019-10-21T13:47:52.640Z
2019-10-21T13:47:52.640Z
Fmstrat
<p>I need to validate if a video file (HEVC encoded) is or is not an HDR video. I know that there are many HDR standards, but I did not find a way to identify it using <code>mediainfo</code> or <code>ffprobe</code>.</p>

<p>The need is because I have an API that receives several video profiles (different bitrates, dimensions and codecs) for a single video, which are used to deliver to users the best match based on their devices and connection speed. So now I want to allow them to select HDR profile but to achieve this I need first to validate the ingest files.</p>

<p>Do you know how to handle this?</p>

<ffmpeg><hdr>
How to identify HDR video?
Douglas Lise
# How to identify HDR video?

(Asked by: username_0 on 2017-08-08)

I need to validate if a video file (HEVC encoded) is or is not an HDR video. I know that there are many HDR standards, but I did not find a way to identify it using `mediainfo` or `ffprobe`.

The need is because I have an API that receives several video profiles (different bitrates, dimensions and codecs) for a single video, which are used to deliver to users the best match based on their devices and connection speed. So now I want to allow them to select HDR profile but to achieve this I need first to validate the ingest files.

Do you know how to handle this?

**Tags:** ffmpeg, hdr


---

## 5 answers

### Answer by username_7 on 2019-10-21. Score: 9 | Accepted answer

Assuming your file is ${F}, the below is an efficient means I have been able to create:
COLORS=$(ffprobe -show_streams -v error "${F}" |egrep "^color_transfer|^color_space=|^color_primaries=" |head -3)
for C in $COLORS; do
        if [[ "$C" = "color_space="* ]]; then
                COLORSPACE=${C##*=}
        elif [[ "$C" = "color_transfer="* ]]; then
                COLORTRANSFER=${C##*=}
        elif [[ "$C" = "color_primaries="* ]]; then
                COLORPRIMARIES=${C##*=}
        fi      
done    
if [ "${COLORSPACE}" = "bt2020nc" ] && [ "${COLORTRANSFER}" = "smpte2084" ] && [ "${COLORPRIMARIES}" = "bt2020" ]; then 
        echo ${F}
fi

I use this inside a looping function to know when to use https://github.com/username_7/ffmkv to create an SDR version of a video on one of the presets.

> **Comments:**
> **username_7**: Note, this defaults to the top video stream. I use `-select_stream` when I need to be specific. And you'll want to reset the variables in a loop.  
> **username_0**: So you assume that these parameters must be satisfied:  ColorSpace = bt2020nc; ColorTransfer = smpte2084; ColorPrimaries = bt2020;  Looks good. Thanks.  

---

### Answer by username_1 on 2021-05-15. Score: 8

Well, and yeah, all answers are wrong here. HDR is only the new transfer function, PQ or HLG. So that means you need to look into that, PQ is SMPTE 2084 and HLG is ARIB STD-B67.

Yes, 8 bit file tagged as PQ will be played as HDR.

Yes, 10 bit files tagged as BT.2020 transfer are SDR, because BT.2020 transfer is the same as BT.709 and BT.601. Moreover Rec. BT.2020 is SDR only spec., HDR was defined in BT.2100. Master files of Hollywood used 10 bit in SDR for a long time.

Yes, you need to color manage BT.2020 primaries to your primaries. Just as before PAL primaries were supposed to be color managed to what display primaries are.

Yes, it is 0.0001 to 10000 nits, not 0.001 to 4000 in PQ. Yes, 65 Y' is actually 0.00005 nits and 64 Y' is 0.000000 nits. Black body.

Yes, BT.2390 EETF dynamical tone mapper is mandatory unless the master display is full 10000 nits.

Yes, almost all movies are inside P3-D65 inside BT.2020, only Planet Earth 2 and Matrix are not and some others. That changed in 2022, since Netflix allowed to use BT.2020 primaries for their JPEG2000 masters.

Yes, film cameras supported HDR back in 1970s and they are nowadays converted to PQ and image format .pcd (Photo CD) supported HDR and WCG.

> **Comments:**
> **username_2**: thanks for this helpful answer - but what does this mean in practical terms? how should we check for HDR with ffmpeg?  
> **username_1**: ffprobe file, look for smpte2086 or arib transfer.  
> **username_2**: color_space=bt2020nc ... color_transfer=arib-std-b67 ... color_primaries=bt2020 ... this is what I have ... IF color_primaries === 'bt2020' && (color_transfer.startsWith('arib') || color_transfer.startsWith('smpte')) ... does this check sound correct? the other guys refer to smpte2084 not smpte2086 which is why I used startsWith  
> **username_1**: smpte 2084, yes, a typo. No, primaries are not required.  
> **username_2**: many thanks much appreciated  
> **username_3**: I have an HLG HDR video, and I can't figure out how to identify it in MediaInfo. Looks like a regular file; not a special HDR one. It definitely plays back in HDR. What's the trick?  
> **username_1**: @KevinGhadyani What does Mediainfo say for transfer function?  
> **username_3**: I'm not seeing anything called "transfer function". But as an update, that file was mislabeled I'm thinking. My TV didn't go into HLG mode when playing it on my SHIELD. I downloaded an HLG file from YouTube, and "transfer characteristics" properly shows HLG. I wonder if that other video was mislabeled: https://4kmedia.org/lg-cymatic-jazz-hdr-hlg-uhd-4k-demo/  
> **username_1**: @KevinGhadyani The MPEG-TS file from 4kmedia is labeled Transfer characteristics    : HLG / BT.2020 (10-bit), so it is indeed HLG. So?  
> **username_3**: It is. When using MKVToolNix, it removed it. It all makes sense now.  

---

### Answer by username_2 on 2022-01-04. Score: 7

This answer relies on but simplifies the answer by username_1 who seems to know his stuff.
ffprobe -v quiet -show_streams -select_streams v:0 video.mp4 | grep ^color_transfer=

IF color_transfer EQUALS arib-std-b67 OR smpte2084 THEN the video is HDR

> **Comments:**
> **username_4**: Thanks, this answer helped me most. Is there a way to do a grep where it just shows a result when we have arib-std-b67 OR smpte2084, and not output anything when that is NOT the case? I want to use this in a batch file for a lot of movies at once.  
> **username_1**: Indeed, correct.  

---

### Answer by username_0 on 2017-12-14. Score: 5

I've found how to get this information from color primaries attribute. Considering color primaries BT.2020 as a HDR video.
mediainfo video.mp4 --Inform="Video;%colour_primaries%"

In this example above, if the return of the command is BT.2020 so I consider the video as HDR. 
Otherwise SDR.

> **Comments:**
> **username_5**: Technically, that will only determine if a video is WCG.  To test for HDR-ness, you also need to check that the transfer function is one of the HDR flavors.  
> **username_0**: Nice to know @JasonConrad . So could I consider PQ and HLG as valid transfer functions for and HDR video?  
> **username_5**: Yes. I *think* that the color space, transfer function, and bit depth (HDR also needs to be 10 bits per channel) are enough to minimally qualify video as HDR, but there are different flavors and specifications.  

---

### Answer by username_6 on 2020-12-06. Score: 2

Checking color_primaries is the right approach. I use ffprobe to get the JSON output. Then you can parse the JSON output instead of searching for a string in the normal output.
$ ffprobe -v error -show_streams -select_streams v:0 -of json -i test.mp4
{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "color_transfer": "arib-std-b67",
            "color_primaries": "bt2020",
            "refs": 1,
            // …
       }
    ]
}


---

