How to capture every frame of a video, manipulate the image using a function, and display the manipulated frames?

I was looking at the examples in the video library and there is an example that lets you control the video by pressing arrow keys and navigating per frame

Is there a way i can store the frame as an image, obtain the color of each pixel from it, then manipulate it off screen using PGraphics and display the manipulated frames instead of the normal frames so it plays like a movie but using the frames ive created?
eg, If i apply a basic pixelsorting algo on each frame and play the movie?

Is that possible? How do i make it not very heavy? Is there an easier way to get access to the pixels of a video and manipulate them either in the video itself or in the individual frames?

1 Like

Hi @Alalalala ,

You can easily use the pixels buffer of the Movie object.
ie:

import processing.video.*; 

Movie myMovie; 

void setup() { 
  size(200, 200); 
  myMovie = new Movie(this, "video.avi");
  myMovie.loop(); 
}

void draw() { 
background (0);

if (myMovie.available()) {
    myMovie.read();
    myMovie.loadPixels();
    for (int i=0; i < myMovie.pixels.length; i++) {
       int cs = myMovie.pixels[i];
       // Switch blue and red
       int ct = color(blue(cs), green(cs), red(cs));
       myMovie.pixels[i] = ct;
    }
    myMovie.updatePixels();
}
image(myMovie,0, 0); 
} 

Cheers
----mnse

Hello @Alalalala,

I found these tutorials to be helpful:

Along with the examples.

:)