/** * Frames. * by Andres Colubri * * Moves through the video one frame at the time by using the * arrow keys. */ import codeanticode.gsvideo.*; GSMovie myMovie; int newFrame = 0; PFont font; void setup() { size(1920, 1080); background(0); // Load and set the video to play. Setting the video // in play mode is needed so at least one frame is read // and we can get duration, size and other information from // the video stream. // myMovie = new GSMovie(this, "station.mov"); // myMovie = new GSMovie(this, "/Volumes/external/tera/Assets/Memory/20080630 930pm - breaking up with nichol/MOV09976.MPG"); myMovie = new GSMovie(this, "/Volumes/Reservoir/Assets/dxarts/00001.MTS"); myMovie.play(); font = loadFont("DejaVuSans-24.vlw"); textFont(font, 24); } void movieEvent(GSMovie myMovie) { myMovie.read(); } void draw() { if (1 < myMovie.width && 1 < myMovie.height) { if (newFrame != myMovie.frame()) { // println(myMovie.length()); // The movie stream must be in play mode in order to jump to another // position along the stream. Otherwise it won't work. myMovie.play(); myMovie.jump(newFrame); myMovie.pause(); } image(myMovie, 0, 0, width, height); fill(240, 20, 30); text(myMovie.frame() + " / " + (myMovie.length() - 1), 10, 30); // println(newFrame+ " " +myMovie.frame()); } } void keyPressed() { if (key == CODED) { if (keyCode == LEFT) { if (0 < newFrame) newFrame--; } else if (keyCode == RIGHT) { if (newFrame < myMovie.length() - 1) newFrame++; } } }