The difference in sound quality on Kitkat / Lollipop

I am trying to record audio on Android and run into quality problems, correspondingly with the selected format.

I use the following setting

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

This code, however, returns very different results on two devices running under different versions of Android (4.4.4 and 5.1.1).

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

Does anyone know why?

+7
xml
source share
1 answer

Try to install 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 an external library: http://rehearsalassist.svn.sourceforge.net/viewvc/rehearsalassist/android/releases/RehearsalAssistant_0_8_2/src/urbanstew/RehearsalAssistant/

By changing the registrar:

  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:

 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 that devices with SDKs below 10 cannot record good quality.

+1
source share

All Articles