Search code examples
androidaudioaudio-recordingmediarecorderbitrate

How to record Ultra low size audio on Android


I tried using AMR_NB encoder and 3gp outfut format in MediaRecorder and got fairly low filesize (104KB for 60 seconds audio). But for my application (audio chat on low bandwidth unreliable network especially for the third world), I need lower audio sizes.

I tried using the following options alongwith AMR_NB encoder, 3gp output format and setAudioChannels(1) -

a. setAudioSamplingRate(8000) and setAudioEncodingBitRate(4750)

b. setAudioSamplingRate(4000) and setAudioEncodingBitRate(4000)

c. setAudioSamplingRate(2000) and setAudioEncodingBitRate(2000)

But, whether any of the above options are used or not, the audio filesize remains same.

My questions are as follows -

1. Why aren't any of the options having any effect on the filesize?

2. What should I do to reduce the filesize (by sacrificing the sound quality of course)?

For comparison, Facebook messenger records a 60 second audio in 90KB as a .mp4 file.

recorder = new MediaRecorder();

recorder.setAudioChannels(1);
recorder.setAudioSamplingRate(8000);

recorder.setAudioEncodingBitRate(4750);

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

Solution

  • Look into the official doc : http://developer.android.com/reference/android/media/MediaRecorder.html

    It says that, for AMR_NB, setAudioSamplingRate() only supports 8000 Hz!

    Can you post some of your code? It might be helpful to see what is your problem.

    EDIT: Try to record on AAC format - like Facebook messenger. I think that you don't do smaller size with AMR_NB/3GP.