How to decode MP3 in Android within app?

ⅰ亾dé卋堺 提交于 2019-12-29 06:55:41

问题


I'm currently working on an app that lets the user choose an MP3 audio file. The file is then processed by my app.

For this processing, the application would need to decode audio files to get the raw PCM output.

To decode MP3, I have two options:

  1. Use the Android system to decode MP3 and get the PCM data.
  2. Decode the MP3 myself on the phone, WITHOUT paying MP3 licensing fees.

My question is whether #1 is technically possible? And for #2, whether the MP3 license on the phone covers an app as well?


回答1:


To my knowledge, there is no Android-provided way to decode MP3s.

I've used JLayer in the past, and can recommend it for MP3 processing. Using the NDK with a c++ library might be faster, but if you're looking to keep it Java, that's what I'd use. It's still faster than real-time, roughly 30 seconds to decode all frames in an average bitrate 3 minute MP3. That's with an Galaxy S(1GHz), so any newer phones are faster.

As far as licensing goes, I can't help you there. JLayer itself is LGPL, but the world of MP3 licensing is murkier than used motor oil. After a few days of searching for a concrete answer, I just gave up and did it. The world at large seems divided on who even holds the license in the first place.




回答2:


the Android system can decode mp3 file now, see here it describes the media codec, container, and network protocol support provided by the Android platform.

The MedieCodec is a very powful framework to encode and decode media file.




回答3:


Option 1 is definitely not possible (unless you want to target ICS+ devices and are willing to write native C code to decode MP3s with OpenSL). Geobits recommendation of jLayer is a good one. For the most part, dealing with jLayer is a breeze. Here's a good blog post that will help: http://mindtherobot.com/blog/624/android-audio-play-an-mp3-file-on-an-audiotrack/



来源:https://stackoverflow.com/questions/11191246/how-to-decode-mp3-in-android-within-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!