Pnemonic
Pnemonic

Reputation: 1825

ACodec configureCodec returning error -38

I am trying to configure a video encoder using MediaCodec for mime=video/avc, width=1920, height=1080. Unfortunately the device complains with the following log:

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

Upvotes: 2

Views: 2591

Answers (1)

Pnemonic
Pnemonic

Reputation: 1825

Some codecs are finicky and require special properties.

Failing to specify some of these can cause the MediaCodec configure() call to throw an unhelpful exception.

Must define the following integer properties in the MediaFormat at a minimum:

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

For example:

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);

Upvotes: 1

Related Questions