Android audio recording issue with MediaRecorder O

2019-09-16 17:01发布

问题:

I am trying to record an audio from my android app. Everything worked well. Recently, I had to change the output format from MPEG4 to AAC_ADTS. The issue is that AAC_ADTS does not work for one of the device It works on the other device. So, my question is does AAC_ADTS format work only on certain android versions. How can I get the audio recorded in AAC_ADTS format from all devices? Kindly help

mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
//        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mRecorder.setOutputFile(mFileName);

        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

回答1:

AAC_ADTS format is added in API level 16, and works only on android versions 4.1+. See this link below. http://developer.android.com/reference/android/media/MediaRecorder.OutputFormat.html