Processing Library: MovieMaker

Processing Library: MovieMaker

 
//IMPORT QUICKTIME LIBRARY
import processing.video.*;
 
// QUICKTIME VARIABLES
MovieMaker theMovie;
boolean blnRecordMovie, blnStopMovie;
 
/*--------------------------------------------------------------------------------
 *** GLOBAL SETUP ***
 ---------------------------------------------------------------------------------*/
void setup() {
  //------------general
  size(800,800);
  background(0);
  //------------quicktime
  theMovie = new MovieMaker(this, width, height, "myMovie.mov",
  30, MovieMaker.ANIMATION, MovieMaker.MEDIUM);
 
  blnRecordMovie = false;
}
 
/*--------------------------------------------------------------------------------
 *** GLOBAL RUN ***
 ---------------------------------------------------------------------------------*/
void draw() {
 
  //------------add a random ellipse to the screen every N frames
  addRandomEllipse();
 
  //------------quicktime record after everything is drawn!
  if(blnRecordMovie) {
    theMovie.addFrame();
  }
}
 
 
/*--------------------------------------------------------------------------------
 *** FUNCTION -- ADD ELLIPSE ***
 ---------------------------------------------------------------------------------*/
void addRandomEllipse() {
  float posX = random(width);
  float posY = random(height);
  float rad  = random(15,35);
  int   col  = int( random(100,250) );
  noStroke();
  fill(col,0,col);
  ellipse(posX, posY, rad,rad );
}
 
 
/*--------------------------------------------------------------------------------
 *** KEYSTROKE EVENTS -- START & STOP RECORDING  ***
 ---------------------------------------------------------------------------------*/
void keyPressed() {
 
  if(key == 'r') {
    if(blnRecordMovie == false) {
      //start recording
      blnRecordMovie = true;
      println("I have STARTED recording!!!");
    }
    else {
      theMovie.finish();
      println("I have STOPPED recording!!!");
    }
  }
}

Comments are closed.