how to detect video file HDR or SDR?

how to detect video file HDR or SDR?

High-dynamic-range (HDR) is a technology for the way luminance and colors are represented in videos and images. It is contrasted with standard-dynamic-range (SDR), which has become the term for older technology.[1] HDR offers the possibility to represent substantially brighter highlights, darker shadows, more details in both sides, and more colorful colors than what was previously possible.[1][2]

HDR enables better use of displays that have high brightnesscontrast, and color capabilities. It does not increase the display’s capabilities and not all HDR displays have the same capabilities. HDR content will thus look different depending on the display used.[3]

HDR10HDR10+Dolby Vision, and HLG are common HDR formats.[4]

The HDR technology related to displays came about in 2014.[5]

ffprobe -show_streams -v error filename.mkv

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

The important bits that state it's HDR are these 3:

color_space=bt2020nc
color_transfer=smpte2084
color_primaries=bt2020

https://video.stackexchange.com/questions/22059/how-to-identify-hdr-video

https://stackoverflow.com/questions/52897028/ffmpeg-hdr-to-sdr-unable-to-find-a-suitable-output-format-for-format-gbrpf3

Add tonemapping filter to convert HDR10 content to SDR
https://github.com/jellyfin/jellyfin/issues/415

The second

# 第二种

mediainfo video.mp4 --Inform="Video;%colour_primaries%"

BT.2020

ffprobe -v error -show_streams -select_streams v:0 -of json -i test.mp4

## Command for detecting colour primaries of input file 
mediainfo "FILENAME" --Inform="Video;%colour_primaries%"


cd /home/wwwroot/dev/public/queued
for V in *.*;do
#echo -e $(mediainfo $V --Inform="Video;%colour_space%")
#echo -e $(mediainfo $V --Inform="Video;%colour_transfer%")
#echo -e $(mediainfo $V --Inform="Video;%colour_primaries%")
DUR=$(ffmpeg -i $V 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p")
FPS1=$(ffprobe -v 0 -of csv=p=0 -select_streams V:0 -show_entries stream=r_frame_rate $V)
FPS2=$(ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=nw=1:nk=1 "$V")
FPS3=$(mediainfo $V --Inform="Video;%FrameRate%")
echo -e "$V" "$FPS1" "$FPS2" "$FPS3"
done

mediainfo -i /home/wwwroot/dev/public/queued/30.tmp

Leave a Reply

Your email address will not be published. Required fields are marked *