Does ML2 support hardware h.264 decoding through the MediaCodec API?


I'm decoding h264 streams from the user's desktop using FFMPEG/libavcodec, which currently does it on the CPU. I see the custom H264 decoding in the docs for ml_media_decoder, but I'm wondering if ML2 supports Android's MediaCodec (which I would be able to access through libavcodec). Or if there's a way I can just swap out avcodec_send_packet & avcodec_receive_frame for something in the ML2 API.


For anyone wondering, here's what I found using the isHardwareAccelerated method of MediaCodec :slight_smile:

Hi @hollowaya, thank you for your message. Magic Leap 2 does support HW H264 decoding, it is listed above as OMX.mesa.video_decoder.avc and it should be available and functional through standard AOSP interfaces also using the mime type video/avc when creating the decoder. Also, the Magic Leap 2 API can also use it.

When you mean through AOSP interfaces, do you mean the AMediaCodec?
if so, I would appreciate if there were examples on how to use it to decode h264 frames.

Yes, AMediaCodec_createDecoderByType("video/avc"); should create the HW h264 decoder, i.e. OMX.mesa.video_decoder.avc

From this, any decoding example using the Android NDK should be fine (for example AImageReader is a possible mechanism to handle decoded buffers).

See also the example code here: android ndk - Fetch raw data from an Image acquired from an AImageReader - Stack Overflow