2013-07-24 42 views
5

我想使用MediaCodec将Surface编码为H.264。MediaCodec createInputSurface

使用API​​ 18,可以通过调用createInputSurface()并在该表面上绘图来从表面编码。

我在createInputSurface()上得到一个IllegalStateException。这里是额外的logcat输出:

D/H264Encoder(17570): MediaFormat: {frame-rate=25, bitrate=1000000, height=600, mime=video/avc, color-format=19, i-frame-interval=75, width=800} 
D/NvOsDebugPrintf( 125): NvMMLiteOpen : Block : BlockType = 4 
D/NvOsDebugPrintf( 125): NvRmPowerModuleClockControl on MOD[29] INST[0] 
D/NvOsDebugPrintf( 125): NvRmModuleResetWithHold deassert MOD[29] INST[0] 
D/NvOsDebugPrintf( 125): NvMMLiteBlockCreate : Block : BlockType = 4 
I/ACodec (17570): setupVideoEncoder succeeded 
E/OMXNodeInstance( 125): OMX_EnableAndroidNativeBuffers failed with error -2147479547 (0x80001005) 
E/OMXNodeInstance( 125): createInputSurface requires AndroidOpaque color format 
E/ACodec (17570): [OMX.Nvidia.h264.encoder] onCreateInputSurface returning error -38 
W/MediaCodec(17570): createInputSurface failed, err=-38 

任何有关如何新的api的作品会有所帮助。

回答

5

重要错误消息是这样的:

createInputSurface requires AndroidOpaque color format 

对于表面输入,必须设置颜色格式COLOR_FormatSurface(也称为AndroidOpaque。)

见的例子here,特别是EncodeAndMuxTest。

+0

非常感谢帮助!我认为它与此有关,但在AndroidOpaque上找不到任何东西 – Broatian