我正在调用AudioFileGetProperty方法,以便为.ac3音频文件设置AudioStreamBasicDescription对象的属性,但结果是所有属性都为0。 这是我的代码
NSString *soundFile= [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"sample1AC3.ac3"];
CFURLRef soundURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (__bridge void*)soundFile, kCFURLPOSIXPathStyle, false);
int err;
err = AudioFileOpenURL(soundURL, kAudioFileReadPermission, 0, &mAudioFile);
//
AudioStreamBasicDescription audioFormat;
UInt32 size1 = sizeof(audioFormat);
//
err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &size1, &audioFormat);
这是我的日志
audioFormat AudioStreamBasicDescription {...}
mSampleRate Float64 0
mFormatID UInt32 0
mFormatFlags UInt32 0
mBytesPerPacket UInt32 0
mFramesPerPacket UInt32 0
mBytesPerFrame UInt32 0
mChannelsPerFrame UInt32 0
mBitsPerChannel UInt32 0
mReserved UInt32 0
该代码适用于.mp3,我不明白为什么它不适用于.ac3格式。