Question

I want to read the AudioStreamBasicDescription from an audio file as follows

AudioStreamBasicDescription asdb;
UInt32 propSize = sizeof(asdb);

OSStat stat = ExtAudioFileGetProperty(_audioFile,
                                      kExtAudioFileProperty_FileDataFormat,
                                      &propSize,
                                      &asdb);

That works fine, except that all fields but mBytesPerFrame, mBitsPerChannel and mBytesPerPacket are set correctly.

Why would these fields not be set?

That's what the AudioStreamBasicDescription's fields look like

TotalFrames: 2628360
BitsPerChannel: 0
BytesPerFrame: 0
BytesPerPacket: 0
ChannelsPerFrame: 2
FormatFlags: 0
FormatID: aac 
FramesPerPacket: 1024
SampleRate: 44100
Was it helpful?

Solution

Take a look at the comment above AudioStreamBasicDescription in CoreAudioTypes.h. It explains how depending on the format, some fields may not be filled in. Since AAC is a compressed format, not all of the fields can be calculated, and are therefore returned as 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top