How do I record in high quality on Android?

Asked 2 years ago, Updated 2 years ago, 57 views

I'm making a mobile community application

Currently, I record using Media Record class on Android

The sound quality is poor and the recorded data is very small.

Can you tell me how to convert to .mp3 format or record in high quality?


     recorder = new MediaRecorder();
     recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
     recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
     recorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
     recorder.setOutputFile(RECORDED_FILE);

The above code was recorded using the Media Record class. OutputFormat, mp3 does not exist and MPEG_4 format exists.

If you play it, you'll hear noise mixed in noise.

It's okay to have some capacity, but I want to get better sound quality. What should I do?

record android mediarecord

2022-09-22 14:27

2 Answers

The result of my test seems that the difference in encoder determines the sound quality. Please test it with the following code.

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setOutputFile(mFileName);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

When I set the code HE_AAC, I felt the sound quality was definitely low. AMR_NB and AMR_WB have confirmed that they record much better sound quality than HE_AAC. Please refer to the following link for the source of the relevant code.

https://developer.android.com/guide/topics/media/audio-capture.html


2022-09-22 14:27

You can also improve the sound quality by adjusting the values of Sampling Rate and Encoding Bit Rate in the additional code you uploaded. Try using the values below in the existing code.

recorder.setAudioSamplingRate(44100);
recorder.setAudioEncodingBitRate(96000);


2022-09-22 14:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.