ACodec configureCodec返回错误-38

问题描述 投票:0回答:1

我正在尝试使用MediaCodec为mime = video / avc,width = 1920,height = 1080配置视频编码器。不幸的是,设备抱怨以下日志:

12-20 13:11:49.410 5781-5817/ I/OMXClient: Treble IOmx obtained
12-20 13:11:49.423 5781-5817/ E/ACodec: [OMX.google.h264.encoder] configureCodec returning error -38
12-20 13:11:49.424 5781-5817/ E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
12-20 13:11:49.424 5781-5816/ E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3
12-20 13:11:49.425 5781-5801/ E/MediaCodec: configure failed with err 0x80001001, resetting...
12-20 13:11:49.433 5781-5817/com.humaneyes.filesave I/OMXClient: Treble IOmx obtained
android mediacodec
1个回答
0
投票

有些编解码器很挑剔,需要特殊的属性。

未能指定其中一些可能导致MediaCodec configure()调用抛出无用的异常。

必须至少在MediaFormat中定义以下整数属性:

  • MediaFormat.KEY_BIT_RATE
  • MediaFormat.KEY_FRAME_RATE
  • MediaFormat.KEY_I_FRAME_INTERVAL
  • MediaFormat.KEY_COLOR_FORMAT

例如:

MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/avc", 1920, 1080);
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, 2000000);
mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
© www.soinside.com 2019 - 2024. All rights reserved.