部分华为手机解h265绿屏问题。

前言

华为荣耀某型号手机解h265绿屏,无法解码。

华为手机内置两个解码库,一个自己的,一个OMX.google.hevc.decoder
自己的解码绿屏
使用google的没问题,使用type方式创建解码库会优先走他自己的
so解决办法如下

				String type = MediaFormat.MIMETYPE_VIDEO_HEVC;
                mFormat = MediaFormat.createVideoFormat(type, width, height);
                if(!TextUtils.isEmpty(Build.MANUFACTURER) && Build.MANUFACTURER.toUpperCase().contains("HUAWEI") && DecoderUtils.isSupportGoogleH265()) {
                    //华为手机强制走google解码
                    LogUtil.e(TAG,"华为手机强制走google解码");
                    mCodec = MediaCodec.createByCodecName("OMX.google.hevc.decoder");
                }else {
                    mCodec = MediaCodec.createDecoderByType(type);
                }

DecodeUtils

    public static boolean isSupportGoogleH265(){

        int count = MediaCodecList.getCodecCount();
        for(int i=0;i<count;i++){
            MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
            String name = info.getName();
            if(name.toLowerCase().equals("omx.google.hevc.decoder")){
                return true;
            }
        }
        return false;
    }

问题解决。

猜你喜欢

转载自blog.csdn.net/a940659387/article/details/104975877