Reputation: 4698
I have written an application that captures audio and video from multiple devices simultaneously, using the QTKit capture APIs a while ago.
However, I have learned that from time to time, the media captured from DV camcorders appears to not have any associated audio. In fact, the audio track is well present in the file, but the channels are set to "unused" in QuickTime Player Pro — hence the silence.
Since I am not comfortable exposing my users to such shenanigans, I want to post-flight my recordings and fix the channel-layout automatically, if needed.
Unfortunately, I have a hard time figuring out how!
My question is two-fold:
stsd
Atom (contained in the stbl
Atom) but I don't see where any mapping occurs.Upvotes: 0
Views: 310
Reputation: 233
First question: Doesn't look like it.
You'll have to use the QTGetTrackPropertyInfo
API with kQTPropertyClass_Audio, kQTAudioPropertyID_ChannelLayout
to get a channel layout. If the returned AudioChannelLayout
structure contains a tag != 0, you can resolve that via AudioFormatGetPropertyInfo
with kAudioFormatProperty_ChannelLayoutForTag
; otherwise, the AudioChannelDescription
field will be valid, with mChannelLabel
set to kAudioChannelLabel_Unused
(0). Of course, all this only works in 32 bit. Don't forget to #include <AudioToolbox/AudioToolbox.h>
Second question:
The stsd atom of the audio track should contain a 'chan' extension. This extension appears to be a UInt32 set to zero, followed by an AudioChannelLayout
structure. It doesn't seem to be documented in either the QT file spec nor the MP4 spec.
Good luck!
Upvotes: 1