使用MediaCodec将摄像头采集的视频编码为h264的问题

参考https://www.cnblogs.com/CoderTian/p/6224605.html案例时所遇到问题,记录一下:
错误日志
2019-09-11 15:18:59.791 6287-6329/com.hkst.testmuxer E/ACodec: [OMX.MTK.VIDEO.ENCODER.AVC] does not support color format 15 2019-09-11 15:18:59.791 6287-6329/com.hkst.testmuxer E/ACodec: [OMX.MTK.VIDEO.ENCODER.AVC] configureCodec returning error 80000000 2019-09-11 15:18:59.791 6287-6329/com.hkst.testmuxer E/ACodec: signalError(omxError 0x80001001, internalError -2147483648) 2019-09-11 15:18:59.791 6287-6328/com.hkst.testmuxer E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3 2019-09-11 15:18:59.791 6287-6287/com.hkst.testmuxer E/MediaCodec: configure failed with err 0x80001001, resetting... 2019-09-11 15:18:59.825 6287-6287/com.hkst.testmuxer E/AndroidRuntime: FATAL EXCEPTION: main Process: com.hkst.testmuxer, PID: 6287 android.media.MediaCodec$CodecException: Error 0x80001001 at android.media.MediaCodec.native_configure(Native Method) at android.media.MediaCodec.configure(MediaCodec.java:1895) at com.hkst.testmuxer.AvcEncoder.(AvcEncoder.java:48) at com.hkst.testmuxer.MainActivity.surfaceCreated(MainActivity.java:56) at android.view.SurfaceView.updateWindow(SurfaceView.java:709) at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:180) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2553) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1462) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6965) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:907) at android.view.Choreographer.doCallbacks(Choreographer.java:709) at android.view.Choreographer.doFrame(Choreographer.java:644) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:893) at android.os.Handler.handleCallback(Handler.java:836) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6251) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
提示不支持 color format 15
将:
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
的MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar更改为 MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar
或者使用format = getSupportColorFormat()获取支持的格式。

你可能感兴趣的:(Android)