On May 22, 2006, at 3:51 PM, Steve Israelson wrote:
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.
I did and saw your response. Didn't think it applied to me :) I
guess it does.
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.
Ok, so this means for a track with 2 channels, I get 2 items per
sample (Float32 in my case).
But, since I only want one of those (and with a track with 10 odd
channels even) how do I further refine it to pick only the one I want?
Let's say you set "all channels discrete" on a source movie with 10
channels of audio in a single audio track, and you know you want just
the second channel of audio. In your resulting AudioBufferList, just
use the contents of:
bufferList->mBuffers[1].mData.
The data is still non-interleaved. Unless you specifically set it to
be interleaved (you do this by mucking with the flags and various
other fields in the audio stream basic description).
// finally, extract some data:
MovieAudioExtractionFillBuffer()
In the extracted AudioBufferList, just use the one channel you
care about.
Ok, cool, so the data is interleaved in here if there was more than
one channel present, so I get ONE buffer only, but interleaved, and
thus I need to know how many are interleaved, or as above, somehow
configure it to return just one.
No, see above. You only get interleaved if you've set the extraction
asbd to give you interleaved. I happen to think my "all channels
discrete" way is easier (since you don't have to mess with the labels
of the source movie), but if you truly just want one channel of
audio delivered to your resulting bufferlist, you are going to have
to make sure QT only mixes the source channel you want into that
output buffer:
1) iterate through the source movie, one track at a time
• Get Track Channel layout. Set all channels to unused except for
the one channel you want, note the spatial label of the channel you
want in your output.
• Set Track channel layout.
2) MAEBegin
3) Set MAE ASBD to one channel at the desired sample rate.
4) Set MAE channel layout thusly:
AudioChannelLayout acl = { 0 };
acl.mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelDescriptions;
acl.mNumberChannelDescriptions = 1;
acl.mChannelDescriptions[0].mChannelLabel =
theLabelOfTheChannelINotedInBulletOneOfStepOneAbove;
5) MAE FillBuffer to your heart's content
6) When you're all done, make sure you put the channel layouts back
the way they were before you changed them in step 1. Unless of
course you're just disposing of this movie, in which case it doesn't
matter.
-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