I am using a library (librealsense) that only outputs the bus and port number as such (9.1). It uses libusb internally. The issue is from this identifier in libusb I want to know what physical device it belongs to in /dev/video0. For instance, 9.1 -> /dev/video0 and 7.2 -> /dev/video2 when two cameras are plugged in in ports 9.1 and 7.2.

Is this possible? How do I acquire what devices paths belong to a bus and port? Any partial answer would be helpful.

  • 1
    Don't know your OS, but if the devices are created via udev, you could use udevadm info -n video0 -q all to see the created symlinks; e.g. S: v4l/by-path/pci-0000:00:13.2-usb-0:4.1:1.0-video-index0 shows the link in /dev/v4l/by-path. Or, if you know the ID of your cameras, /dev/v4l/by-idcould help. And configuring udev might give fixed devices for different cameras. – ridgy Feb 14 '17 at 10:43
  • You can do it the other way round (find which usb device belongs to which video* device) by examining /sys/class/video4linux/, which contains symlinks with the complete bus path (usb or otherwise). – dirkt Feb 14 '17 at 11:14
  • @ridgy Thanks that's what I was looking for, I can grep for existence of that path! Feel free to copy that as an answer, if you want. – nico Feb 14 '17 at 15:23
  • @dirkt I appreciate your answer, I tried that but I'm not quite sure which directory the video information is location within the /sys/class/video4linux folder. – nico Feb 14 '17 at 15:23
  • 1
    Just do ls -l /sys/class/video4linux/, you should see all video devices as symlinks. udevadm also just looks at the /sys file system, but extracts more information from it (most of which you don't need for your question). – dirkt Feb 14 '17 at 16:52

Answering so I can close this question full credit to @ridgy and @dirkt for their help. With the command:

udevadm info -n video0 -q path

Or similarly with ls -l /sys/class/video4linux/, a path of the form /devices/pci0000:00/0000:00:10.0/usb7/7-2/7-2:1.0/video4linux/video0 can be found. That in combination with the listing of the video devices using either ls /dev/video* or v4l2-ctl --list-devices allows a map between the usb port and video device to be created.

| improve this answer | |

you can also use below command to get more information

udevadm info -a -p $(udevadm info -q path -n /dev/video0)

udevadm info -a -p $(udevadm info -q path -n /dev/video1)

| improve this answer | |

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.