# deviceId constraint ignored?

**URL:** <https://discourse.processing.org/t/deviceid-constraint-ignored/28791>\
**Category:** Coding Questions\
**Created:** [March 24, 2021, 10:12am UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791 "2021-03-24T10:12:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_RicH\_1](https://avatars.discourse-cdn.com/v4/letter/_/8dc957/32.png) [@\_RicH\_1](https://discourse.processing.org/u/_RicH_1)\
**Post date:** [March 24, 2021, 10:12am UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791/1 "2021-03-24T10:12:58Z")

</div>

Hi,  
I’m wanting to use mutliple camera inputs so I’m using the deviceId constraint on createCapture, but it doesnt seem to matter what I enter it will always just uses the first availalbe video source

If device ID isn’t correct should it error out, not capture anything, or just default to first device?

I get the same result in FF and Chrome. Also tried with the groupID constraint and get the same result.

Everything else works as expected, I can set width and height etc in the same section and that works fine.

Anyone know what i might be doing wrong?

Edit: So it seems firefox will just use the camera I allow on the security popup, how do I allow it to use all?

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 24, 2021, 12:11pm UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791/2 "2021-03-24T12:11:29Z")

</div>

It’s quite tricky. What is the value are you passing to `createCapture` ? I think you need to first list devices, which perhaps is not implemented yet so you need to use the native API

```javascript
navigator.mediaDevices.enumerateDevices().then(console.log);

```

then copy the object from the console (it seems p5.js editor’s console doesn’t show the whole object so you need to open developer tools) and put it inside `{video: ...}`

```javascript
createCapture({
  video: {
    "deviceId": "...",
    "kind": "videoinput",
    "label": "",
    "groupId": "..."
  }
})

```

Here are related issues

> <https://github.com/processing/p5.js/issues/1043>
>
> The need to use a different camera with createVideo(CAPTURE) has come up several times this semester. @lmccart posted an example for...

> <https://github.com/processing/p5.js/issues/5031>
>
> I read this old thread
> \#1043
> but it is closed.
> Has the problem been solved?
> I cannot access the camera on a jetson nano.
> How would...

---

<div class="post-metadata">

**Author:** ![\_RicH\_1](https://avatars.discourse-cdn.com/v4/letter/_/8dc957/32.png) [@\_RicH\_1](https://discourse.processing.org/u/_RicH_1)\
**Post date:** [March 24, 2021, 12:42pm UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791/3 "2021-03-24T12:42:00Z")

</div>

Oh my, thank you so much. I feel like an idiot, I had deviceId:… instead of “deviceId”:…

Now it works as expected!

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 24, 2021, 2:26pm UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791/4 "2021-03-24T14:26:35Z")

</div>

glad that it helped! but effectively `{arg: xxx}` and `{"arg": xxx}` are the same so perhaps there was another issue… but I guess it’s fine if it works now

---

<div class="post-metadata">

**Author:** ![\_RicH\_1](https://avatars.discourse-cdn.com/v4/letter/_/8dc957/32.png) [@\_RicH\_1](https://discourse.processing.org/u/_RicH_1)\
**Post date:** [March 25, 2021, 8:24am UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791/5 "2021-03-25T08:24:38Z")

</div>

You are right, I changed it back and it still works. 🤔

Only other thing I can think of was I moved enumerateDevices outside of the setup function, then called the 3x setups after. Not sure why that would make a difference as it was getting all 3 devices before.

Whatever it was I hope this is useful for anyone else that might have the same issue in the future.
