Audio queue services are written to a .mp4 file that cannot be played. And the problem with magic cookie

I am a Mac programmer for beginners in just 3 months. I have a problem servicing a queue in a queue, hope someone can help me.

I use the Audio Queue Services API by creating a writer and outputting AAC format data. Everything seems to work well.

Until I use the MP4V2 library (open source library) to output a. mp4, a problem arises.

Problem 1:

I use a magic cookie as an AAC header to enter the MP4V2 MP4WriteSample () library function. There is data inside the .mp4 file, but the player (for example: Quicktime) cannot recognize the .mp4 file, it cannot play audio data.


Problem 2:

I set the format for the basic descriptions of my audio queue:

aqData.mDataFormat.mSampleRate = 44100.0; aqData.mDataFormat.mFormatID = kAudioFormatMPEG4AAC; // AAC codec. aqData.mDataFormat.mChannelsPerFrame = 2; aqData.mDataFormat.mFramesPerPacket = 1024; 

and use AudioQueueGetProperty () to get the magic cookie.

How do I print my magic cookies , for example:

  <03808080 22000000 04808080 14401500 18000001 f4000001 f4000580 80800212 10068080 800102> 

only 39 bytes.

What exactly does this mean?

What are 39 bytes each?

Can it convert to an AAC header?

Link:

Set Magic Cookie for audio file

Set Magic Cookie for Playback Queue

CoreAudio - how to determine the end of aac playable file


Thank you very much.

Ryan

+4
source share
1 answer

set file type to kAudioFileM4AType

 AudioFileCreateWithURL ( audioFileURL, kAudioFileM4AType, &audioFormat, kAudioFileFlags_EraseFile, &audioFileID ); 
0
source

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


All Articles