如何让两个 USB 网络摄像头在运行 openSUSE Leap 15.2 的 Raspberry Pi 4 上同时运行?

如何让两个 USB 网络摄像头在运行 openSUSE Leap 15.2 的 Raspberry Pi 4 上同时运行?

如何在运行 openSUSE Leap 15.2 的 Raspberry Pi 4 上同时运行两个 USB 网络摄像头?

我最终希望它能与运动似乎已经消除了这个问题,因为我也从命令行使用 ffplay 失败了。

我有两个网络摄像头插入到有源 USB 集线器。两个网络摄像头独立工作,但不能一起工作。作为测试,将网络摄像头直接插入 Pi 或从集线器上拔掉电源可以让我设备描述符读取/64错误-110所以枢纽正确供电。

如果我按如下方式启动第一个摄像头,我会得到一张照片:

# ffplay -f v4l2 /dev/video0

但是当我开始第二个时,我没有得到图片(第一个将继续工作);我们只是在这里等待,似乎没有超时(不过,不能说我已经等了超过几分钟):

# ffplay -loglevel debug -f v4l2 /dev/video2
ffplay version 3.4.8 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 7 (SUSE Linux)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' --optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl --enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcelt --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libzimg --enable-libzvbi --enable-vaapi --enable-vdpau --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libx264 --enable-libx265 --enable-libxvid
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Initialized opengl renderer.
[video4linux2,v4l2 @ 0xffff40000b50] fd:11 capabilities:84a000010   
[video4linux2,v4l2 @ 0xffff40000b50] Current input_channel: 0, input_name: Camera 1, input_std: 0
[video4linux2,v4l2 @ 0xffff40000b50] Querying the device for the current frame size
[video4linux2,v4l2 @ 0xffff40000b50] Setting frame size to 1280x720
[video4linux2,v4l2 @ 0xffff40000b50] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0xffff40000b50] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0xffff40000b50] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0xffff40000b50] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0xffff40000b50] The V4L2 driver changed the pixel format from 0x32315659 to 0x47504A4D
[video4linux2,v4l2 @ 0xffff40000b50] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0xffff40000b50] The V4L2 driver changed the pixel format from 0x50323234 to 0x47504A4D
[video4linux2,v4l2 @ 0xffff40000b50] Trying to set codec:rawvideo pix_fmt:yuyv422
    nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

dmesg 中没有任何内容;当第一个凸轮启动时,journalctl 显示这一点:

Dec 29 16:23:17 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Scheduling inhibition from ":1.14" "My SDL application" with cookie 18 and reason "Playing a game"
Dec 29 16:23:22 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Enforcing inhibition from ":1.14" "My SDL application" with cookie 18 and reason "Playing a game"
Dec 29 16:23:22 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Added change screen settings
Dec 29 16:23:22 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Added interrupt session
Dec 29 16:23:22 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Disabling DPMS due to inhibition
Dec 29 16:23:22 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Can't contact ck

...然后当第二个开始时

Dec 29 16:24:07 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Scheduling inhibition from ":1.14" "My SDL application" with cookie 19 and reason "Playing a game"
Dec 29 16:24:12 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Enforcing inhibition from ":1.14" "My SDL application" with cookie 19 and reason "Playing a game"
Dec 29 16:24:12 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Added change screen settings
Dec 29 16:24:12 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Added interrupt session
Dec 29 16:24:12 shed-pi4.xxx.xxx org_kde_powerdevil[2497]: powerdevil: Can't contact ck

这可能是关键,也可能是转移注意力的因素。根据谷歌的说法,陪审团还没有定论!

如果我停止第一个摄像头(video0)的 ffplay,那么第二个“挂起”会话(video2)将立即启动。

其他信息:

# ls -lah /dev/v4l/by-path/
total 0
drwxr-xr-x 2 root root 120 Oct 21 15:01 .
drwxr-xr-x 4 root root  80 Oct 21 15:01 ..
lrwxrwxrwx 1 root root  12 Oct 21 15:01 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4.3:1.0-video-index0 -> ../../video0
lrwxrwxrwx 1 root root  12 Oct 21 15:01 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4.3:1.0-video-index1 -> ../../video1
lrwxrwxrwx 1 root root  12 Oct 21 15:01 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4.4:1.0-video-index0 -> ../../video2
lrwxrwxrwx 1 root root  12 Oct 21 15:01 platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4.4:1.0-video-index1 -> ../../video3

# ls -lah /dev/v4l/by-id/
total 0
drwxr-xr-x 2 root root 80 Oct 21 15:01 .
drwxr-xr-x 4 root root 80 Oct 21 15:01 ..
lrwxrwxrwx 1 root root 12 Oct 21 15:01 usb-HD_Camera_Manufacturer_USB_2.0_Camera-video-index0 -> ../../video0
lrwxrwxrwx 1 root root 12 Oct 21 15:01 usb-HD_Camera_Manufacturer_USB_2.0_Camera-video-index1 -> ../../video1

# hwinfo --usb [Edit]
03: USB 00.1: 0000 Unclassified device
  [Created at usb.122]
  Unique ID: VfPh.nrd9O+1TtQ3
  Parent ID: 33sj.xvTGa+XkbXF
  SysFS ID: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4.4/1-1.4.4:1.1
  SysFS BusID: 1-1.4.4:1.1
  Hardware Class: unknown
  Model: "ARC International USB 2.0 Camera"
  Hotplug: USB
  Vendor: usb 0x05a3 "ARC International"
  Device: usb 0x9310 "USB 2.0 Camera"
  Driver: "uvcvideo"
  Driver Modules: "uvcvideo"
  Speed: 480 Mbps
  Module Alias: "usb:v05A3p9310d0000dcEFdsc02dp01ic0Eisc02ip00in01"
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #4 (Hub)

05: USB 00.2: 0000 Unclassified device
  [Created at usb.122]
  Unique ID: Wi1b.nrd9O+1TtQ3
  Parent ID: 33sj.xvTGa+XkbXF
  SysFS ID: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.2
  SysFS BusID: 1-1.4.3:1.2
  Hardware Class: unknown
  Model: "ARC International USB 2.0 Camera"
  Hotplug: USB
  Vendor: usb 0x05a3 "ARC International"
  Device: usb 0x9310 "USB 2.0 Camera"
  Driver: "snd-usb-audio"
  Driver Modules: "snd_usb_audio"
  Speed: 480 Mbps
  Module Alias: "usb:v05A3p9310d0000dcEFdsc02dp01ic01isc01ip00in02"
  Driver Info #0:
    Driver Status: snd_usb_audio is active
    Driver Activation Cmd: "modprobe snd_usb_audio"
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #4 (Hub)


# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 8, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 1: Dev 8, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 3: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 4: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 4: Dev 7, If 1, Class=Video, Driver=uvcvideo, 480M
            |__ Port 4: Dev 7, If 2, Class=Audio, Driver=snd-usb-audio, 480M
            |__ Port 4: Dev 7, If 0, Class=Video, Driver=uvcvideo, 480M
            |__ Port 4: Dev 7, If 3, Class=Audio, Driver=snd-usb-audio, 480M
            |__ Port 3: Dev 6, If 2, Class=Audio, Driver=snd-usb-audio, 480M
            |__ Port 3: Dev 6, If 0, Class=Video, Driver=uvcvideo, 480M
            |__ Port 3: Dev 6, If 3, Class=Audio, Driver=snd-usb-audio, 480M
            |__ Port 3: Dev 6, If 1, Class=Video, Driver=uvcvideo, 480M
     
# v4l2-ctl --list-devices --verbose
USB 2.0 Camera: HD USB Camera (usb-0000:01:00.0-1.4.3):
        /dev/video0
        /dev/video1

USB 2.0 Camera: HD USB Camera (usb-0000:01:00.0-1.4.4):
        /dev/video2
        /dev/video3

VIDIOC_QUERYCAP: ok

我整个下午都在谷歌搜索,但到目前为止还是一片空白。如何让两个摄像头同时启动并运行?我希望如果我能让它与 ffplay 一起工作,那么它也能与 Motion 一起工作。

提前致谢。

答案1

好的...我认为这个问题已经解决了,现在我知道我在寻找什么,答案是到处

我将我的第一个摄像头设置为 1280x720 的分辨率,它运行得很好,Pi 的 CPU 利用率低于 20%,所以我想我可以插入另一个摄像头,并且仍然有空闲容量。

不,看来瓶颈是USB而不是CPU。

首先,如果我将多个 USB2 设备插入 USB3 集线器,所有 USB2 设备共享一个 480Mbs 空间,它们不会各自获得一个新空间。我隐含地知道这一点,但我明确地证明了这一点! (噢!)

其次,第一个摄像头似乎占用了所有可用带宽,而不仅仅是它需要的带宽,因此后续摄像头不会获得任何带宽。就我而言,没有错误,没有警告,我们只是坐在那里等待。等待。这个问题可以通过设置一个标志来解决UVC_QUIRK_FIX_BANDWIDTH如下:

# rmmod uvcvideo
# modprobe uvcvideo quirks=128

并使其永久化

# cat /etc/modprobe.d/uvcvideo.conf
options uvcvideo quirks=128

第三,遗憾的是,即使这本身还不够,我不得不将分辨率降至 640x480,将帧速率降至 20。

现在,Motion 全部使用两个摄像头。这是一个有趣的练习,但直到我发现uvcvideo 怪癖并把回到谷歌,我意识到这个问题确实是众所周知的,并且之前已经被回答过很多次了。 ...但是你需要了解怪癖才能发现怪癖。

嘿嗬!

相关内容