Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: MovieAudioExtractionFillBuffer = paramError -50
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MovieAudioExtractionFillBuffer = paramError -50

On May 3, 2005, at 8:11 AM, Geoff Hufford wrote:

I am taking my first crack at the new extraction API. The call to
MovieAudioExtractionFillBuffer is returning a -50 paramError. I have tried
tweaking the numbers and different approaches at allocation the buffer. The
call to MovieAudioExtractionGetProperty appears to return the expected
result. The movie passed in is playable and has a sound track. Anyone catch
what I am missing?

MovieAudioExtractionRef session; OSStatus status = MovieAudioExtractionBegin( myMovie, 0, &session);

TimeRecord timerec;
ByteCount inPropValueSize = sizeof(TimeRecord);
status = MovieAudioExtractionGetProperty(session,
  inPropValueSize,(QTPropertyValuePtr) &timerec, &inPropValueSize);

Your above code is fine.

UInt32 ioNumFrames = 1000;
UInt32 outFlags = 0;

AudioBufferList ioData;
ioData.mNumberBuffers = 1;
ioData.mBuffers[0].mNumberChannels = 2;
ioData.mBuffers[0].mDataByteSize = (sizeof(float) * 2000);
ioData.mBuffers[0].mData = new float(2000);

Your bufferlist has a problem:
1) You don't know what audio will be coming out of the movie. You're assuming it's going to be 2 interleaved channels of audio, when in fact, by default, you' get non-interleaved audio (movies.h says so). If you specifically want to coerce the pcm data you'll get from the movie to a specific format, you'll need to set two properties on the ExtractionSession - the audiostreambasicdescription, and the channel layout. But to fix your code above, first get the stream description from the movie, like this:

AudioStreamBasicDescription asbd;

// first get the asbd from the extraction session, so you know the proper sample rate.
status = MovieAudioExtractionGetProperty(session,
sizeof(asbd), &asbd, NULL);

// now you know how many buffers you need and how big to size them:

const UInt32 desiredNumFrames = 1000;
AudioBufferList * abl = (AudioBufferList*)calloc(1, offsetof (AudioBufferList, mBuffers[asbd.mChannelsPerFrame]));
abl->mNumberBuffers = asbd.mChannelsPerFrame;

for (i = 0; i < abl->mNumberBuffers; i++)
    abl->mBuffers[i].mNumberChannels = 1;
    abl->mDataByteSize = desiredNumFrames * asbd.mBytesPerFrame;
    abl->mData = malloc(abl->mDataByteSize);

// when you're done extracting, remember to free each mData in the bufferlist, then free the abl itself!

You can of course get interleaved PCM data from audio extraction API's, but this is not the default behavior, as most people will probably be extracting audio from quicktime movies in order to source audio into a CoreAudio audio unit chain or graph, and V2 audio units require de-interleaved float32 audio.

Hope that helps. -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: This email sent to email@hidden
 >MovieAudioExtractionFillBuffer = paramError -50 (From: Geoff Hufford <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.