# Tuio framework and movie with alpha channel

**URL:** <https://discourse.processing.org/t/tuio-framework-and-movie-with-alpha-channel/42644>\
**Category:** Libraries\
**Created:** [August 22, 2023, 2:42pm UTC](https://discourse.processing.org/t/tuio-framework-and-movie-with-alpha-channel/42644 "2023-08-22T14:42:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrblade](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mrblade](https://discourse.processing.org/u/mrblade)\
**Post date:** [August 22, 2023, 2:42pm UTC](https://discourse.processing.org/t/tuio-framework-and-movie-with-alpha-channel/42644/1 "2023-08-22T14:42:18Z")

</div>

hi, i am new in this world.  
i use Tuio library.  
when a marker goes out then an effect starts in a video loop.  
A video flip and an addition of a mask with alpha channel. But this is not seen. I think it’s a problem on:  
image(overlayVideo, 0, 0); but I’m not sure.  
Can some good soul check and fix the code? thanks!!

```auto
import TUIO.*;
import processing.video.*;

TuioProcessing tuioClient;

boolean showOverlay = false;
boolean flipVideo = false;
boolean videoLoaded = false;
Movie video;
Movie overlayVideo;

void setup() {
  size(600, 352);
  frameRate(30);

  video = new Movie(this, "movie.mov");
  overlayVideo = new Movie(this, "overlay.mov");

  tuioClient = new TuioProcessing(this);

  video.loop();
  overlayVideo.loop();
  
}

void movieEvent(Movie video) {
  video.read();  
}
void movieEvent2(Movie overlayVideo) {
  overlayVideo.read();
}

void draw() {
  
  background(0);
  loadPixels();
  video.loadPixels();
  overlayVideo.loadPixels();

 if (showOverlay) {
    PImage overlayVideo = video.get(); // Create a copy of the video frame
    overlayVideo.mask(video); // Apply overlay as a mask
      image(overlayVideo, 0, 0); // Display masked video
  } 
    
  if (flipVideo) {
    video.pixels = flipPixels(video.pixels);
  }
  
 image(video, 0, 0);
 image(overlayVideo, 0, 0);
  
  video.updatePixels();
 
}

int[] flipPixels(int[] pixels) {
  int[] flippedPixels = new int[pixels.length];
  int width = video.width;

  for (int y = 0; y < video.height; y++) {
    for (int x = 0; x < video.width; x++) {
      flippedPixels[y * width + x] = pixels[y * width + (width - x - 1)];
    }
  }

  return flippedPixels;
}

void addTuioObject(TuioObject tobj) {
  println("Marker aggiunto: " + tobj.getSymbolID());
  if (tobj.getSymbolID() == 0) {
    showOverlay = false;
  } else if (tobj.getSymbolID() == 1) {
    flipVideo = false;
  }
}

void removeTuioObject(TuioObject tobj) {
  println("Marker rimosso: " + tobj.getSymbolID());
  if (tobj.getSymbolID() == 0) {
    showOverlay = true;
  } else if (tobj.getSymbolID() == 1) {
    flipVideo = true;
  }
}

void updateTuioObject(TuioObject tobj) {
  println("Marker aggiornato: " + tobj.getSymbolID());
}

void keyPressed() {
  if (key == 'r' || key == 'R') {
    tuioClient.stop();
    tuioClient = new TuioProcessing(this);
    tuioClient.stop();
  }
}

void stop() {
  video.stop();
  video.dispose();
  overlayVideo.stop();
  overlayVideo.dispose();
  tuioClient.stop();

  super.stop();
}

```
