English 中文(简体)
GetNextInterestingTime() gets the same frame multiple times
原标题:
  • 时间:2010-02-01 11:02:07
  •  标签:
  • quicktime

I want to export every frame in a *.mov-Movie-File, so I do this:

GoToBeginningOfMovie(movie);
TimeValue startPoint = 0;
long gnitFrames = 0;
while (startPoint >= 0) {
    GetMovieNextInterestingTime(movie, nextTimeStep, 0, &whichMediaType, startPoint, 0, &startPoint, NULL);
    gnitFrames++;
}

the problem is, the count of gnitFrames is different (many more) than when I call this:

Track track = GetMovieIndTrack(movie, 1);
Media media = GetTrackMedia(track);
OSType mediatype;
MediaHandler mediahandler = GetMediaHandler(media);
GetMediaHandlerDescription(media, &mediatype, nil, nil);
MediaGetName(mediahandler, medianame, 0, nil);
long nsamples = GetMediaSampleCount(media);

nsamples gives me the correct frame-count. So now my question: how can I do that to get to every frame in a movie just once? (When I export the frame now after I called GetNextInterestingTime, a frame is exported multiple times, sometimes even 25 times)
My operating system is Windows XP.

最佳回答

Using nextTimeStep might be problematic as a timestep does not necessarily have to match a (video) media sample causing GetMovieNextInterestingTime() to return superfluous time stamps.

If all you want to do is to count / locate all frames in a video media, try using nextTimeMediaSample along with GetMediaNextInterestingDisplayTime() on the video Media like this:

...
TimeValue64  start           = 0;
TimeValue64  sample_time     = 0;
TimeValue64  sample_duration = -1;
int frames = 0;
while( sample_time != -1 ) {

    GetMediaNextInterestingDisplayTime( media, nextTimeMediaSample | nextTimeEdgeOK, start, fixed1, &sample_time, &sample_duration );
    if( sample_time != -1 ) {
        ++frames;
    }
    ...
    start += sample_duration;
}
...

Caveat:

According to the Q&A article below this approach is not supposed to work out for f.e. MPEG but for many other formats it works like a charm in my experience.

Technical Q&A QTMTB54: How do I count the frames in an MPEG movie?

问题回答

暂无回答




相关问题
Display MPEG-4 Export Component Dialog

Below is my code for a doc based QTKit app that exports to the fixed Apple device formats by way of a popUp that displays the three device options. The [NSNumberWithLong:mpg4 ] option works fine as ...

Quicktime Framework and opening Transport Streams

I have noticed that Quicktime 10 is now able to open Transport Stream Video files and also search reliably within that video file(Which is something that VLC can not seem to handle). Quicktime 7, on ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签