我需要在QT电影中获取音轨的频道布局。我已经阅读了CMAudioFormatDescription
"<CMAudioFormatDescription 0x60800011fad0 [0x7fff77314f00]> {
mediaType:'soun'
mediaSubType:'lpcm'
mediaSpecific: {
ASBD: {mSampleRate: 48000.000000
mFormatID: 'lpcm'
mFormatFlags: 0xc
mBytesPerPacket: 6
mFramesPerPacket: 1
mBytesPerFrame: 6
mChannelsPerFrame: 2
mBitsPerChannel: 24 }
cookie: {(null)}
ACL: {Stereo (L R)}
}
extensions: {<CFBasicHash 0x608000668080 [0x7fff77314f00]>{type = immutable dict, count = 1,\nentries =>\n\t1 : <CFString 0x7fff760e2340 [0x7fff77314f00]>{contents = \"VerbatimSampleDescription\"} = <CFData 0x608000365940 [0x7fff77314f00]>{length = 114, capacity = 114, bytes = 0x00000072696e32340000000000000001 ... 0000000000000000}\n}\n}\n}"
但是我无法解决如何提取&#34; Stereo(L R)&#34;这个字符串。我看到有一个CMAudioFormatDescriptionGetChannelLayout,它包含一个AudioChannelLayoutTag,在这种情况下是kAudioChannelLayoutTag_Stereo,但是&#34; Stereo(L R)&#34;字符串来自?
不幸的是,由于某些原因我不能让它工作:
size_t layoutSize = 0;
const AudioChannelLayout *layout = CMAudioFormatDescriptionGetChannelLayout(audioTrackRef, &layoutSize);
NSString *layoutName = nil;
UInt32 layoutNameSize = sizeof(layoutName);
OSStatus err = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutSimpleName, sizeof(layout), &layout, &layoutNameSize, &layoutName);
和layoutName
仍为零,即使我能看到&#34; Stereo(L R)&#34;当我打印audioTrackRef
答案 0 :(得分:1)
您可以将kAudioFormatProperty_ChannelLayoutName
和kAudioFormatProperty_ChannelLayoutSimpleName
属性与AudioFormatGetProperty
一起使用,以获取您之后的内容:
CFStringRef layoutName = nullptr;
UInt32 propertySize = sizeof(layoutName);
OSStatus result = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutName, /* size of your channel layout */, /* your channel layout */, &propertySize, &layoutName);
// later
CFRelease(layoutName);