mediacodec的bug

摄像头在onPreviewFrame输出的YUV帧格式,如果没有配置任何参数的情况下,基本上都是NV21格式,但Google对MediaCodec的API在设计和规范的时候,显得很不厚道,过于贴近Android的HAL层了,导致了NV21格式并不是所有机器的MediaCodec都支持这种格式作为编码器的输入格式!


因此,在初始化MediaCodec的时候,我们需要通过codecInfo.getCapabilitiesForType来查询机器上的MediaCodec实现具体支持哪些YUV格式作为输入格式,一般来说,起码在4.4+的系统上,这两种格式在大部分机器都有支持:



两种格式分别是YUV420P和NV21,如果机器上只支持YUV420P格式的情况下,则需要先将摄像头输出的NV21格式先转换成YUV420P,才能送入编码器进行编码,否则最终出来的视频就会花屏,或者颜色出现错乱

发布了331 篇原创文章 · 获赞 85 · 访问量 47万+
展开阅读全文

视频编码花屏问题求助

03-31

各位大侠你们好, 小弟在使用华为P8ALE-UL00进行H264编码的时候,录像文件出现花屏,再现率非常高。 系统打印打印了如下错误,有遇到过的么?求指教。(在其它的手机上暂时没有发现类似问题) 03-15 10:56:50.720 I/OMXClient(17516): Using client-side OMX mux. 03-15 10:56:50.720 I/MediaCodecList( 2975): findCodecByType::numCodecs=35, index=0, type=video/avc 03-15 10:56:50.720 I/OMXCodec(17516): matching ´OMX.IMG.TOPAZ.VIDEO.Encoder´ quirks 0x00000000 03-15 10:56:50.720 I/MediaCodecList( 2975): findCodecByType::numCodecs=35, index=15, type=video/avc 03-15 10:56:50.720 I/OMXCodec(17516): matching ´OMX.google.h264.encoder´ quirks 0x00000000 03-15 10:56:50.720 I/MediaCodecList( 2975): findCodecByType::numCodecs=35, index=33, type=video/avc 03-15 10:56:50.730 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000001 = 2130706433 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000005 = 2130706437 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000002 = 2130706434 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000006 = 2130706438 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x17 = 23 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x18 = 24 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000011 = 2130706449 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x16 = 22 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000007 = 2130706439 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000008 = 2130706440 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x19 = 25 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x1a = 26 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x1b = 27 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x1c = 28 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000003 = 2130706435 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000009 = 2130706441 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f00000c = 2130706444 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000012 = 2130706450 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f00000a = 2130706442 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f00000b = 2130706443 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000789 = 2130708361 03-15 10:56:50.740 I/ACodec (17516): setupVideoEncoder succeeded 03-15 10:56:50.740 E/IMGTOPAZ( 2975): Error in OTE_Base_GetParameter at line 1321 03-15 10:56:50.740 E/OMXNodeInstance( 2975): getParameter(2130706443) ERROR: 0x8000100e 03-15 10:56:50.740 W/ACodec (17516): do not know color format 0x7f000789 = 2130708361 以下是相关代码: MediaFormat format = MediaFormat.createVideoFormat("video/avc", width, height); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); format.setInteger(MediaFormat.KEY_BIT_RATE, 4000000); format.setInteger(MediaFormat.KEY_FRAME_RATE, 15); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1); mEncoder = MediaCodec.createEncoderByType("video/avc"); mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); mInputSurface = mEncoder.createInputSurface(); mEncoder.start(); 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览