Re-recording video and playback

edited April 2015 in Library Questions

Hello everyone, I am new to processing but have a little experience with adruino. I am currently working on a project that will have a live stream from a webcam and will allow people to interact with the video by rewinding and fast forwarding the last 30 seconds of the 'live' footage (The interaction will take place with the audience spinning a potentiometer mapped to recorded frames, aided by arduino).

My logic is to have the live stream playing and to capture the frames using saveFrame, once 30 seconds of footage is captured (approx 720 frames) the 'recording' or saveFrame will restart saving back over the original file path and the original 720 frames - giving the program a constant 30 seconds of footage to refer to without it running out of memory.

When the audience interact with the piece they will spin the potentiometer, cycling through the frames creating a stop-motion interaction.

I am having trouble with re-recording the frames to the same file path and then accessing it again to play back and link top the potentiometer. Heres my code: import processing.video.*;

Capture cam;
float frameCount;


void setup() {
  startTime=millis();
  frameRate(30);
  size(640, 480);
  noLoop();

  String[] cameras = Capture.list();


  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }
    cam = new Capture(this, cameras[0]);
    cam.start();     
  }      
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
  saveFrame("stillFrame/" + "stillFrames-###.jpg"); 
  {
  if (frameCount == 720) {

  exit();
  }
  loop();

}

I realise that i have not gotten that far with it but and pointers in the right direction would be greatly appreciated.

I came across this code for resetting the code but cannot integrate it within my code:

// forum.processing.org/two/discussion/1725/millis-and-timer

final int WAIT_TIME = (int) (3.5 * 1000); // 3.5 seconds
int startTime;

void draw() {
  if (hasFinished()) {
    println(WAIT_TIME/1e3 + " seconds have transpired!");
    startTime = millis();
  }
}

boolean hasFinished() {
  return millis() - startTime > WAIT_TIME;
}

Any help with this would be much appreciated

edit: formatted

Sign In or Register to comment.