Search code examples
javavideowebcamxuggler

Get webcams names in Xuggler library on Windows


When I using Xuggler library on computer with more than one web-camera with Windows I need use "name" of this web-cameras to select device. I means that command "vfwcap 0" select only first web-camera and command "vfwcap 1" or "vfwcap 2" not allowed get access to other web-cameras. If I use:

$ ffmpeg -list_devices true -f dshow -i dummy

I can see the list of "names" this web-cameras. For example: "Logitech HD Webcam C270", "Logitech Webcam C210". If I using this names into the Xuggler library I get en error.

So, I can get access only to the first web-camera on Windows machine using Xuggler.

Can I get list of all devices in Windows from Xuggler and can I use this names into the Xuggler (I just want to use more than one web-camera at the same time)?

Maybe alternative way are exists?


Solution

  • Using this simple java program, you can get list of all webcam's available on your system.

    import com.github.sarxos.webcam.Webcam;
    
    public class CameraTest {
        public static void main(String[] args) {
            List<Webcam> list = Webcam.getWebcams();
    
            for (int i = 0; i < list.size(); i++) {
                    try {
                        Webcam cam = list.get(i);
                        System.out.println("Found this Camera : "+cam.getName());
                        BufferedImage image = cam.getImage();
                    } catch (Exception e) {
                        System.out.println("Exception in cam : " + i);
                    }
            }
        }
    }
    

    Sample Output :

    Found this Camera : TV CARD WDM VIDEO CAPTURE 0
    Found this Camera : ManyCam Video Source 1
    Found this Camera : DroidCam 2
    

    You will have List of all camera's , So you can use anyone of them as you like.