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
Dynamic naming (Read 515 times)
Dynamic naming
Nov 27th, 2007, 11:46pm
 
Hey there!
I'm trying to set up a system that will record a webcam and cut it every 10 seconds with a new file name and then stream that new file in. At the moment it will only make one clip that is called 0.mov and will not progress to the next increment. At the moment it makes the file based on a keypress. Any help is appreciated.

import processing.video.*;

Capture cam;
MovieMaker mm;  // Declare MovieMaker object
int clipcount = 0;
void setup() {
 size(640, 480);
 cam = new Capture(this, 320, 240);
  mm = new MovieMaker(this, width, height, ""+clipcount+".mov",
                      30, MovieMaker.H263, MovieMaker.HIGH);
 background(204);
}


void draw() {
 if (cam.available() == true) {
   cam.read();
   image(cam, 160, 100);
 mm.addFrame();  // Add window's pixels to movie
 }
}        
void keyPressed() {
 if (key == ' ') {

   mm.finish();  // Finish the movie if space bar is pressed!
   clipcount = clipcount + 1;
 }
}
Re: Dynamic naming
Reply #1 - Nov 28th, 2007, 9:10am
 
Ok, with millis() you've got the milliseconds since starting an applet. 10.000 milliseconds are 10 seconds, so every time millis()%10.000 = 0, 10 seconds are gone.

Instead of your keyPressed function at an if-statement to your draw function like this:

Code:


if(millis()%10000==0){
mm.finish();
mm = new MovieMaker(this, width, height, ""+clipcount+".mov", 30, MovieMaker.H263, MovieMaker.HIGH);
clipcount++;
}

Re: Dynamic naming
Reply #2 - Nov 28th, 2007, 10:38pm
 
ok wicked!

now lets say I want to load these streams back into the player. would i be able to apply certain behaviors to them to make them react to eachother? what i mean is, im having trouble understanding how to give objects certain rules as they load in. my goal is to have these video files load in and as they collide with eachother they get smaller and change direction.
Page Index Toggle Pages: 1