简体   繁体   中英

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);

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.

Android encoders override programmer's parameters if they detect a mistake. AMR_NB only works with 8000 Hz and 1 channel, so if you set different values, like 4000 Hz or 2 channels, the encoder will silently change them back to 8000 and 1.

If you reduce the Audio Sampling Rate below 8000, human voice becomes undecipherable.

For lower sampling rate, you will have to use the class AudioRecord as that one lets you go as low as 4000 Hz.

For higher compression, you will have to use a different encoder, or program one yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM