Please see code at end of this message. I am trying to create a movie
frame by frame. I basically get called with a PNG image file in
memory, I have to render the image and write it to the movie file as
one frame.
When it's finished there is a 5.3 MB imovie file created, I can open
in QuickTime Movie Player but it says the movie has a duration of 0
and doesn't play anything. When the movie opens, the area for the
frame is not displayed, only the lower controls part of the window is
displayed (like if you just play an audio file).
I'm not sure if I should be using the GWorld functions anymore and
not sure if this is why it's not working. Is there a better way of
doing this?
//**
//** Convert the File Path to a CFString
//**
myFilePathStringCFString = CFStringCreateWithCString
(kCFAllocatorDefault,theFilePathStringPtr,kCFStringEncodingMacRoman);
if (myFilePathStringCFString == NULL)
return(kRunRevBadFileNameString);
//**
//** Make a Data Reference from a POSIX File Path String
//**
myOSStatus = QTNewDataReferenceFromFullPathCFString
(myFilePathStringCFString,kQTPOSIXPathStyle,
0,&myFileDataRef,&myDataRefType);
if (myOSStatus != noErr)
goto LTWQTUtilsCreateMovie_999;
//**
//** Create the Movie Storage
//**
myOSStatus = CreateMovieStorage
(myFileDataRef,myDataRefType,'TVOD',smCurrentScript,createMovieFileDelet
eCurFile,&theParameterInfoPtr->QTDataHandler,&theParameterInfoPtr-
>QTMovieRef);
if (myOSStatus != noErr)
goto LTWQTUtilsCreateMovie_999;
//**
//** Add the Movie to the Storage
//**
myOSStatus = AddMovieToStorage(theParameterInfoPtr-
>QTMovieRef,theParameterInfoPtr->QTDataHandler);
if (myOSStatus != noErr)
goto LTWQTUtilsCreateMovie_999;
//**
//** Create a New Movie Track
//**
theParameterInfoPtr->QTTrackRef = NewMovieTrack(theParameterInfoPtr-
>QTMovieRef,
FixRatio(theParameterInfoPtr->QTFrameWidth,1),
FixRatio(theParameterInfoPtr->QTFrameHeight,1),
kNoVolume);
myOSStatus = GetMoviesError();
if (myOSStatus != noErr)
return(myOSStatus);
//**
//** Create Media for Track
//**
theParameterInfoPtr->QTMediaRef = NewTrackMedia(theParameterInfoPtr-
>QTTrackRef,VideoMediaType,600,NULL,0);
myOSStatus = GetMoviesError();
if (myOSStatus != noErr)
return(myOSStatus);
//**
//** Begin Media Edits
//**
myOSStatus = BeginMediaEdits(theParameterInfoPtr->QTMediaRef);
if (myOSStatus != noErr)
return(myOSStatus);
//**
//** Clean up and Return
//**
LTWQTUtilsCreateMovie_999:
if (myFilePathStringCFString != NULL)
CFRelease(myFilePathStringCFString);
if (myOSStatus != noErr)
{
if (theParameterInfoPtr->QTMovieRef != NULL)
{
DisposeMovie(theParameterInfoPtr->QTMovieRef);
theParameterInfoPtr->QTMovieRef = NULL;
}
}
return(myOSStatus);
}
//**
//** End Media Edits
//**
myOSStatus = EndMediaEdits(theParameterInfoPtr->QTMediaRef);
if (myOSStatus != noErr)
goto LTWQTUtilsCloseMovie_999;
//**
//** Insert the Media into the Movie Track
//**
myMovieDuration = GetMediaDuration(theParameterInfoPtr->QTMediaRef);
myOSStatus = InsertMediaIntoTrack(theParameterInfoPtr->QTTrackRef,
0,0,myMovieDuration,fixed1);
if (myOSStatus != noErr)
goto LTWQTUtilsCloseMovie_999;
//**
//** Close the Movie Storage
//**
myOSStatus = CloseMovieStorage(theParameterInfoPtr->QTDataHandler);
if (myOSStatus != noErr)
goto LTWQTUtilsCloseMovie_999;
//**
//** Clean up and Return
//**
LTWQTUtilsCloseMovie_999:
if (theParameterInfoPtr->QTMovieRef != NULL)
{
DisposeMovie(theParameterInfoPtr->QTMovieRef);
theParameterInfoPtr->QTMovieRef = NULL;
}
return(myOSStatus);
}
//**
//** Add the Image to the Movie
//**
myOSStatus = AddMediaSample(theParameterInfoPtr->QTMediaRef,
myComprDataHdl,
0, // no offset in data
(**myImageDesc).dataSize,
kVideoFrameDuration, // frame duration
(SampleDescriptionHandle) myImageDesc,
1, // one sample
0, // self-contained samples
NULL);
if (myOSStatus != noErr)
goto LTWQTUtilsAddFrameToMovie_999;
//**
//** Clean up and Return
//**
LTWQTUtilsAddFrameToMovie_999:
SetGWorld(mySavedPort,mySavedDevice);
if (myImageDesc != NULL)
DisposeHandle((Handle)myImageDesc);
if (myComprDataHdl != NULL)
DisposeHandle(myComprDataHdl);
if (myGWorld != NULL)
DisposeGWorld(myGWorld);
return(myOSStatus);
}
_______________________________________________
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