We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Measuring frame rate (Read 483 times)
Measuring frame rate
Feb 17th, 2010, 6:33pm
 
What I really want to do is be able to select individual frames in a movie, but the threads I've read suggest that's not possible.  So the closest I can get is to divide the frame I want by the frame rate and jump to that time code.

There doesn't seem to be a way of requesting the frame rate (setting it doesn't seem override whatever the file believes) and I want to save the manual work of opening the movie in QT and looking up the frame rate manually, so I thought I could measure it doing something like this:
Code:
x=theMovie.time();
for(i=0;i<j;i++)
 {
   theMovie.read();
 }
println("Average spf: " + (theMovie.time()-x)/j );


Turns out I get very different numbers depending on the value of j, even when j is in the hundreds.  Furthermore, I get different results when I run the exact same code multiple times.

I figured it was because the frame loading is async to the control thread, so I tried changing the inner loop to:
Code:
theMovie.read();while(!(theMovie.available())); 



That just looped forever.  Looking at the reference material for "while" it seems to imply that nothing else happens outside the while loop while the loop is executing.

Finally, I figured I'd try this:
Code:
theMovie.read();while(!(theMovie.available())){delay(1);}; 


and I'm still having no luck-- delay appears to seize all cycles, not yield to other processes.

How do I handle this?
Page Index Toggle Pages: 1