Skip to content

Instantly share code, notes, and snippets.

@chasemarangu
Created April 23, 2020 21:42
Show Gist options
  • Save chasemarangu/516613198ea5188c5e4535e7b6a503c8 to your computer and use it in GitHub Desktop.
Save chasemarangu/516613198ea5188c5e4535e7b6a503c8 to your computer and use it in GitHub Desktop.
// Video to Frames
// C010011012 (@cmarangu) 2020 3/10
// can use with my rollingshutter.pde
import java.util.ArrayList;
import processing.video.*;
ArrayList<PImage> imgs;
Movie mov1;
int C = 0;
void setup() {
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
// SET BELOW TO WIDTH AND HEIGHT OF YOUR VIDEO
size(500, 500);
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
// SET "example.mp4" TO NAME OF YOUR VIDEO
mov1 = new Movie(this, "example.mp4");
imgs = new ArrayList<PImage>();
//mov1.loop();
mov1.frameRate(0.01);
mov1.speed(0.5);
mov1.jump(0);
mov1.play();
}
void draw() {
// if (mov1.availible()) {
if (C < imgs.size()) {
image(imgs.get(C), 0, 0);
C++;
C %= imgs.size();
}
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
m.read();
PImage fraem = mov1.get();
imgs.add(fraem);
// set filename - c followed by exactly 5 digits including trailing zeros
// then extension
String num = ""+(imgs.size()-1);
while (num.length() < 5) {
num = "0"+num;
}
num = "c"+num;
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
// UNCOMMENT BELOW LINE TO SAVE FRAMES (in png or other)
//fraem.save("saved/"+num+".png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment