Extract frames from MOOV files using Quicktime SDK

有时间再翻译一下

 

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值