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
Processing frames within a video (Read 351 times)
Processing frames within a video
Mar 19th, 2009, 4:43pm
 
Hi
I'm kind of new to this and i'm trying to perform some analysis on the frames of some videos. It seems to me that the video jumps some of the frames being analysed, and that i can't control the rate at wich the events appear. The movieEvent() simply is much more quicker than the process that i want to do on the frames. I don't mind getting the video more slowly, the computation i do on each frame slows the video. What i can't get is how can i control the movieEvent to only give a frame after i finished processing the previous frame.

My code looks like this:

void movieEvent(Movie myMovie) {
 if(state == 1){
   myMovie.read();
   //if the movie ends change the state to finishProcess
   if(myMovie.duration() <= myMovie.time()){
     state = 2;
     theFrames++;
     myMovie.stop();
   }
   loop();
 }
}//movieEvent

void draw(){
 switch(state){
 case 0:
   //waiting state
   waiting();
   break;
 case 1:
   //processing state
   processVideo();
   break;
 case 2:
   //finishing state
   finishProcess();
   break;
 }
}//draw

//Does a number of operations on each frame of the movie
void processVideo(){
 if(myMovie.available()){
   myMovie.read();
   //...
   //all sorts of operations here
   //...
 }
}//processVideo

I always get more movie events than processing cycles and it seems that he skips some of them. I also tried slowing down the movie.speed() and it produces diferent results but i can't get all the frames again. For instance an eight second video at 25 fps should have 200 frames to process but i can never achieve that number. Also in Mac OS X it seems this problem is more visible than Windows XP (might be because of the computer instead of the OS). If anyone knows something about this i appreciate any help i can get.
Page Index Toggle Pages: 1