6

I have 3 USB cameras on single PC, one camera will be unused and can be ignored. I need to force two identical cameras to be mapped to constant device names (like /dev/video1 and /dev/video2 ). The cameras should not change their order (say camera 1 mounted as video1 and camera 2 as video2 after disconnect they should be in same order not camera1 --> /dev/video2, camera2 --> /dev/video1. How to make this setup work?

I will feed camera output to Gstreamer. Cameras are using v4l2 and uvc driver interface. Linux distro in question is Archlinux, cameras - some Logitech webcams.

11

I suggest you autocreate /dev symlinks using udev, using unique properties (serial number? port number?) of your USB cameras. See this (should apply to Arch as well) tutorial about udev rules. Or maybe this tutorial is clearer.

You can get the list of properties for your devices using:

sudo udevadm info --query=all --name=/dev/video1

then

sudo udevadm info --query=all --name=/dev/video2

Find what's different and create a .rules file out of it inside /etc/udev/rules.d (you can use 99-myvideocards.rules as a filename, say); let's say you want to use the serial number, you'd get a ruleset that looks like:

ATTRS{ID_SERIAL}=="0123456789", SYMLINK+="myfirstvideocard"
ATTRS{ID_SERIAL}=="1234567890", SYMLINK+="mysecondvideocard"

After unplugging/replugging your devices (or after a reboot), you'll get /dev/myfirstvideocard and /dev/mysecondvideocard that always point to the same devices.

  • 1
    Thanks I tried that and it works, I will "close" question with your answer ;D But in meantime I found that v4l already have symlinks like /dev/v4l/by-id/usb-046d_0819_92E84F10-video-index0 – IBr May 26 '13 at 17:50
4

Patrice Levesque method works fine, but I found that there are already symlinks in Linux as /dev/v4l/by-id/usb-046d_0819_92E84F10-video-index0 in folder /dev/v4l/by-id/ so no need to do anything, if ones program can accept arguments other than /dev/videoX.

  • While the other answer is correct, I think this is the more practical answer. I've confirmed this with Raspbian and Ubuntu (so at least Debian-based OS's it seems). Not sure if this a standard v4l feature across all distros or not. – Adam Plocher Oct 31 '17 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.