what is good setAudioEncodingBitRate on record voice

android

Solution

You set the AudioEncodingBitRate too low. I made the same mistake :-)

This seems to work:

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (Build.VERSION.SDK_INT >= 10) {
    recorder.setAudioSamplingRate(44100);
    recorder.setAudioEncodingBitRate(96000);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} else {
    // older version of Android, use crappy sounding voice codec
    recorder.setAudioSamplingRate(8000);
    recorder.setAudioEncodingBitRate(12200);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
recorder.setOutputFile(file.getAbsolutePath());
try {
    recorder.prepare();
} catch (IOException e) {
    throw new RuntimeException(e);
}

The idea comes from here

plus: read the docs. The docs of setAudioSamplingRate say the following:

The sampling rate really depends on the format for the audio recording, as well as the capabilities of the platform. For instance, the sampling rate supported by AAC audio coding standard ranges from 8 to 96 kHz, the sampling rate supported by AMRNB is 8kHz, and the sampling rate supported by AMRWB is 16kHz.

Problem

hello,i want to use mediaRecorder to record voice. i want to save the format is amr. ``` this.mediaRecorder = new MediaRecorder(); this.mediaRecorder.setAudioChannels(1); this.mediaRecorder.setAudioSamplingRate(8000); this.mediaRecorder.setAudioEncodingBitRate(16); this.mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); this.mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); this.mediaRecorder.setOutputFile(this.file.getAbsolutePath()); this.mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); ``` i used this.mediaRecorder.setAudioEncodingBitRate(16), some device is ok mediaRecorder.setAudioEncodingBitRate(12500),somedevice is ok but i delete the mediaRecorder.setAudioEncodingBitRate some device is ok so my question how to get the default the AudioEncodingBitRate. which parameter i need to use?

Original source