Is there a way to detect if Exoplayer is currently playing a video with HDR?

966 Views Asked by At

I am using Exoplayer with SurfaceView and I am displaying diagnostic overlay (TextViews) to check the video/app properties.

I was wondering if there is a way to get the information about the HDR state of the currently played video stream.

I can get the HDR info about a display and a codec - they both support HDR - but I cannot find a way to tell if the stream is in HDR or not.

I have looked into the video formats from DashManifest to check the color info for BT.2020 color space but they are all null.

Any help will be appreciated.

1

There are 1 best solutions below

2
Mick On

The HDR information, or metadata, will be in the media stream rather than the DASH manifests.

Different containers will carry the container level metadata differently, so you can look at the VP9 and the MP4 ExoPLayer extractors to see how they parse and extract the data.

You can see more info on this in the online ExoPlayer/Android documentation (https://source.android.com/docs/core/display/hdr):

HDR10 bitstreams are packaged in MP4 containers. Applications use a regular MP4 extractor to extract the frame data and send it to the decoder.

MPEG4 Extractor

HDR10 bitstreams are recognized as just a normal HEVC stream by a MPEG4Extractor and the HDR track with the type "video/HEVC" will be extracted. The framework picks an HEVC video decoder that supports the Main10HDR10 profile to decode that track.

HEVC Decoder

HDR information is in either SEI or SPS. The HEVC decoder first receives frames that contain the HDR information. The decoder then extracts the HDR information and notifies the application that it is decoding an HDR video. HDR information is bundled into decoder output format, which is propagated to the surface later.

You can look at the actual parsing in the ExoPlayer source code also - look at 'AtomParsers.java' in the mp4 extractors. You could add some hooks here but I suspect this may be more low level than you want to go, as I think you are simply interested in an easy way to detect if the stream is HDR so you can display this on your overlay.

You could also use ffmpeg/ffprobe to detect if the stream is HDR, or more precisely if the metadata says it is, (see https://video.stackexchange.com/a/34827 for example) but this will not necessarily tell you if ExoPlayer has also detected it is HDR.