MediaCodec createInputSurface

做~自己de王妃 提交于 2020-01-02 02:02:13

问题


I want to use MediaCodec to encode a Surface into H.264.

With API 18, there is a way to encode content from a surface by calling createInputSurface() and then drawing on that surface.

I get IllegalStateException on createInputSurface(). Here's additional logcat output:

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

Any insight on how the new API works would be helpful.


回答1:


The important error message is this:

createInputSurface requires AndroidOpaque color format

For Surface input, you must set the color format to COLOR_FormatSurface (also known as AndroidOpaque.)

See examples here, notably EncodeAndMuxTest.



来源:https://stackoverflow.com/questions/17845859/mediacodec-createinputsurface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!