# video.loadPixels() does not seem to work

**URL:** <https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225>\
**Category:** Coding Questions\
**Created:** [January 5, 2019, 5:21pm UTC](https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225 "2019-01-05T17:21:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjsan](https://avatars.discourse-cdn.com/v4/letter/r/87869e/32.png) [@rjsan](https://discourse.processing.org/u/rjsan)\
**Post date:** [January 5, 2019, 5:21pm UTC](https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225/1 "2019-01-05T17:21:00Z")

</div>

Hi all!

I did a lot of code dabbling on this video capture tutorial sometime around 2017 : [https://www.youtube.com/watch?v=rNqaw8LT2ZU](https://www.youtube.com/watch?v=rNqaw8LT2ZU) using p5js version v0.5.11 . All seem to work even around early 2018 but when i revisited my code now, video.loadPixels() does not seem to work. Updated p5js library to version v0.7.2 but still no go.

Anyone having similar experience / workaround ?

Thanks.

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [January 5, 2019, 9:26pm UTC](https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225/2 "2019-01-05T21:26:39Z")

</div>

[Looks like it’s a know bug in v0.7.2](https://github.com/processing/p5.js/issues/3278). If you’d like to use `loadPixels()` on a video I think the easiest thing is just to switch back to v0.7.1 and wait for v0.8.0 where it’ll probably be fixed.

---

<div class="post-metadata">

**Author:** ![Hassan](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@Hassan](https://discourse.processing.org/u/Hassan)\
**Post date:** [January 6, 2019, 1:16pm UTC](https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225/3 "2019-01-06T13:16:25Z")

</div>

Hi Rjsan, I faced the same problem yesterday. But I was working on Processing P3 with this Code from the video in link. Luckily, I have fixed it 🙂  
I was facing error in the “_loc_” variable in this command, **video.loadPixels(loc)**. The error was “ **arrayindexoutofboundsexception:** 307200”

If you are facing the same do the following:  
**int loc = x + y \* video.width;** ………………….( **1** )  
**color currentColor = video.pixels[loc];**…………( **2** )  
you must know and confirm that code(1) is accurately entered as it is written here. If it is correct, then you will not get the “arrayindexoutofboundsexception: 307200” error.

**_Example:_**  
Camera resolution=640x480

here,  
640 = width i.e. “x=639 maximum” [because bits start from 0]  
480 = height i.e. “y=479 maximum” [because bits start from 0]  
then,  
loc = x + y \* video.width;  
loc = 639 + (479 \* 640)  
=307199 maximum.  
We get the “arrayindexoutofboundsexception: 123…” error, if our _ **loc** _ value is greater then the Max. calculated value of _loc_. It is may be only due to  
**1)** Wrong equation Entered. [this equation must be same as code( **1** )]

---

<div class="post-metadata">

**Author:** ![rjsan](https://avatars.discourse-cdn.com/v4/letter/r/87869e/32.png) [@rjsan](https://discourse.processing.org/u/rjsan)\
**Post date:** [January 19, 2019, 4:37pm UTC](https://discourse.processing.org/t/video-loadpixels-does-not-seem-to-work/7225/4 "2019-01-19T16:37:20Z")

</div>

Thanks figraham/Hassan , appreciate the input. Will look more into this.
