# Empty pixels array when playing a movie

**URL:** <https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235>\
**Category:** Libraries\
**Created:** [September 30, 2020, 10:24am UTC](https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235 "2020-09-30T10:24:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![protagoras](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@protagoras](https://discourse.processing.org/u/protagoras)\
**Post date:** [September 30, 2020, 10:24am UTC](https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235/1 "2020-09-30T10:24:44Z")

</div>

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?

---

<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:** [September 30, 2020, 12:10pm UTC](https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235/2 "2020-09-30T12:10:19Z")

</div>

> [@protagoras](#):
>
> 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. 📽

As a workaround you can continuous poll its _width_ or _height_ fields `while ()` they’re still `0` w/ the help of **delay()**: 💡

> **[while / Reference](https://processing.org/reference/while.html)**
>
> Controls a sequence of repetitions. The while structure executes a series of statements continuously while the expression is true. The expression must be updated during the repeti…

> **[delay() / Reference](https://processing.org/reference/delay_.html)**
>
> The delay() function causes the program to halt for a specified time. Delay times are specified in thousandths of a second. For example, running delay(3000) will stop the program for thr…

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

---

<div class="post-metadata">

**Author:** ![protagoras](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@protagoras](https://discourse.processing.org/u/protagoras)\
**Post date:** [September 30, 2020, 1:18pm UTC](https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235/3 "2020-09-30T13:18:38Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![alanholding](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/alanholding/32/19694_2.png) [@alanholding](https://discourse.processing.org/u/alanholding)\
**Post date:** [February 9, 2022, 9:36am UTC](https://discourse.processing.org/t/empty-pixels-array-when-playing-a-movie/24235/4 "2022-02-09T09:36:32Z")

</div>

> [@GoToLoop](#):
>
> A Movie object needs some couple of seconds after the 1st **play()** call to be properly ready. 📽

Thanks for clarifying that. Was driving me nuts. 🙂
