On May 22, 2006, at 3:29 PM, Steve Israelson wrote:
- I want to extract and convert the audio from a single track.
How do I specify this? I can see how to specify left or right
etc, but that mixes all left and rights together, but I want
say the left of a single track only.
There are two ways.
1) iterate through the tracks in the source movie, get the track
layout, and set the channel labels you want to exclude to
kAudioChannelLabel_Unused. Note that if you leave, say,
multiple "Left's" labelled as "Left", they will still all mix
into a single "Left", unless you specify:
2) kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete on
the MovieAudioExtractionSession. This causes QuickTime to do
_no_ mixing. You get all the source channels in all the audio
tracks in the movie (in order) if you set this property.
So, if the track in question is stereo, and all others are set to
"unused", then I just pick out the left or right track as needed.
Just pick out the left or right _channel_ as needed. I think
that's what you meant though.
Is there any other track layouts, like say 5.1 where I have more
options than just left and right PER TRACK?
I'm not sure I understand the question. QuickTime audio tracks
now allow any number of channels of audio, and those channels can
be labelled using any of the AudioChannelLabels supported by
CoreAudio (see CoreAudioTypes.h). You need to be prepared for
strange things -- for instance, you could have an audio track with
10 channels of audio, each one labelled "Right". QTPro Users can
relabel audio channels at will in the Movie Jinfo window.
Ok, so here is what I am doing:
MovieAudioExtractionBegin(...)
MovieAudioExtractionGetProperty
(kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription)
// here I set the sample rate to what I want: 44,100
MovieAudioExtractionSetProperty(...) // for above sample rate change
// choose left channel
AudioChannelLayout layout;
layout.mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelBitmap;
layout.mChannelBitmap = kAudioChannelBit_Right;
MovieAudioExtractionSetProperty(...)
// finally, extract some data:
MovieAudioExtractionFillBuffer()
And it then returns an improper call order error. Huh?
Search the archives for a response from me about the conditions in
which MovieAudioExtractionFillBuffer returns badCallOrder. The most
common is that the movie is inactive. In your case, the problem is
probably the mismatch between the AudioStreamBasicDescription's
mChannelsPerFrame, and the AudioChannelLayout you set. The ACL you
set only specifies 1 channel of audio, but the asbd is specifying the
number of channels in the summary mix of the movie. Regardless, this
is not how you want to do it.
Instead:
MovieAudioExtractionBegin(...)
Now set the property:
MovieAudioExtractionSetProperty(...
kQTPropertyClass_MovieAudioExtraction_Movie,
kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete, ... )
By default, MAE gives you non-interleaved audio, meaning a separate
buffer for each channel of output. By specifying "all channels
discrete", MAE will do no mixing. You just need to know the index of
the channel in the source movie that you care about.
MovieAudioExtractionGetProperty
(kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription)
// here I set the sample rate to what I want: 44,100
MovieAudioExtractionSetProperty(...) // for above sample rate change
{ Deleting the layout code from the original, you don't need it now }
// finally, extract some data:
MovieAudioExtractionFillBuffer()
In the extracted AudioBufferList, just use the one channel you care
about.
Should I set it to left, then set the sample rate?
No, order doesn't matter as far as asbd's and acl's.
Essentially all I want is ONE specific channel of audio at a sample
rate I specify. I am using "left" for testing, but the user can
choose any channel.
The code snippet you provided would only work if you first iterated
through all the tracks in the source movie and relabelled all the
duplicate labelled channels to "unused".
HTH.
-Brad Ford
QuickTime Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden