views:

67

answers:

2

I want to extract every audio channel in a quicktime movie with the QuickTime-API. That means if the file has 5.1 surround, i want 6 audio files in the end. But at the moment I don't know how to manage that. Until now I have:

OSStatus err = noErr;
MovieAudioExtractionRef extractionSessionRef = nil;
Boolean allChannelsDiscrete = true;
int flags;
int numFrames;
AudioBufferList *mBufferList;
err = MovieAudioExtractionBegin(movie, 0, &extractionSessionRef); 


// disable mixing of audio channels
err = MovieAudioExtractionSetProperty(extractionSessionRef,
  kQTPropertyClass_MovieAudioExtraction_Movie,
  kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete,
  sizeof (Boolean), &allChannelsDiscrete);

err = MovieAudioExtractionFillBuffer(extractionSessionRef, &numFrames, 
  mBufferList, &flags);
if (flags & kQTMovieAudioExtractionComplete)
{
    // extraction complete!
}
err = MovieAudioExtractionEnd(extractionSessionRef);

The problem is that I don't know how to get mBufferList and how to export every channel as WAV 48kHz. Can you help me? The example is from this page.

A: 

Not sure if this helps - there's a method of doing this without using Quicktime-SDK:

You need to parse Quicktime "moov" atom to get the audio track types/bps/sample rate/endian etc., find then "stsc" and "stco" atoms to samples_per_chunk and each chunk offset. Then you just read "mdat" atom raw data using these offsets and write the samples to destination files.

This is not the easy way - but it works for me.

2can
+1  A: 

Have you checked with this?

vrrathod