Ui Webcam node camera select

Hi. I use the node-red-node-ui-webcam node and it works fine but when i use it on a mobile phone with a lot of camera's inside, the node is always startup with the front camera. I can switch it to the back camera with the smal dropdown menu. But is it possible to startup automatically with the back camera??

Maybe it is a option to add a new config item to this node. So that you can select which camera is the first one to startup.....

I thought maybe it would remember last used camera... but (after fighting with Chrome to honor me with permission to use my own camera :stuck_out_tongue: ) I realized that is NOT the case.

I would suggest asking on the GitHub page, for this dynamically controllable selection feature to be added... but this is one of the core nodes that seem all lumped into one, on said page. So I guess asking here is what we do.

Not sure how that should be implemented. Most users use their dashboard on multiple devices. For example:

  • On a smartphone which has a rear and a back cam.
  • On a labtop which only has a rear camera.

Some options:

  1. You cannot show a dropdown in the node's config screen, to select one of the available cams as default one. Because the node (which is running on the server side ), isn't aware of that...
  2. Keeping track of the last selected cam per client device somehow on the server side, seems complex to me...
  3. Perhaps the node can store (e.g. using this the last selected device on the client side, and select it automatically again the next time you open your dashboard. Such a behaviour could be activated explicit with a checkbox on the node's config screen.


Any device with multiple cameras has some way of numerating them... as shown by being able to chose in the dropdown. Perhaps an option to inject a command to use the 1st, 2nd, 3rd, etc. camera availed.

That way, if a device only has on camera, that is all it shows regardless of choice, but if it has more it choses the number listed.

Yes, that may mean it isn't always the right alternate camera, depending on device, but as most are not going to use that feature across many devices, then it is at least an option.

1 Like

I used the standard node "node-red-node-ui-webcam" ver 0.3.0 I think there is no option to selected which camera is startup. when i test the dashboard on a system with one camera(laptop) then it is off course always startup with the first camera. But on my phone with 4 camera it is always startup with camera one, and that is the front camera. I try to startup with camera 3 (rear camera)

As the creator of the webcam node, I agree this would be a very useful feature to add. However I'm unlikely to have time to do it at any point soon.

If someone wanted to contribute a change, I'd be happy to discuss/review etc.

The main design question is, as has been mentioned, how exactly to pick the preferred camera.

For the cases where the dashboard is only ever viewed on one particular device, hard-coding the camera in the node config would be okay - but it would still have to do the right thing when viewed on a different device.

In many cases, the computer where the flows are edited is not the computer where the dashboard is viewed. So whilst picking a camera in the node config would work in some cases, it wouldn't make sense in all.

But regardless, if someone wanted to give it a go, I'm sure we'd welcome the contribution.

Most devices would have either one, two or perhaps three cameras... anything more almost gets into the realm of use something different for the job :wink:

So a simple option (via settings and/or msg) to have the node always chose the 2nd (or 3rd) camera (unless there is only one, and fall back to next last of a higher choice is offered then availed) would seem applicable. One could test and set the best option for most desired use case across needed devices. Even have multiple nodes to be chosen from based on device used to view.

Wish I could... probably already would have tried instead of elevating this topic. But this is all I can do.

Looks like the two options are

1 - allow setting an index in the config - and fail back to 0 or highest in list (TBD) if not valid for that device.
2 - store last chosen in the browser localStorage - so would need to be set by the user the first time the node was used by each device.

1 is "easy" to implement as it's standard Node-RED node config type work.
2 is harder as I'm not sure it's been done before - certainly not accessing localStorage from a ui node so would need more investigation (if it is even possible).

Actually option 2 also looks doable - so which would users prefer ? I think I prefer 2 as it is one less thing to try to guess/configure for the app writer. But opinions please before I write any code.

1 Like

I think option2 is the best way.

Would this permit the user to change camera after the choice is made? Perhaps simply tapping the camera image should cycle through all cameras & store last used in browser storage ready for next time?

There is already a drop down for the user to choose from

so yes the user can change at any time.

1 Like

Which ever way, I think it should be an option that could be passed in via a msg. I can see someone using it with multiple cameras and wanting them to switch based on a timer or a 'next' button or something else where it is done automatically.

1 Like

Really ? Is that an actual requirement ? No-one has asked for that.

Yes i know there is a drop down. But this is not a good option for me.

:slightly_frowning_face: It's not an 'actual' requirement but a suggestion. I've been working on a security system with some others and just thought this would be a useful feature.....

so this needs the client device to have a dashboard browser open in order for you to grab pics... for a security system I would think you wouldn't want to rely on that being the case... and indeed most browsers need the user to allow the camera first as well... but I guess maybe.

OK - PR raised


Nice work!!!

So that's really fast. How can i use it?