How to bind v4l2 USB cameras to the same device names even after reboot?
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.
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
.