有时间再翻译一下
I am using Quicktime SDK 6. I want to extract and decompress the frames
from the mov files. Currently, i am able to get the media samples using
GetMediaSample function from the mov file but it is compressed data.
How can i decompress that sample data. Do i have to use DecompressImage
function? If yes, then how can i get the ImageDescriptionHandle
parameter.
This is the part of my code
strcpy(szFileName, "c://test.mov");
// Convert pathname and make FSSpec
oErr = NativePathNameToFSSpec(szFileName, &fss, 0);
// Open movie file
oErr = OpenMovieFile(&fss, &nFileRefNum, fsRdPerm);
oErr = NewMovieFromFile(&movie, nFileRefNum, nil, nil, newMovieActive,
nil);
lTrackCount = GetMovieTrackCount(movie);
theTrack = GetMovieIndTrack(movie, 1);
theMedia = GetTrackMedia(theTrack);
lDuration = GetMediaDuration(theMedia);
lMaxSize = GetMediaDataSize(theMedia, 0, lDuration);
outdata = NewHandle(lMaxSize);
GetMediaHandlerDescription(theMedia, &mediaType, nil, nil);
if (mediaType == VideoMediaType)
{
for (i = 0; i < lDuration; i++)
{
oErr = GetMediaSample(theMedia, outdata, lMaxSize, &lSize, i,
&st, &dps, nil, &sampleDescriptionIndex,
1, &numberOfSamples, &sampleFlags);
}
DisposeHandle(outdata);
}
Thanks,
Here's one way,
if(pich = GetMoviePict(srcMovie,((TimeValue*)*frames)[theframe])){
bounds = gStuff->theRect;
if( !(e = NewGWorld(&gw,32,&bounds,NULL,NULL,0)) ){
CGrafPtr port;
GDHandle gdh;
if(LockPixels(pm = GetGWorldPixMap(gw))){
GetGWorld(&port,&gdh);
SetGWorld(gw,NULL);
DrawPicture(pich,&bounds);
SetGWorld(port,gdh);
gStuff->data = GetPixBaseAddr(pm);
gStuff->rowBytes = GetPixRowBytes(pm);
// ...
}else e = QDError();
}
KillPicture(pich);
}else e = GetMoviesError();
Where ((TimeValue*)*frames)[] are the frame times obtained like so:
for( f = 0, theTime = 0 ; theTime != -1 ; ++f ){
GetMovieNextInterestingTime(m,f ? nextTimeMediaSample :
nextTimeMediaSample|nextTimeEdgeOK,
1,&whichMediaType,theTime,0,&theTime,NULL);
((TimeValue*)*frames)[f] = theTime;
}
This code is from a Photoshop plugin to read movie frames:
http://www.telegraphics.com.au/svn/qtmovie/trunk/read.c
--Toby
Nah, you're going to want to use a decompression session. This is
because in most codecs - all the MPEG's, H263 & H264, etc., you're
dealing with only partial information. The frames have to be assembled
from previous frames - except for key frames. In the case of H264, you
might even enounter subsequent frames to help assemble an entire usable
frame.
Personally, I find decompression sessions to be a pain, but don't know
any way around it for what you want to do. The get movie poster idea
above *might* be sufficient, I don't know - haven't tried that.
GetMoviePict() takes care of everything - but would probably not be
optimally efficient if dealing with sequential frames.