chuckfairy / node-webcam

Nodejs Cross Platform Webcam usage
MIT License
194 stars 52 forks source link

Device name on MacOS #25

Closed rodrigo-puente closed 5 years ago

rodrigo-puente commented 6 years ago

Taking a look at the documentation of imagesnap, when running

imagesnap -l

you should get an output like this:

HD Pro Webcam C920
FaceTime HD Camera

But when trying

WebCam.create().list()

I get the following:

<AVCaptureDALDevice: 0x7fc52ae24c50 [HD Pro Webcam C920][0x14100000046d082d]>, <AVCaptureDALDevice: 0x7fc52ac43690 [FaceTime HD Camera][CC2632430WGGJJM3U]>

Which won't work if you try to create a camera with that device name. For example, if I try to pass the device name to a new instance and capture a picture, I get the following:

{ Error: Command failed: imagesnap -w 1 -d '<AVCaptureDALDevice: 0x7fc52ae24c50 [HD Pro Webcam C920][0x14100000046d082d]>' -q test_picture.jpg Device "<AVCaptureDALDevice: 0x7fc52ae24c50 [HD Pro Webcam C920][0x14100000046d082d]>" not found.

I implemented a little regex to take the first ocurrence inside brackets to display the correct device name, then passing it to:

WebCam.create({ device: list[i]})

I can send a pull request for this, since it might affect other users, but don't know if it has something to do with the OS, imagesnap version I'm using.

chuckfairy commented 6 years ago

I'll check it out this weekend. You can send a pull though and it would be appreciated

danniolsen commented 6 years ago

We are facing the same issue, not for all computers, but some. Any solution for this issue?

chuckfairy commented 6 years ago

Sorry for the lateness 0.4.5 will fix that issue. Running imagesnap from my command line even without node-webcam doesn't seem to be working for me. How about you? I'll see if it's just me later.

https://github.com/chuckfairy/node-webcam/commit/406857c96ac9c2d069724b0fcf8c31b25cfbcb79