2

I've created a udev rule to force my usb devices into fixed folders at /dev/ (one, is a webcam into /dev/video1 and the other one is a framegrabber into /dev/video0 ) I need to do this because, by default, I attach webcam after the framegrabber into my computer (so far so good) but if I reboot the system (while they're still attached) the webcam will be assigned to /dev/video0 and the framegrabber to /dev/video1 which will lead to the failure of the apps trying to use them as recording resources (gstreamer pipeline, in this case)

I put the 25-video-devices.rules in /etc/udev/rules.d/ and reload the udev rules, even restart the udev service but after rebooting the system the result is still the same...

SUBSYSTEMS=="usb", ATTRS{idVendor}=="5555", ATTRS{idProduct}=="3500", NAME:="video0", OPTIONS:="link_priority=100"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0843", NAME:="video1"

It seems udev rule doesn't function properly or I'm doing something wrong or missing something?

Can you please help me with that?

p.s: I got the vendor and product ids using lsusb

4

From man 7 udev (highlighting by me):

The kernel usually just assigns unpredictable device names based on the order of discovery. […] The name of a device node cannot be changed by udev, only additional symlinks can be created.

In other words, I think you won’t be able to use /dev/video0 or /dev/video1 reliably. Instead you should create and use stable symlinks. Something like the following might work instead:

KERNEL=="video*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="5555", ATTRS{idProduct}=="3500", SYMLINK+="myframegrabber"
KERNEL=="video*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0843", SYMLINK+="mywebcam"

You would then use /dev/mywebcam and /dev/myframegrabber in your applications.

By the way, as recently mentioned in a similar answer:

There is a chance that video4linux has already provided you with stable device names. You may want to check the directories /dev/v4l/by-id/ and /dev/v4l/by-path/ for this.

8
  • Thanks a lot for this useful info :-) I did make symlinks as you mentioned but gstreamer failed to find access to the resources I checked the /dev/ and saw those links are created but with this permissions: lrwxrwxrwx 1 root root 13 Jan 9 18:17 mywebcam -> snd/controlC2 how can I fix this as well? does this has something to do with permissions or I'm wrong? – Sina Sh Jan 9 '16 at 17:22
  • and here is the permissions on one of the /dev/video locations: crw-rw----+ 1 root video 81, 1 Jan 9 18:16 video1 – Sina Sh Jan 9 '16 at 17:25
  • 1
    A symlink always has these permissions; it’s the permissions of the link target that matters. Interestingly, your symlink points to /dev/snd/controlC2 which doesn’t seem to be a video device! Are you sure that your idVendor and idProduct values are correct? Perhaps the issue is also that the device is internally treated as different devices (both audio and video capturing), not sure. If the latter should be the case, then maybe adding KERNEL=="video*" to your rules might help (but this is only a wild guess of mine). – Chriki Jan 9 '16 at 17:57
  • Well, I did add the KERNEL=="video*" to my rules, after rebooting myframegrabber points toward /dev/video1 and mywebcam to /dev/video0 which is still wrong... – Sina Sh Jan 9 '16 at 18:45
  • 1
    Wait, we should clarify our expectations here: the only expectation we should have is that /dev/mywebcam points to your webcam and /dev/myframegrabber points to your framegrabber. It does’t matter what /dev/video1 and /dev/video0 point to! The whole purpose of the new rules is to become independent of the latter two device node names and to instead only use the new symlinks. I have updated my answer to what seems to be the solution for your device IDs. Could you please check if your applications can use /dev/mywebcam for the webcam and /dev/myframegrabber for the framegrabber? – Chriki Jan 10 '16 at 7:15

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.