janpaul123 / paperprograms

Run Javascript on pieces of paper!
https://paperprograms.org
MIT License
484 stars 55 forks source link

video stream of webcam doesn't load #39

Closed paulsonnentag closed 6 years ago

paulsonnentag commented 6 years ago

The webcam I'm using (Microsoft LifeCam 3000) doesn't work with Paper Programs. The "onloadedmetadata" event never get triggered. This problem unfortunately only occurs with Chrome (65.0.3325.181), other browsers work fine. The cause seems to be how getUserMedia is called:

https://github.com/janpaul123/paperprograms/blob/2f49491595619a044f98c7517d67557f95104dde/client/camera/CameraVideo.js#L19-L26

If I change it to a specific resolution, my webcam supports it works. I think this is a bug with Chrome or the webcam driver.

video: { 
  width: 1280, 
  height: 720
}

I searched for a more generic solution which always picks the best available resolution and found this snippet on stack overflow. This also works with my webcam.

video: {
  optional: [
    {minWidth: 320},
    {minWidth: 640},
    {minWidth: 1024},
    {minWidth: 1280},
    {minWidth: 1920},
    {minWidth: 2560},
  ]
}

https://stackoverflow.com/questions/27420581/get-maximum-video-resolution-with-getusermedia#answer-27444179

Is this issue specific to my webcam or has anyone experienced something similar?

janpaul123 commented 6 years ago

Fixed in #40 👍