Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select from multiple cameras #313

Open
nitesh-nair opened this issue Jun 25, 2020 · 3 comments
Open

Select from multiple cameras #313

nitesh-nair opened this issue Jun 25, 2020 · 3 comments

Comments

@nitesh-nair
Copy link

If i have an external camera connected, is there a way to select that from the page rather than going into chrome settings and changing it?

@usamaraja125
Copy link

hi did you find the answer i want to connect IP camera .please let me know if you know how to connect IP camera

@t-walker-wei
Copy link

From enumerateDevices, you can get the list of available cameras.
And then use contraints option in webcamjs
deviceId: { exact: [the device id you get from enumerateDevices] }

@kentxp
Copy link

kentxp commented Aug 17, 2021

navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
  devices.forEach(function(device) {
    console.log(device.kind + ": " + device.label +
                " id = " + device.deviceId);
  });
})
.catch(function(err) {
  console.log(err.name + ": " + err.message);
});
// when you get device.deviceId,you can replace xxx in  deviceId: {exact: 'xxx' },
		Webcam.set({
			width: 320,
			height: 180,
			image_format: 'jpeg',
			jpeg_quality: 90,
			constraints: {
				width: 320, // { exact: 320 },
				height: 180, // { exact: 180 },
				facingMode: 'user',
				deviceId: {exact: 'xxx' },
				frameRate: 30
			}
		});
		Webcam.attach( '#my_camera' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants