#include #include void main(void); void main() { OSErr err; Movie themovie; FSSpec tempspec; PicHandle pichand; SFTypeList typelist; OSType mediatypes[1]; short saveref, resref, outref, frame; StandardFileReply getreply, putreply; TimeValue fromtime, thetime, duration; /* user gets movie file */ typelist[0] = 'MooV'; StandardGetFile(nil, 1, typelist, &getreply); if (!getreply.sfGood) return; /* copy the FSSpec from the reply record and append suffix to copy of file name */ tempspec = getreply.sfFile; PtoCstr(tempspec.name); strcat((char *)tempspec.name, ".PICS"); CtoPstr((char *)tempspec.name); /* user puts new PICS file */ StandardPutFile("\pSave PICS file as:", tempspec.name, &putreply); if (!putreply.sfGood) return; /* initialize movie toolbox */ EnterMovies(); /* open the movie file, get the movie from it, then close it */ OpenMovieFile(&getreply.sfFile, &resref, fsRdPerm); NewMovieFromFile(&themovie, resref, nil, nil, newMovieActive, nil); CloseMovieFile(resref); /* save the current resource file for later restoration */ saveref = CurResFile(); /* delete any existing PICS file, create resource file, and open it */ FSpDelete(&putreply.sfFile); FSpCreateResFile(&putreply.sfFile, 'RUNT', 'PICS', 0); outref = FSpOpenResFile(&putreply.sfFile, fsWrPerm); UseResFile(outref); /* set up some variables */ fromtime = 0; frame = 128; mediatypes[0] = VideoMediaType; /* get the first frame from the movie and save it */ /* the 0 means the very beginning of the movie */ pichand = GetMoviePict(themovie, 0); if (pichand) { AddResource((Handle)pichand, 'PICT', frame, "\p"); WriteResource((Handle)pichand); ReleaseResource((Handle)pichand); frame ++; /* increment resource id number */ } /* now get each successive frame from movie and save it */ /* the break will exit from the inifinite loop */ do { /* get the time and duration of the next video media sample in the movie */ GetMovieNextInterestingTime(themovie, nextTimeMediaSample, 1, mediatypes, fromtime, (Fixed)1L<<16, &thetime, &duration); /* if the time comes back -1, then there are no more samples; so exit loop */ if (thetime < 0) break; /* otherwise, continue to get a PICT from the movie based on /* the time returned, and save it off to the resource file */ pichand = GetMoviePict(themovie, thetime); if (pichand) { AddResource((Handle)pichand, 'PICT', frame, "\p"); WriteResource((Handle)pichand); ReleaseResource((Handle)pichand); frame ++; } /* set the search start time to the end of the last sample */ fromtime = thetime + duration - 1; } while (true); /* clean up and close down */ DisposeMovie(themovie); UpdateResFile(outref); CloseResFile(outref); UseResFile(saveref); ExitMovies(); }