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.
IndexProgramming Questions & HelpPrograms › Low Framerate on Movies
Page Index Toggle Pages: 1
Low Framerate on Movies (Read 1512 times)
Low Framerate on Movies
May 26th, 2009, 2:27am
 
Hey there
I've a big problem with my Processing and displaying movies.
When I display them the framerate is very low(like 13 frames) and the sound plays the normal speed. I'm new in Processing so please help! And sorry for my bad english Wink

Here's my programm:

import processing.serial.*;
import processing.video.*;
import cc.arduino.*;

Arduino arduino;
Movie movie;
Movie movie2;

void setup() {
 size(320, 132);
 arduino = new Arduino(this, Arduino.list()[0], 115200);
 movie = new Movie(this, "/Users/tdiesterweg/Desktop/data/terminator.mov");
 movie2 = new Movie(this, "/Users/tdiesterweg/Desktop/data/station.mov");
 movie.loop();
 movie2.loop();
 
 for (int i = 0; i <= 13; i++)
   arduino.pinMode(i, Arduino.INPUT);
}
void draw() {
 background(0);
 
 for (int i = 0; i <= 13; i++) {
   if (arduino.digitalRead(13) == Arduino.HIGH){
     image(movie,0,0);
   }else{
     image(movie2,0,0);
   }
 }
}

I hope you can help me as quick as a flash!
Re: Low Framerate on Movies
Reply #1 - May 26th, 2009, 4:42am
 
I have no experience of playing movies but if I look at play() reference, I see there is a movieEvent callback function which seems to be missing from your code.
Beside, I don't see why you draw 14 times each movie image, even less as the result will be displayed only at the end of draw().
Re: Low Framerate on Movies
Reply #2 - May 26th, 2009, 5:00am
 
I must use loop(); because these movies must be played in a loop Wink and I dont draw each image 14 time... it's just a part of handle with arduino, an extern hardware.
Teach me if i'm wrong
Re: Low Framerate on Movies
Reply #3 - May 26th, 2009, 7:05am
 
Right, that's loop(), not play(), but both need the movieEvent to call read() (if I believe the reference).

And you do call image() in the for loop, for each iteration.
Re: Low Framerate on Movies
Reply #4 - May 26th, 2009, 7:31am
 
How to do? I don't know where I must insert this... Sad when I put it before "image(movie,0,0);" there are less frames than before
Re: Low Framerate on Movies
Reply #5 - May 26th, 2009, 9:21am
 
As PhiLho mentioned, you will need movieEvent() to update the frames.
Code:
void movieEvent(Movie myMovie) {
myMovie.read();
}
Add that as a separate method to your sketch. You will not have to call it in your code.

You can see an example of this here:
http://processing.org/learning/libraries/loop.html
Or included in processing. Smiley
Re: Low Framerate on Movies
Reply #6 - Jun 2nd, 2009, 1:36am
 
There is a low framerate anyway Sad
Re: Low Framerate on Movies
Reply #7 - Jun 2nd, 2009, 2:12am
 
Have you fixed the for loop?
Re: Low Framerate on Movies
Reply #8 - Jun 2nd, 2009, 2:39am
 
fixed? i just insert
void movieEvent(Movie movie, Movie movie2) {
 movie.read();
 movie2.read();
}
thats the one and only i fixed....
Re: Low Framerate on Movies
Reply #9 - Jun 2nd, 2009, 3:17am
 
Then no wonder it is still slow. I wrote you draw each frame (call on image()) 14 times on each draw() call. Fix that and you will see it running at normal speed. The loop is useless anyway as you don't use its index.
Re: Low Framerate on Movies
Reply #10 - Jun 2nd, 2009, 3:43am
 
import processing.serial.*;
import processing.video.*;
import cc.arduino.*;

Arduino arduino;
Movie movie;
Movie movie2;

void setup() {
 size(320, 132);
 arduino = new Arduino(this, Arduino.list()[0], 115200);
 movie = new Movie(this, "/Users/tdiesterweg/Desktop/data/terminator.mov");
 movie2 = new Movie(this, "/Users/tdiesterweg/Desktop/data/station.mov");
 movie.loop();
 movie2.loop();
 
 for (int i = 0; i <= 13; i++)
   arduino.pinMode(i, Arduino.INPUT);
}
void movieEvent(Movie movie, Movie movie2) {
 movie.read();
 movie2.read();
}
void draw() {
 background(0);
 
   if (arduino.digitalRead(13) == Arduino.HIGH){
     image(movie,0,0);
   }else{
     image(movie2,0,0);
   }
}
I'm too stupid to run the movie in normal speed. Please edit my code. I'm new in processing so I don't know how to do -.- I'm realy sorry for this!
Re: Low Framerate on Movies
Reply #11 - Jun 2nd, 2009, 4:16am
 
I can't test, I have no Arduino nor your movies.
You made the change I expected. You don't see any improvement?
Re: Low Framerate on Movies
Reply #12 - Jun 2nd, 2009, 4:20am
 
No I don't Sad if I run the movie on Quicktime there is the normal framerate... so it isn't the movie or the machine.
Re: Low Framerate on Movies
Reply #13 - Jun 2nd, 2009, 6:09am
 
Actually, I just saw your movieEvent() is incorrect, it will never be called.
You should have used the routine as given by NoahBuddy: the method is designed to be called by the library, and that's the myMovie parameter which tells which movie sent the event and must be read().

Frankly, I don't know if it makes any different, but it is worth a try.

Also I don't know if the digitalRead() call can take some time or not. You might try and sample less frequently the hardware, just in case (separate the tests!).
Example:
Code:
Arduino arduino;
Movie[] movies = new Movie[2];
int movieToPlay;

void setup() {
size(320, 132);
arduino = new Arduino(this, Arduino.list()[0], 115200);
movies[0] = new Movie(this, "/Users/tdiesterweg/Desktop/data/terminator.mov");
movies[1] = new Movie(this, "/Users/tdiesterweg/Desktop/data/station.mov");
for (int i = 0; i < movies.length; i++)
movies[i].loop();

for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
}
void movieEvent(Movie movie) {
movie.read();
}
void draw() {
background(0);

if (frameCount % 10 == 0) { // Check every 10 frames
if (arduino.digitalRead(13) == Arduino.HIGH){
movieToPlay = 0;
}else{
movieToPlay = 1;
}
}
image(movies[movieToPlay], 0, 0);
}

Obviously not tested...
Re: Low Framerate on Movies
Reply #14 - Jun 2nd, 2009, 6:33am
 
Thank you for your help but it doesn't work Sad
Page Index Toggle Pages: 1