ADC Home > Reference Library > Technical Q&As > QuickTime > Import & Export >

Using MovieExportSetSampleDescription to specify the format of exported data


Q: I'd like to use the ConvertMovieToFile function to export a WAV audio-only movie to an AIFF file using a specific compressor such as QUALCOMM PureVoice. How do I specify the movie export component use the designated compressor?

A: Use the MovieExportSetSampleDescription function to specify the format of the exported data. This function is supported by the Apple sound movie export component (though it is not necessarily implemented by all movie export components - if it's not, the component will return the codecUnimpErr error). Here's code showing how to use the MovieExportSetSampleDescription to specify the format of the exported data:


 Listing 1. Using the MovieExportSetSampleDescription function to specify the format of exported data.


OSErr ExportWAVEtoAIFF (Movie theMovie, FSSpec *theFile)
{
    ComponentInstance            myComponent = NULL;
    SoundDescriptionHandle        myDesc = NULL;
    ComponentResult                myErr = badComponentType;

    // open a movie export component
    myComponent = GetAIFFMovieExportComponent();
    if (myComponent == NULL)
        goto bail;

    // create and fill in a sound description
    myDesc = (SoundDescriptionHandle)NewHandleClear(sizeof(SoundDescription));
    if (myDesc == NULL)
    {
        myErr = MemError();
        goto bail;
    }

    // specify the export format
    (**myDesc).descSize = sizeof(SoundDescription);
    (**myDesc).sampleSize = 16;
    (**myDesc).sampleRate = rate22050hz;
    (**myDesc).dataFormat = kQUALCOMMCompression;
    (**myDesc).dataRefIndex = 1;
    (**myDesc).numChannels = 1;

    // tell the export component to use the
    // specified audio characteristics
    myErr = MovieExportSetSampleDescription(myComponent,
          (SampleDescriptionHandle)myDesc, SoundMediaType);
    if (myErr != noErr)
        goto bail;

    // export the movie into a file
    myErr = ConvertMovieToFile(
                        theMovie,        // the movie to convert
                        NULL,            // the first track
                        theFile,         // the output file
                        kQTFileTypeAIFF, // the output file type
                        sigMoviePlayer,  // the output file creator
                        smSystemScript,  // the script
                        NULL,            // resource ID
                        0L,              // no flags
                        myComponent);    // the export component

bail:
    // dispose of any storage we allocated
    if (myComponent != NULL)
        CloseComponent(myComponent);

    if (myDesc != NULL)
        DisposeHandle((Handle)myDesc);

    return((OSErr)myErr);
}

ComponentInstance GetAIFFMovieExportComponent()
{
    ComponentDescription cd;
    Component c = 0;
    ComponentInstance ci=0;


    cd.componentType = MovieExportType;
    cd.componentSubType = kQTFileTypeAIFF;
    cd.componentManufacturer = SoundMediaType;
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;

    c = FindNextComponent( c, &cd );

    if (c != nil)
    {
        ci = OpenComponent(c);
    }

    return ci;
}

[Sep 05 2000]



Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.