PDA

View Full Version : QuickTime MovieExport procedure


Steven
2004.07.06, 06:11 PM
What's the proper way of setting up QuickTime to read in an audio track and export it as a different format? This is what I have so far (with error checking and such removed) but it always exports as 8bit PCM, no matter what I pass in. What am I doing wrong?
OSErr nErr;
Movie movie;
FSSpec inFile;
Component movieExporterComponent = 0;
FSSpec outFile;
char aChar;
Boolean cancelled = false;
ComponentDescription compDesc;
short refNum;
ComponentInstance sc = NULL;
SCSpatialSettings ss;
SCTemporalSettings st;
SCDataRateSettings sd;
QTAtomContainer gExportSettings;
MovieExportComponent exporter = NULL;


nErr = EnterMovies();



inFile = toFSSpec(inF);
outFile = toFSSpec(outF);


nErr = OpenMovieFile(&inFile,&refNum,fsRdPerm);

nErr = NewMovieFromFile(&movie,refNum,NULL,NULL,0,NULL);


GoToBeginningOfMovie(movie);

compDesc.componentType = MovieExportType;
compDesc.componentSubType = kQTFileTypeMovie;
compDesc.componentManufacturer = kAppleManufacturer;
compDesc.componentFlags = 0;
compDesc.componentFlagsMask = cmpIsMissing;

movieExporterComponent = FindNextComponent(NULL, &compDesc);


nErr = OpenAComponent(movieExporterComponent, &exporter);

nErr = OpenADefaultComponent(StandardCompressionType,Stan dardCompressionSubType,&sc);


ss.codecType = 0;
ss.codec = options.codec;
ss.depth = options.depth;
ss.spatialQuality = (codecMaxQuality - codecMinQuality) * options.quality + codecMinQuality;

st.temporalQuality = codecNormalQuality;
st.frameRate = 0;
st.keyFrameRate = 0;

sd.dataRate = options.dataRate;
sd.frameDuration = 0;
sd.minSpatialQuality = 0;
sd.minTemporalQuality = 0;


SCSetInfo(sc, scSpatialSettingsType, &ss);
SCSetInfo(sc, scTemporalSettingsType, &st);
SCSetInfo(sc, scDataRateSettingsType, &sd);


SCGetSettingsAsAtomContainer(sc, &gExportSettings);


CloseComponent(sc);


aChar = (options.audio ? true : false);

nErr = QTInsertChild( gExportSettings, kParentAtomIsContainer, kQTSettingsMovieExportEnableSound, 1, 0, sizeof(aChar), &aChar, nil );

aChar = (options.video ? true : false);
nErr = QTInsertChild( gExportSettings, kParentAtomIsContainer, kQTSettingsMovieExportEnableVideo, 1, 0, sizeof(aChar), &aChar, nil );


if(options.audio){
QTAtom temp = 0,ret = 0;
UnsignedFixed r,s;
QTFindChildByIndex(gExportSettings,kParentAtomIsCo ntainer,'sptl',0,&temp);
QTInsertChild(gExportSettings,temp,kQTSettingsSoun d,0,0,0,NULL,&temp);

QTInsertChild(gExportSettings,temp,scSoundCompress ionType,10,0,4,&options.codec,&ret);

r = (int)(options.sampleRate*((unsigned long)1 << 16));
QTInsertChild(gExportSettings,temp,scSoundSampleRa teType,11,0,sizeof(UnsignedFixed),&r,&ret);

s = (int)(options.sampleSize*((unsigned long)1 << 16));

QTInsertChild(gExportSettings,temp,scSoundSampleSi zeType,12,0,sizeof(UnsignedFixed),&s,&ret);

QTInsertChild(gExportSettings,temp,scSoundChannelC ountType,13,0,sizeof(short),&options.channels,&ret);

}
if(options.video){
printf("Video not implemented yet!\n");
}



nErr = MovieExportSetSettingsFromAtomContainer(exporter, gExportSettings);


QTDisposeAtomContainer(gExportSettings);
gExportSettings = NULL;

nErr = MovieExportToFile(exporter, &outFile, movie, NULL, 0, GetMovieDuration(movie));

CloseMovieFile(refNum);

Steven
2004.07.08, 07:59 PM
Well, by changing the last line to:
nErr = ConvertMovieToFile(movie,NULL,&outFile,kQTFileTypeMP4,'MooV',smSystemScript,NULL, 0,NULL);
I got it to export a MP4, but apparently this is one of the only type supported by this method (AIFF, AIFC, and MIDI being the others)

How do I export to other formats, uLaw, aLaw, and such?

Steven
2004.07.10, 11:06 AM
If nobody knows, where might I ask someone who does?

Josh
2004.07.10, 11:45 AM
Is there a QT mailing list or something of that nature?

Steven
2004.07.10, 11:54 AM
That's what I was hoping, but I don't know of one. But, it turns out there's a list server at lists.apple.com that I didn't even know about. I just subscribed to quicktime-api and will ask there soon...