problem with a dynamic mask over a video

edited May 2014 in Questions about Code

I use this code wich is actually working exept that at random time i see a flash of the full-frame of my video (non masked) someone can explain me why?

import processing.video.*;
Movie myMovie;

PGraphics gBuffer;
void setup() {
  size(1280, 720);
  myMovie = new Movie(this, "mifo.mov");
  myMovie.loop();
  gBuffer = createGraphics( width, height);
}

void draw() {
    background(0);
  gBuffer.beginDraw();
  gBuffer.background(0);//clear the mask
  gBuffer.fill(255);
  gBuffer.ellipse(mouseX,mouseY,250,250);//draw a new circle
  gBuffer.endDraw();
  myMovie.mask(gBuffer);//apply the mask to the image
  image(myMovie, 0, 0);
}

void movieEvent(Movie m) {
  m.read();  
}

Comments

  • Please format your code by highlighting it and pressing Ctrl+K

  • This is because the movieEvent function is firing at a different rate than the draw loop. It causes a bit of skipping, but if you delete the movieEvent function and do myMovie.read() in the draw loop this problem is resolved.

Sign In or Register to comment.