Search code examples
javaandroid-studiowavaudio-recordingconverters

Android Studio Java - Convert 3gp file to wav without ffmpeg


I'm writing an Android Studio project in Java that records audio, then sends it to a flask server to extract its musical notes.

Since I found MediaRecorder easier to use and more friendly than the other solutions, I use it to record the audio. However, it doesn't supportwav format. (The different output formats that are supported are MPEG_4 | WEBM | THREE_GPP | AAC_ADTS | AMR_NB | AMR_WB | MPEG_2_TS | OGG and I currently use 3gp (THREE_GPP)).

Because my flask server accepts wav files only, my goal is to convert the recorded file (can be any of the supported formats above) to wav format. I've already tried to use the ffmpeg library, as I found this solution on this website, but it didn't let me execute ffmpeg commands due to permission limits.

So my final question is, how can I convert the recorded audio file to wav format using Java and without executing any shell commands?

If there is a better way to accomplish my goals, such as fix the permission error I have had or any other solution, I would love to hear that as well.


Solution

  • I've found an alternative to record wav files in android studio.

    It is a class called WavAudioRecorder I found on github.

    Credit: https://github.com/roman10/roman10-android-tutorial/blob/master/AndroidWaveRecorder/src/roman10/tutorial/androidwaverecorder/WavAudioRecorder.java