Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio quality difference on Kitkat / Lollipop

Tags:

xml

I am attempting to record audio on Android and encounter issues with the quality, respectively the chosen format.

I use the following setup

mr=new MediaRecorder();
mr.setAudioSource(MediaRecorder.AudioSource.MIC);
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mr.setOutputFile("somepath");
mr.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

That code however returns very different results on two devices running different Android versions (4.4.4 and 5.1.1).

When I take a look at the file headers, it shows different formats for both files there (3gp4 on 4.4.4 - mp42 on 5.1.1). VLC however "insists" on both using AAC, but shows very different sampling rates, 8k for the 4.4.4 file and 48k for 5.1.1.

Anybody an idea why?

like image 364
user5854159 Avatar asked Jan 29 '16 06:01

user5854159


People also ask

Which is better KitKat or Lollipop?

Android 5.0 Lollipop is the updated version of Android KitKat, previously with the support of KitKat users faced various problems, such as phone heating issues, network disconnection issue, WiFi bug, and battery drain problem. Google solved these issues with Lollipop.

Is Lollipop Android 5.1 good?

Overall, Android 5.1 seems like a far better version of Android than anything we've seen from third-party OEMs or even Google in the past. The slick design and good-looking animations are far more convincing than anything from Samsung or HTC.

Which one is better android lollipop or marshmallow?

Android Marshmallow goes one step forward when compared to the Lollipop version. Lollipop introduced project Volta, Google laid the foundation for longer battery life. Google has been worked very hard to improve the experience with Android. Marshmallow takes one step forward with Doze.


1 Answers

Try to set all of this:

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); //I would use MediaRecorder.AudioEncoder.AMR_NB
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
recorder.setOutputFile(outputFile.getAbsolutePath());
recorder.prepare();
recorder.start();

Or use external library: http://rehearsalassist.svn.sourceforge.net/viewvc/rehearsalassist/android/releases/RehearsalAssistant_0_8_2/src/urbanstew/RehearsalAssistant/

By changing recorder:

 RehearsalAudioRecorder recorder = new RehearsalAudioRecorder(RehearsalAudioRecorder.RECORDING_UNCOMPRESSED, MediaRecorder.AudioSource.MIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT);
 recorder.setOutputFile(outputFile.getAbsolutePath());
 recorder.prepare();
 recorder.start();

UPDATE

Check also this:

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

It seems like devices with SDK lower than 10 cannot record good quality.

like image 165
m.aibin Avatar answered Oct 26 '22 11:10

m.aibin