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
Video delay 30 seconds (Read 1195 times)
Video delay 30 seconds
Sep 14th, 2009, 10:20am
 
Hi, I found this code in another topic at this forum for delaying captured video.

The only problem is that I don't know how or where to put the parameters I want. I would like to have a 30 seconds delay.

Can someone please help me?

And, is there a way to decide how much of the captured data that is to be stored on my computer?

Best, Celia
--------------------

import processing.video.*;
Capture maCam;
VideoBuffer monBuff;

void setup() {
size(320,240);
maCam = new Capture(this, width, height, 30);
monBuff = new VideoBuffer(30, 320, 240);
}

void captureEvent(Capture maCam) {
maCam.read();
monBuff.addFrame( maCam );
}

void draw() {
image( monBuff.getFrame(), 100, 100 );
image( maCam, 0, 0 );
}

 
class VideoBuffer
{
 PImage[] buffer;
 
 int inputFrame = 0;
 int outputFrame = 0;
 int frameWidth = 0;
 int frameHeight = 0;
 
 /*
   parameters:

   frames - the number of frames in the buffer (fps * duration)
   width - the width of the video
   height - the height of the video
 */
 VideoBuffer( int frames, int width, int height )
 {
   buffer = new PImage[frames];
   for(int i = 0; i < frames; i++)
   {
     this.buffer[i] = new PImage(width, height);
   }
   this.inputFrame = frames - 1;
   this.outputFrame = 0;
   this.frameWidth = width;
   this.frameHeight = height;
 }

 // return the current "playback" frame.  
 PImage getFrame()
 {
   return this.buffer[this.outputFrame];
 }
 
 // Add a new frame to the buffer.
 void addFrame( PImage frame )
 {
   // copy the new frame into the buffer.
   System.arraycopy(frame.pixels, 0, this.buffer[this.inputFrame].pixels, 0, this.frameWidth * this.frameHeight);
   
   // advance the input and output indexes
   this.inputFrame++;
   this.outputFrame++;

   // wrap the values..    
   if(this.inputFrame >= this.buffer.length)
   {
     this.inputFrame = 0;
   }
   if(this.outputFrame >= this.buffer.length)
   {
     this.outputFrame = 0;
   }
 }  
}
Re: Video delay 30 seconds
Reply #1 - Sep 14th, 2009, 3:35pm
 
this is weird ill look into it
Re: Video delay 30 seconds
Reply #2 - Sep 15th, 2009, 12:11am
 
great. This is the thread where I found the code(s):
Topic: Real-time Video Delay

(I am  not allowed to post links yet...)
-but this is the last part of the webstring:

/yabb2/?board=Video%3Baction=display%3Bnum=1159143757
Re: Video delay 30 seconds
Reply #3 - Sep 15th, 2009, 5:19am
 
Solution found! thanx
Page Index Toggle Pages: 1