# Does video.size() function doesn’t work properly for pixel manipulation

**URL:** <https://discourse.processing.org/t/does-video-size-function-doesn-t-work-properly-for-pixel-manipulation/22489>\
**Category:** Coding Questions\
**Created:** [July 8, 2020, 8:09pm UTC](https://discourse.processing.org/t/does-video-size-function-doesn-t-work-properly-for-pixel-manipulation/22489 "2020-07-08T20:09:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddyna](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@maddyna](https://discourse.processing.org/u/maddyna)\
**Post date:** [July 8, 2020, 8:09pm UTC](https://discourse.processing.org/t/does-video-size-function-doesn-t-work-properly-for-pixel-manipulation/22489/1 "2020-07-08T20:09:30Z")

</div>

\<does video.size() function doesn’t work properly for pixel manipulation.  
the moment i am using it I am getting a black screen in the canvas though the video is running in the browser  
I am sending the code:  
let video;

function setup() {  
createCanvas(320, 240);  
video=createCapture(VIDEO);  
pixelDensity(1);  
video.size(320,240);

}

function draw() {  
background(220);  
loadPixels();  
video.loadPixels();  
for(var y=0;y\<height;y++){  
for(var x=0;x\<width;x++){  
let index=(x+y\*width)\*4;

```auto
  var r=video.pixels[index+0];
  var g=video.pixels[index+1];
  var b=video.pixels[index+2];
  var a=255;
  
  let br=(r+g+b)/3;
  pixels[index+0]=br;
  pixels[index+1]=br;
  pixels[index+2]=br;
  pixels[index+3]=255;
  
  
}

```

}  
updatePixels();  
}

please suggest what is wrong  
/\>
