MediaCodec:native_window_api_connect返回错误:没有这样的设备(-19)

时间:2018-01-13 08:58:08

标签: android h.264 mediacodec

当我使用MediaCodec时,发生了崩溃。 堆栈跟踪:

  

I / VideoHW / VideoDecoder:createVideoDecoder       I / ACodec:[]现在未初始化       I / ACodec:[] onAllocateComponent       I / OMXClient:MuxOMX ctor       I / ACodec:为aacProfile设置Google AAC Dec 0       I / ACodec:[OMX.qcom.video.decoder.avc]现已加载       E / BufferQueueProducer:[SurfaceTexture-0-11590-3] conn       E / MediaCodec:native_window_api_connect返回了一个呃       E / MediaCodec:配置失败,错误为0xffffffed,re       I / ACodec:[OMX.qcom.video.decoder.avc]现在uninitiali       I / ACodec:[]现在是kWhatShutdownCompleted事件:8362       I / MediaCodec:编解码器关闭完成       I / ACodec:[]现在未初始化       I / ACodec:[] onAllocateComponent       I / OMXClient:MuxOMX ctor       I / ACodec:为aacProfile设置Google AAC Dec 0       W / Activity:AppLock checkAppLockState已锁定:false ver       ALSE       D / SVPlayerView:onSurfaceTextureAvailable宽度1080小时       I / KugouPlayer / JNI:++++++结束通话       I / ACodec:[OMX.qcom.video.decoder.avc]现已加载       D / siganid:崩溃了       D / siganid:isForeProcess:true       android.media.MediaCodec $ CodecException:Error 0xffffffed>在android.media.MediaCodec.native_configure(原生方法)
      在android.media.MediaCodec.configure(MediaCodec.java:1882)

public boolean createVideoDecoder(Object surface,int width, int height, byte[] sps, byte[] pps) {
        Log.i(TAG,"createVideoDecoder");
        mFormat = new MediaFormat();
        mFormat.setString(MediaFormat.KEY_MIME, "video/avc");
        mFormat.setInteger(MediaFormat.KEY_WIDTH, width);
        mFormat.setInteger(MediaFormat.KEY_HEIGHT, height);
        byte[] head = { 0, 0, 0, 1 };
        ByteBuffer bSPS = ByteBuffer.allocate(sps.length + head.length);
        ByteBuffer bPPS = ByteBuffer.allocate(pps.length + head.length);
        bSPS.put(head);
        bSPS.put(sps);
        bSPS.flip();
        bPPS.put(head);
        bPPS.put(pps);
        bPPS.flip();
        mFormat.setByteBuffer("csd-0", bSPS);
        mFormat.setByteBuffer("csd-1", bPPS);

        mFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
        try {
            mCodec = MediaCodec.createDecoderByType("video/avc");
            if (mCodec == null) {
                return false;
            }
            mCodec.configure(mFormat, (Surface) surface, null, 0);
            mCodec.start();
            info = new BufferInfo();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }
        return true;
    }

0 个答案:

没有答案