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
how to delay a video? (Read 312 times)
how to delay a video?
Sep 17th, 2008, 11:22pm
 
Hi everyone!

I just been playing with video in processing to make something bigger I have in mind.

The thing is I could delay somehow the video saving everything as a picture and then playing it again but my first implementation, saving every cam frame into a PImage does not work! and I dont know why. I just save all the first 300 frames into PImage array and then when trying to play it I get the normal video instead the delayed one.

Another question is about which implementation would work better, saving everything as files or in memory? I have in mind maybe working with hd video, so perhaps is going to be a bit too much having everything in the memory, isnt it?

So about the file version is there any way of just saving the cam frames into files instead of the whole window content with saveFrame?

Here it is the code

Thanks everyone!

Quote:


import processing.video.*;

Capture cam;
PImage[] img;

int i = 0;
int q = 0;

void setup() {
 size(640, 240);
 cam = new Capture(this, 320, 240);
 frameRate(30);
 
 img = new PImage[301];
}


void draw() {
   cam.read();
   image(cam, 0, 0);

   //store the image in the buffer
   if (i < 300) {
     img[i++] = cam;
     //saveFrame("imagen###.jpg");
   }
   //play the buffer
   else {
     //image(img[q++], 320, 0);
     println("imagen" + nf(q++ + 1, 3) +".jpg");
     //image(loadImage("imagen" + nf(q++ + 1, 3) +".jpg"), 320, 0);
     
     if (q > 300 - 1) i = q = 0;
   }  
}

Page Index Toggle Pages: 1