Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / June 2005



Tip: Looking for answers? Try searching our database.

Extract frames from MOOV files using Quicktime SDK

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AhmadKQ - 28 Jun 2005 14:25 GMT
Hi,

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,
toby - 28 Jun 2005 15:26 GMT
> Hi,
>
> 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. ...

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
jollyprez - 29 Jun 2005 04:08 GMT
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.

n@lex@h@nd-off.com
toby - 29 Jun 2005 04:41 GMT
> 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.

GetMoviePict() takes care of everything - but would probably not be
optimally efficient if dealing with sequential frames.

> 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.
>
> n@lex@h@nd-off.com
AhmadKQ - 29 Jun 2005 08:05 GMT
Thaks a lot. I worked. Thanks again for your help
AhmadKQ - 29 Jun 2005 08:09 GMT
Thanks alot. It worked.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.