Johann
Johann

Reputation: 29867

Decode AMR audio file in Android

Is there a way to decode an AMR audio file in Android and have access to the raw audio data? MediaCodec is only available for API 16 and above. I need something that will work on Android 2.2 and above.

Upvotes: 1

Views: 1646

Answers (1)

fardjad
fardjad

Reputation: 20404

I think there's no native API in 2.X platforms for doing this. You can use ffmpeg binaries in your application instead.

With a quick search I found this precompiled version of ffmpeg for Android 2.2.

You can place the executable it in your application raw resources folder and use Runtime.getRuntime().exec() to execute it.

To convert an AMR file to WAV with ffmpeg you can do something like this:

ffmpeg -i file.amr file.wav

and to convert a wav to raw PCM you can do the following: (taken from here)

ffmpeg -i file.wav -f s16le -acodec pcm_s16le file.pcm

Upvotes: 2

Related Questions