why does not work? sampling
in
Core Library Questions
•
11 months ago
Hi,
when i run this code i have written,
it goes for a while then it freezes on one frame (usually 1 or 50) of the sampled video (Untitled.mov)...
I cannot understand where is the error.
It would be great if someone could help me!
It's a very simple code... when fCount arrives to frame 50 the speed is inverted (-) and changed (randomically). When it arrives another time to 1 the speed becomes (+) and change another time and so on... It should be like a cycle but at some point it freezes!
This is the code
- import processing.video.*;
- Movie myMovie;
- int fCount = 0;
- int fr = 25;
- int firstRun = 1;
- float chooseSpeed=1.0;
- int choice = 0;
- void setup() {
- size(320, 240);
- myMovie = new Movie(this, "Untitled.mov");
- myMovie.loop();
- }
- void draw() {
- if(fCount>49){
- choice = 1;
- chooseSpeed = random(-5.0,-0.5);
- }
- //firstRun checks if this is the first time that draw runs
- else if(fCount == 1 && firstRun != 1){
- choice = 0;
- chooseSpeed = random(0.5,5.0);
- }
- if(choice == 0){
- fCount++;
- }
- else if(choice == 1){
- fCount--;
- }
- frameRate(int(abs(chooseSpeed)*fr));
- myMovie.speed(chooseSpeed);
- if (myMovie.available()) {
- myMovie.read();
- }
- image(myMovie, 0, 0);
- firstRun = 0;
- //debug
- print(fCount);
- print(" ");
- print(chooseSpeed);
- print(" ");
- print(choice);
- print("\n");
- }
Thanks
1