Using moviemaker class with a timer
in
Core Library Questions
•
2 years ago
Hi there, I am trying to use the capture class along with movie maker to capture feed from a webcam. I want the movie maker to record 10 seconds and then stop by the use of a timer class but I cannot get the two to gel. Any help, bit of a nebwie?
- import processing.video.*;
- Capture myCapture;
- Timer timer;
- MovieMaker mm; // Declare MovieMaker object
- void setup() {
- size(320, 240);
- frameRate(24);
- myCapture = new Capture(this, width, height);
- timer = new Timer(10000);
- timer.start();
- mm = new MovieMaker(this, width, height, "drawing.mov", 24, MovieMaker.H263, MovieMaker.HIGH);
-
- }
- void captureEvent(Capture myCapture) {
- myCapture.read();
- }
- void draw() {
- image(myCapture, 0, 0);
- mm.addFrame();
- if (timer.isFinished()) {
- mm.finish();
- }
-
- timer.start();
-
- }
and the timer class:
- class Timer {
-
- int savedTime; // When Timer started
- int totalTime; // How long Timer should last
-
- Timer(int tempTotalTime) {
- totalTime = tempTotalTime;
- }
-
- // Starting the timer
- void start() {
- // When the timer starts it stores the current time in milliseconds.
- savedTime = millis();
- }
-
- boolean isFinished() {
- // Check how much time has passed
- int passedTime = millis()- savedTime;
- if (passedTime > totalTime) {
- return true;
- } else {
- return false;
- }
- }
- }
thanks for any help, really appreciate it!
2