# Video Pixels Changing While I Process Them

**URL:** <https://discourse.processing.org/t/video-pixels-changing-while-i-process-them/32589>\
**Category:** Libraries\
**Created:** [October 3, 2021, 6:06pm UTC](https://discourse.processing.org/t/video-pixels-changing-while-i-process-them/32589 "2021-10-03T18:06:46Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 5, 2021, 7:18pm UTC](https://discourse.processing.org/t/video-pixels-changing-while-i-process-them/32589/10 "2021-10-05T19:18:05Z")

</div>

```auto
/**
 * Synchronized Pixels Capture (1.0.0)
 * GoToLoop (2021-Oct-05)
 * Discourse.Processing.org/t/video-pixels-changing-while-i-process-them/32589/10
 */

import processing.video.Capture;

Capture cam;
PImage frame;

void setup() {
  size(640, 480);
  frame = get();

  cam = new Capture(this, width, height, "pipeline: autovideosrc");
  cam.start();
}

void draw() {
  surface.setTitle("Frame: " + frameCount + " FPS: " + round(frameRate));

  synchronized (frame) {
    background(frame);
  }
}

void captureEvent(final Capture c) {
  c.read();

  final color[] pix = frame.pixels;
  final int len = pix.length;

  c.loadPixels();

  synchronized (frame) {
    arrayCopy(c.pixels, pix);

    for (int i = 0; i < len; pix[i++] ^= ~PImage.ALPHA_MASK);

    frame.updatePixels();
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/video-pixels-changing-while-i-process-them/32589)._
