【问题标题】:MediaCodec createInputSurfaceMediaCodec createInputSurface
【发布时间】:2013-07-24 15:04:49
【问题描述】:

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

使用 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 工作原理的见解都会有所帮助。

【问题讨论】:

    标签: android surfaceview h.264 android-mediacodec


    【解决方案1】:

    重要的错误信息是这样的:

    createInputSurface requires AndroidOpaque color format
    

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

    查看示例 here,尤其是 EncodeAndMuxTest。

    【讨论】:

    • 感谢您的帮助!我认为这与此有关,但在 AndroidOpaque 上找不到任何东西
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-11
    • 1970-01-01
    相关资源
    最近更新 更多