How to record original AAC audio files on Android using MediaRecorder? AAC_ADTS not working

I am using Android MediaRecorder to record AAC encoded audio files. Setting the output format to MPEG-4 worked well. But since my audio player does not support either MPEG-4 or 3GP, I tried to get raw AAC files using the AAC_ADTS output format supported by Android from API level 16.

    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
    mRecorder.setOutputFile(mFileName);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

This is where I am stuck. MediaRecorder created the file, but I could not play this file with any player (neither Android MediaPlayer, nor Windows Media Player, nor my audio player, which I mentioned above, which could play the ADTS AAC file that I found on the Internet).

Am I doing something wrong? Is the output format AAC_ADTS even the recommended format? Is there any way to get the ADIF AAC file?

+4
source share

Source: https://habr.com/ru/post/1525213/


All Articles