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
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
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);
© 2024 OneMinuteCode. All rights reserved.