简体   繁体   中英

How to real-time convert the PCM buffer to AAC data when recording for iOS?

I'm using Remote.IO to get the audio buffer from PCM, but the raw data is too big to send to remote-side by cellular network (3G network). I did reference some articles, but most of them suggest converting file to the other format file.

Is there any way to convert the audio buffer to AAC encoding data in real-time ?

You can indeed save the audio buffer directly into AAC format.

While setting the ASBD, set it like this

AudioStreamBasicDescription audioFormat;
audioFormat.mFormatID = kAudioFormatMPEG4AAC;

Specify kAudioFileM4AType while calling ExtAudioFileCreateWithURL like this:

err = ExtAudioFileCreateWithURL((CFURLRef)audioFileURL,
                             kAudioFileM4AType,
                             &audioFormat, 
                             NULL,
                             kAudioFileFlags_EraseFile,
                             &outFile);

You also need to set the codec like this.

UInt32 codecManf = kAppleSoftwareAudioCodecManufacturer;
ExtAudioFileSetProperty(outFile, kExtAudioFileProperty_CodecManufacturer, sizeof(UInt32), &codecManf);

This should help you get your AAC encoding working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM