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

**URL:** <https://discourse.processing.org/t/how-to-capture-every-frame-of-a-video-manipulate-the-image-using-a-function-and-display-the-manipulated-frames/37747>\
**Category:** Libraries\
**Created:** [June 28, 2022, 5:16pm UTC](https://discourse.processing.org/t/how-to-capture-every-frame-of-a-video-manipulate-the-image-using-a-function-and-display-the-manipulated-frames/37747 "2022-06-28T17:16:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alalalala](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Alalalala](https://discourse.processing.org/u/Alalalala)\
**Post date:** [June 28, 2022, 5:16pm UTC](https://discourse.processing.org/t/how-to-capture-every-frame-of-a-video-manipulate-the-image-using-a-function-and-display-the-manipulated-frames/37747/1 "2022-06-28T17:16:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 28, 2022, 6:15pm UTC](https://discourse.processing.org/t/how-to-capture-every-frame-of-a-video-manipulate-the-image-using-a-function-and-display-the-manipulated-frames/37747/2 "2022-06-28T18:15:12Z")

</div>

Hi @Alalalala ,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 29, 2022, 2:20am UTC](https://discourse.processing.org/t/how-to-capture-every-frame-of-a-video-manipulate-the-image-using-a-function-and-display-the-manipulated-frames/37747/3 "2022-06-29T02:20:03Z")

</div>

Hello @Alalalala,

I found these tutorials to be helpful:

> **[Video](https://processing.org/tutorials/video/)**
>
> How to display live and recorded video.

> **[Images and Pixels](https://processing.org/tutorials/pixels/)**
>
> How to load and display images as well as access their pixels.

Along with the examples.

`:)`
