1

I would like to decode an audio MP3 file with Android's MediaCodec without using MediaExtractor. This post does a similar thing with video. Can I get individual audio frames in a similar way to getFramesFromData in the post.

Thanks for any help.

Community
  • 1
  • 1
Ratna Beresford
  • 357
  • 2
  • 6
  • May I ask why you're avoiding `MediaExtractor`? FWIW, there are a number of examples of `MediaCodec` usage at http://bigflake.com/mediacodec/, but they are predominantly video (`EncoderTest` and `DecoderTest` being the exceptions). – fadden Mar 18 '14 at 17:46
  • @fadden - Thank you very much for your reply. I need to decode a bitstream downloaded from network at some point. MediaExtractor doesn't take in a bitstream as far as I can see. I have looked at the mediacodec examples but it seems to me that the post I have referenced in the question is closer to what I need. I would just like to know if I can get frames of audio in the same way as getFramesFromData. Thanks for any help. – Ratna Beresford Mar 19 '14 at 13:06
  • Have you tried actually using MediaExtractor? It does take http URLs as a data source, so if you're simply trying to stream an mp3 file over http, that should work fine. If you still really want to bypass MediaExtractor, it's not that hard to parse an mp3 stream yourself. You just need to look for the sync markers to determine where the mp3 packet boundaries are, and then hand the mp3 packets to the decoder one at a time. – marcone Mar 19 '14 at 14:42
  • The audio stream will be created live, so I won't be able to use URL. I will try to look for info on how to look for sync markers. – Ratna Beresford Mar 19 '14 at 16:05
  • Regarding MediaExtractor, it seems that this class' creation of buffer sizes possibly is too small for the case of doing URL streaming, creating unbearable glitches in the audio if the wireless context (Wlan of 3g/4g) shows incapacity for delivering a continuous stream. LG G3 unit is testbed. Thus, it would be a VERY good thing if MediaExtractor would accept a BitStream as input, instead of an URL string. That would enable proper bufferhandling in this case. I hope I have misunderstood the api! – carl Apr 28 '15 at 20:07

0 Answers0