hi nay/zach,
it’s pretty funny, i was just poring over this issue for the last few days. i have a little code snippet that seems to work fine for static framerate videos. I tested it by setting the playback rate to something really low, then making an infinite loop that would check movie.isFrameNew() and increments a counter if it’s true. for a 3 minute clip, i had about 6000 frames (6055 actually). i also got the duration of the video and when i divided numFrames/duration, i got the standard 29.97 fps. so this was good confirmation that my video is a constant framerate. please test it and let me know!
Media movieMedia;
MediaHandler movieMediaHandler;
MovieGetVideoMediaAndMediaHandler(movieClip.moviePtr, &movieMedia, &movieMediaHandler);
Track videoTrack = GetMovieIndTrackType(movieClip.moviePtr, 1, 'vfrr', movieTrackCharacteristic | movieTrackEnabledOnly );
Media movieMedia = GetTrackMedia(videoTrack);
MediaHandler movieMediaHandler = GetMediaHandler(media);
double numFrames = GetMediaSampleCount(movieMedia);
TimeValue64 duration = GetMediaDuration(movieMedia);
TimeValue64 timeScale = GetMediaTimeScale(movieMedia);
double seconds = (double)duration/(double)timeScale;
double fps = numFrames/seconds;
I suppose if you wanted to do it for a video with nonstatic framerate, you would have to put it in a loop getting every video track and storing the length of each frame.
if your video is an mpeg, it’s much easier. you would first check:
boolean isMPEG = false;
MediaHasCharacteristic(movieMediaHandler, 'mpeg', &isMPEG);
then if it is an mpeg, all you have to do is:
MHInfoEncodedFrameRateRecord encodedFrameRate;
Size encodedFrameRateSize = sizeof(encodedFrameRate);
MediaGetPublicInfo(movieMediaHandler, kMHInfoEncodedFrameRate, &encodedFrameRate, &encodedFrameRateSize);
Fixed frameRate = encodedFrameRate.encodedFrameRate;
also, I did try GetMovieNextInterestingTime:
long frameCount = 0;
TimeValue curMovieTime;
curMovieTime = 0;
while(curMovieTime >= 0)
{
GetMovieNextInterestingTime(theMovie, nextTimeStep, 0, NULL, curMovieTime, 0, &curMovieTime, NULL);
frameCount++;
}
frameCount--; //extra timestep @ eof
however, this gave me a result of 15431, which makes little sense. maybe I’m computing it wrong, so if you guys have an idea on this one, please let me know!
thanks!
ramsin