Android MediaRecorder is not generating a streamab

2019-07-02 08:03发布

问题:

I am using a Nexus 7 with Android version 4.2+. So according to the Android Supported Media Formats all listed encoders and container formats are supported.

Now I want to record an audio using the AAC-LC encoder and the MPEG-4 container format (file type).

In the generated file, when I open it in an HEX-Editor, I see that the file is an ISO Base Media file having the isom File Type Box (Section 4.3) with the following compatible brands: isom and 3gp4. The remaining of the file is mostly an mdat Box (containing the actual audio data). The following HEX snippet from the beginning of the file was telling me this:

00000018 66747970 69736F6D 00000000 69736F6D 33677034 00029708 6D646174 ...

translated as:

      24 ftyp     isom     no-minor isom     3gp4     0x29708  mdat     ...

which means:

the file (ftyp) is complying with the ISO/IEC 14496-12 (isom) and specifies no minor version. The compatible brands with this file are: isom and 3gp4. Then follows the audio data box (mdat) with length 0x29708

Where is the part telling me that this is an AAC-LC (AAC Low complexity) encoded file?

Moreover, compared to other AAC-LC files on the web their header (file box) is different mentioning mp42 as ftyp and mp42, isom, ndia as compatible brands. Such a file is also streamable (how AAC-LC should be).

But the Android generated AAC_LC (MP4) file is NOT streamable. So what is Android MediaRecorder or me doing wrong? I am using the following code:

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
// the bit rate should be adjusted silently if out of range
mRecorder.setAudioEncodingBitRate(320000);
mRecorder.setAudioSamplingRate(48000);