# Low video quality using createVideo

**URL:** <https://discourse.processing.org/t/low-video-quality-using-createvideo/38912>\
**Category:** Coding Questions\
**Created:** [September 21, 2022, 11:20am UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912 "2022-09-21T11:20:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omri](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@Omri](https://discourse.processing.org/u/Omri)\
**Post date:** [September 21, 2022, 11:20am UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/1 "2022-09-21T11:20:01Z")

</div>

hey, I have a video.mp4 on my computer and I want to load it to a p5 sketch. this is the code:

```auto
let pause_vid = true;

function preload() {
  vid = createVideo("video.mp4");
}
function setup() {
  createCanvas(window.innerWidth, window.innerHeight);
   vid.size(width, height);
   vid.volume(0);
   vid.hide(); // hides the html video loader
  vid.pause();
}
function draw() {
image(vid,0,0,width,height);
}
function mousePressed() {
  if (!pause_vid) {
    vid.pause();
  } else {
    vid.loop();
  }
  pause_vid = !pause_vid
}

```

everything is working fine, the problem is that the quality of the video in the browser is very low. (the original video is of good quality).  
what can I do?  
thanks 🙂

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [September 21, 2022, 12:02pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/2 "2022-09-21T12:02:09Z")

</div>

Hi @Omri,

Can you post an original vs `createVideo` in the browser screenshot comparison of the quality you are seeing?

What is the resolution / codec of your video?

You can read more details about that here:

> **[Web video codec guide - Web media technologies | MDN](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs#choosing_a_video_codec)**
>
> This guide introduces the video codecs you're most likely to encounter or consider using on the web, summaries of their capabilities and any compatibility and utility concerns, and advice to help you choose the right codec for your project's video.

---

<div class="post-metadata">

**Author:** ![Omri](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@Omri](https://discourse.processing.org/u/Omri)\
**Post date:** [September 21, 2022, 2:04pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/3 "2022-09-21T14:04:27Z")

</div>

Hi @josephh

this is the video played on my computer on VLC:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/0/f00bce34d1ad82b1bbf7a040d968d73a1c12fa66.jpeg)  
And this is from my sketch:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/6/b6087cc7fe3e7d485ec8bc865255072b3a51d77b.jpeg)  
The resolution is FHD (1920 X 1080)  
it’s an mp4 file

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [September 21, 2022, 2:08pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/4 "2022-09-21T14:08:28Z")

</div>

Ok maybe try to remove this statement:

> [@Omri](#):
>
> `vid.size(width, height);`

since you are then drawing your video with `image(vid, 0, 0, width, height);`…

---

<div class="post-metadata">

**Author:** ![Omri](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@Omri](https://discourse.processing.org/u/Omri)\
**Post date:** [September 21, 2022, 2:17pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/5 "2022-09-21T14:17:38Z")

</div>

A M A Z I N G  
Thank you!!

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [September 21, 2022, 2:19pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912/6 "2022-09-21T14:19:52Z")

</div>

Cool! 😉

It may be because `window.innerWidth` and `window.innerHeight` are set after the `setup()` and so it was setting your resolution to a low value…
