As most of the questions starts: I'm a total processing-n00b and I'd like some help from you all plz.
I'm in a situation, doing a project, and I want to make an application that records from the webcam for about 15 seconds, then stops recording and saves the recording, then replays the recording in the application? Is it possible? Where do I begin if so?
I've read something about the MovieMaker library(??), but can't find any good tutorials or such. Tried to make something with this codes if it's any help:
/**
* Saving Frames example
* by Daniel Shiffman.
*
* This example demonstrates how to use saveFrame() to render
* our an image sequence that you can assemble into a movie
* using the MovieMaker tool.
*/
import processing.video.*;
Capture cam;
int begin;
int duration;
int time;
// A boolean to track whether we are recording are not
boolean recording = false;
void setup() {
size(640, 480);
smooth();
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]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam = new Capture(this, cameras[0]);
cam.start();
}
begin = millis();
time = duration = 20;
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
// If we are recording call saveFrame!
// The number signs (#) indicate to Processing to
// number the files automatically
if (recording) {
saveFrame("output/frames####.png");
}
// Let's draw some stuff to tell us what is happening
// It's important to note that none of this will show up in the
// rendered files b/c it is drawn *after* saveFrame()
textAlign(CENTER);
fill(255);
if (!recording) {
text("Press R to start recording.", width/2, height-24);
}
else {
text("Press R to stop recording.", width/2, height-24);
}
// A red dot for when we are recording
stroke(255);
if (recording) fill(255, 0, 0);
else noFill();
ellipse(width/2, height-48, 16, 16);
if (time > 0) time = duration - (millis() - begin)/1000;
text(time, 80, 80);
}
void keyPressed() {
// If we press r, start or stop recording!
if (key == 'r' || key == 'R') {
recording = !recording;
begin = millis();
time = duration;
}
}
So what I've got so far is a webcam recording, although it saves a lot of snapshots, and a timer..?