question

Stephen H Gerstacker avatar image
Stephen H Gerstacker asked

Using MediaCodec for H.264 decoding on FireTV

I'm having issues configuring MediaCodec to do H.264 decoding on the FireTV. I'm using a standard setup that works on all other Android devices. The set up code is: mFormat = MediaFormat.createVideoFormat(MIMETYPE, outputWidth, outputHeight); mFormat.setString(MediaFormat.KEY_MIME, MIMETYPE); mFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0); ByteBuffer buffer = ByteBuffer.allocateDirect(annexBData.length + 20); buffer.put(annexBData); buffer.limit(annexBData.length); mFormat.setByteBuffer("csd-0", buffer); String avcName = getAVCName(); mDecoder = MediaCodec.createByCodecName(avcName); try { mDecoder.configure(mFormat, surface, null, 0); } catch (Exception e) { Log.e(TAG, "CONFIGURE EXCEPTION: " + e); e.printStackTrace(); } mDecoder.setVideoScalingMode(MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); try { mDecoder.start(); } catch (Exception e) { Log.e(TAG, "START EXCEPTION: " + e); e.printStackTrace(); } getAVCName is returning OMX.qcom.video.decoder.avc A java.lang.IllegalStateException always occurs on start. The only other relevant information comes from logcat. I see the following: E/MediaCodec( 3284): @@@@@@ MediaCodec Start @@@@@@ V/ACodec ( 3284): onStart V/ACodec ( 3284): [OMX.qcom.video.decoder.avc] Now Loaded->Idle V/ACodec ( 3284): [OMX.qcom.video.decoder.avc] Allocating 2 buffers of size 2097088 on input port I/Kernel ( 346): <6>[91350.710327] msm_vidc_dec: Inside vid_dec_open() V/ACodec ( 3284): [OMX.qcom.video.decoder.avc] Allocating 21 buffers from a native window of size 3137536 on output port E/OMX-VDEC-1080P( 328): E/OMX-VDEC-1080P( 328): Set output buffer failed E/OMXNodeInstance( 328): OMX_UseBuffer failed with error -2147479552 (0x80001000) E/ACodec ( 3284): registering GraphicBuffer 0 with OMX IL component failed: -2147483648 V/ACodec ( 3284): [OMX.qcom.video.decoder.avc] Calling cancelBuffer on buffer 0x5ad07ee8 E/ACodec ( 3284): Failed to allocate buffers after transitioning to IDLE state (error 0x80000000) V/ACodec ( 3284): [OMX.qcom.video.decoder.avc] Now Loaded V/MediaCodec( 3284): input buffers allocated E/MediaCodec( 3284): Codec reported an error. (omx error 0x80001001, internalError -2147483648)
fire tv
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Ross@Amazon avatar image
Ross@Amazon answered
Please refer to Google's exoplayer for the usage of MediaCodec APIs to configure H.264 decoder. ExoPlayer works well on Fire TV. https://github.com/google/ExoPlayer
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.