我正在调用 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 格式。