Empty pixels array when playing a movie

Hi there,

I’m trying to mess with some video using Processing, but I get an error whenever I try to use video.pixels, even after doing video.loadPixels()

import processing.video.*;
Movie video;

void setup() {
loadPixels();
video = new Movie(this, “peter.mov”);
video.play();
video.loadPixels();
int n = video.pixels[0];

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

ArrayIndexOutOfBoundsException: 0

Why is this? does it have something to do with the video format?

A Movie object needs some couple of seconds after the 1st play() call to be properly ready. :film_projector:

As a workaround you can continuous poll its width or height fields while () they’re still 0 w/ the help of delay(): :bulb:

while (video.height == 0) delay(10);

1 Like

Thank you very much!

Thanks for clarifying that. Was driving me nuts. :slight_smile:

1 Like