Hi,
I’m trying to access the current frame number from a playing movie. I want to set an object position on the screen according to the frame number. I am using the quicktime API.
So far I have this :
void CMApp::update()
{
// We get the current frame
Media movieMedia = NULL;
Track videoTrack = GetMovieIndTrackType(
m_Movie.moviePtr, 1, 'vfrr',
movieTrackCharacteristic | movieTrackEnabledOnly);
if (videoTrack != NULL)
movieMedia = GetTrackMedia(videoTrack);
else
printf("error: failed to get media track");
long sampleNum;
TimeValue time;
MediaTimeToSampleNum( movieMedia,
GetMovieTime(m_Movie.moviePtr, nil),
&sampleNum,
nil,
nil);
// We update the object position according to the frame number
// ...
m_Movie.idleMovie();
}
This code doesn’t work for all my movie files. When it’s not working, MediaTimeToSampleNum always return 1. My .mov files are PCM encoded.
Perhaps there a better way to do this. I notice there will be a getCurrentFrame method in OpenFrameworks release 006. Is it possible to see how it’s gone work ?
Thanks!
Guils