Video Slicer

Here is a program written in Processing that takes a video, renders the individual frames, adds an effect, and then plays it back. 

I wrote this to effect videos using two different timelines.

Playback is super sticky. :(

 
import processing.video.*;
Movie video;
PImage[] frames = new PImage[10];

//////////////////////////////////////////////////////////////////////////////////

void setup(){
  size(1280, 720);
  frameRate(frames.length);
  
  video = new Movie(this, "suprise720.mov");
  video.play();
}

//////////////////////////////////////////////////////////////////////////////////

void draw(){
 
 if(frameCount < frames.length){ 
    display();
    recordFrame();
 }
 else{
   
   load();
   if(keyPressed && key == ENTER){
     load();
     effect();
     display();
     recordFrame();
   }
   display();
 } 
}

//////////////////////////////////////////////////////////////////////////////////

void movieEvent(Movie m){
 m.read(); 
}

void display(){
  if(frameCount >= frames.length){
    int i = frameCount % frames.length;
      image(frames[i], 0, 0);
      //println(i);
  }
   else {
     image(video, 0, 0);
   }
}

void recordFrame(){
  String frameName = "frame - " + nf((frameCount % frames.length), 2) + ".jpg";
    
  saveFrame("/Users/Kman/Documents/Processing/rouletteVideo/data/"+frameName);
}

void load(){
  for(int i = 0; i < frames.length; i++){
      String frameName = "frame - " + nf(i+1, 2) + ".jpg";
      
      frames[i] = loadImage("/Users/Kman/Documents/Processing/rouletteVideo/data/"+frameName);
      //println(frameName);
  }
}


void effect(){
  
  for(int i = 0; i < frames.length; i++){
    PImage currentImage = frames[i];
    
    currentImage.loadPixels();
    
    for(int j = 100*width; j < width * 150; j++){
      currentImage.pixels[j] = currentImage.pixels[j+50];
    }
    for(int j = 200*width; j < 300*width; j++){
      currentImage.pixels[j] = currentImage.pixels[j+150];
    }
    for(int j = 450*width; j < 600*width; j++){
      currentImage.pixels[j] = currentImage.pixels[j+100];
    }

    currentImage.updatePixels();
  }
}