danyowdee
danyowdee

Reputation: 4698

Problem with Unused Audio-Channels in QuickTime Capture

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:

  1. Is it at all possible to detect if the audio-channels of a track are marked as "unused" from QTKit?
  2. Since I think that the answer to the above is "no", I've been digging around the structure of some movie files that are working correctly with "Atom Inspector" — so far without any success:
    What/Where is the QuickTime Atom where this info is stored?
    I can see the correct number of channels in the stsd Atom (contained in the stbl Atom) but I don't see where any mapping occurs.

Upvotes: 0

Views: 310

Answers (1)

jfortmann
jfortmann

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

Related Questions