Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode MP3 in Android within app?

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?

like image 454
Samuel Neugber Avatar asked Jun 25 '12 14:06

Samuel Neugber


People also ask

How do I decode an MP3 file?

Unless you have weeks (months?) available to play with it, I would recommend using an existing MP3 decoding library to pull the decoded audio out of the file. In C/C++, there's libMAD or libmpg123, as well as the Windows components. In C#, you can use NAudio or NLayer.

Where are MP3 stored on Android?

With 15 GB of free storage, Google Drive offers the easiest method for you to keep your music collection synced across all of your devices, including Android and PC. The Google Drive app for Android doesn't allow you to download entire folders directly to your Android device.


1 Answers

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.

like image 84
Geobits Avatar answered Sep 20 '22 15:09

Geobits