@RequiresApi(api = Build.VERSION_CODES.R)
public static boolean isHDR(MediaMetadataRetriever mediaMetadataRetriever)
throws NumberFormatException {
String colorTransferString =
mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COLOR_TRANSFER);
Log.e("isHDR",colorTransferString);
String colorStandardString =
mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COLOR_STANDARD);
Log.e("isHDR",colorStandardString);
int colorTransfer = Integer.parseInt(colorTransferString);
int colorStandard = Integer.parseInt(colorStandardString);
// This check needs to match the isHDR check in
// frameworks/av/media/libstagefright/FrameDecoder.cpp.
return (colorTransfer == MediaFormat.COLOR_TRANSFER_HLG
|| colorTransfer == MediaFormat.COLOR_TRANSFER_ST2084)
&& colorStandard == MediaFormat.COLOR_STANDARD_BT2020;
}
视频是HDR格式并且系统是API30及以上才能返回true