1

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.

Johann
  • 27,536
  • 39
  • 165
  • 279

1 Answers1

2

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
Community
  • 1
  • 1
fardjad
  • 20,031
  • 6
  • 53
  • 68
  • That's a very large package - over 9 mb. It's a full blown audio processing app. Overkill for my app which is only 2 mb in size. – Johann Feb 11 '13 at 13:44
  • Is there anyway to decode/convert AMR files to mp3/(any playable format) in android kitkat 4.4.2 or higher version? If yes then can you please show some code snippet or any example to do that? Please help. – suv Nov 30 '18 at 14:20