Android MediaCodec usage for decoding MPEG2 video

2020-06-23 07:44发布

问题:

I am trying to use MediaCodec API to decode and display an MPEG2 encoded stream. I use MediaExtractor to extract the stream from an MPEG Transport Stream (TS).

I notice that configure() of the decoder is failing on all devices that I have tried - Nexus7(2012), Nexus7(2013), Nexus10, with error code 0x80001001.

The only parameter that can go wrong in using the configure() API is the MediaFormat configuration provided and this is obtained from the Android MediaExtractor. I do not understand what could be going wrong resulting in this issue getting noticed.

The configuration parameters present in the MediaFormat object are:

            1. `CSD-0` - Containing Sequence header and sequence extension header.

                            Seq_Hdr    - 00 00 01 B3 2D 01 E0 24 09 C4 23 80 

                            Seq_extnsn - 00 00 01 B5 14 8A 00 01 00 80

            2. Height - 480

            3. Width - 720

            4. KEY_MIME - `video/mpeg2`

The error is somewhat similar on all devices, which might mean that the error is perhaps originating from a common entity in the MediaCodec stack. Here is the error from Nexus7 (2013). (0x80001001 – OMX_ErrorUndefined)

E/ACodec  ( 6504): [OMX.qcom.video.decoder.mpeg2] configureCodec returning error -1010
E/MediaCodec( 6504): Codec reported an error. (omx error 0x80001001, internalError -1010)

Is this behavior because MPEG2 is not a mandatory codec to be supported on Android platforms or am I doing something wrong? Any information on the behavior of MPEG2 decoder will be greatly appreciated.

回答1:

On your device, look at /system/etc/media_codecs.xml to see the list.

My understanding is that, on current Nexus devices, MPEG-2 video compression is not supported.