5

I'm using the Android MediaRecorder to record AAC encoded audio files. Setting the output format to MPEG-4 worked pretty well. But as my audio player supports neither MPEG-4 nor 3GP I tried to get raw AAC files by using the output format AAC_ADTS, which is supported by Android since 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);

Here is where I got stuck. The MediaRecorder created a file but I'm not able to play that file with any player (neither Android's MediaPlayer nor the Windows Media Player nor my audio player I mentioned above, which was able to play an ADTS AAC file I found on the web).

Am I doing something wrong? Is the AAC_ADTS output format even a recommendable format? Is there a way to get an ADIF AAC file?

Kirby
  • 86
  • 1
  • 8
  • i was able to record using your audioSource, outputFormat and audioEncoder. The file played fine using AIMP and Windows media player and the player on my phone. – pstanton Jan 20 '15 at 19:59
  • I didn't find any solution to use AAC_ADTS as the OutputFormat. Instead I'm using MPEG_4 with a different audio player. – Kirby Feb 12 '15 at 11:45
  • I have the same problem. It appears that the generated files are AAC Main profile instead of AAC LC - at least that is what ffprobe tells me. There is nothing wrong with the files except they are the wrong format. AudioEncoder.AAC should generate AAC LC according to the docs. – Johan Levin Mar 10 '15 at 09:05
  • I agree with Kirby and use OutputFormat.MPEG_4 – PavelGP Aug 31 '15 at 10:40

1 Answers1

0

Use UNPROCESSED instead of MIC.

  • 3
    Welcome to SO. It would be helpful if you edited your answer to explain why you are suggesting this. – Nick Aug 08 '18 at 19:22