Not able to use H264 (video/avc) Encoder on Intel x86 device, Android 4.2.2

android, android-mediacodec, intel, x86

Solution

Found the fix for the issue. I did not release the Codec before creating another one. Multiple instances of Encoder is not permissible on Samsung Tab 3 running on Intel x86 device. This behaviour is pretty inconsistent across android devices; taking into account other devices on which I've had tested my code.

Problem

I intend to encode raw YUV Data to H264 data for which I'm using Android's MediaCodec interface. Below is the snippet I have in place for the same: ``` MediaCodec mEncoder = MediaCodec.createEncoderByType("video/avc"); MediaFormat mVideoFormat = MediaFormat.createVideoFormat("video/avc", 640 , 480); mVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, CodecCapabilities.COLOR_FormatYUV420SemiPlanar); mVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, 64000); mVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 24); mVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5); mVideoFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline); mEncoder.configure(mVideoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); mEncoder.start(); ByteBuffer[] mInputVideoBuffers = mEncoder.getInputBuffers(); ByteBuffer[] mOutputVideoBuffers = mEncoder.getOutputBuffers(); ``` Although it works well on ARM devices, it fails on Intel x86 device I have (Samsung Tab 3) with below message: E/ACodec(21756): [OMX.Intel.VideoEncoder.AVC] ERROR(0x80001001) E/MediaCodec(21756): Codec reported an error. (omx error 0x80001001, internalError -2147483648) Any help on this would be useful.

Original source