我有一个 nexigo hd 网络摄像头,可以在我的工作笔记本电脑(运行 Ubuntu)上使用,但在我的台式机(也运行 Ubuntu)上却无法使用。我确信我的台式机上有些配置错误,但我不知道下一步该检查什么。
我尝试过各种网络浏览器、cheese、qv4l2、obs-studio 和 gst-launch-1.0。这是一台带有 USB 网络摄像头的标准台式机,因此无需按下特殊键即可启用摄像头,也没有物理开关。在测试之间,只需拔下/插入我的笔记本电脑和台式机即可。这不太可能相关,但我的台式机使用的是 AMD 显卡。这是在裸机上,没有虚拟化、docker、snap、flatpak 等。至少,我看不到。
以下都是我的台式机上的,摄像头无法使用。我在视频组:
└──> ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 Oct 20 16:10 /dev/video0
crw-rw----+ 1 root video 81, 1 Oct 20 16:10 /dev/video1
└──> groups | grep -o video
video
找到设备:
└──> v4l2-ctl --list-devices
NexiGo N60 FHD Webcam: NexiGo N (usb-0000:0c:00.3-3.1.2):
/dev/video0
/dev/video1
/dev/media0
这是一个相对标准的 uvcvideo 设备:
└──> v4l2-dbg -D -d /dev/video0
Driver info:
Driver name : uvcvideo
Card type : NexiGo N60 FHD Webcam: NexiGo N
Bus info : usb-0000:0c:00.3-3.1.2
Driver version: 6.2.16
Capabilities : 0x84A00001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
但我无法分配缓冲区。我猜想其他程序也存在同样的问题,但我无法始终获得良好的日志。
└──> GST_DEBUG="v4l2*:3" gst-launch-1.0 v4l2src device=/dev/video0 ! videoscale ! videoconvert ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.079505628 31240 0x564e88fc6800 ERROR v4l2bufferpool gstv4l2bufferpool.c:706:gst_v4l2_buffer_pool_streamon:<v4l2src0:pool0:src> error with STREAMON 5 (Input/output error)
0:00:00.079591570 31240 0x564e88fc6800 WARN v4l2src gstv4l2src.c:759:gst_v4l2src_decide_allocation:<v4l2src0> error: Failed to allocate required memory.
0:00:00.079597662 31240 0x564e88fc6800 WARN v4l2src gstv4l2src.c:759:gst_v4l2src_decide_allocation:<v4l2src0> error: Buffer pool activation failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
../sys/v4l2/gstv4l2src.c(759): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.059204336
Setting pipeline to NULL ...
Freeing pipeline ...
查看上面的 strace,我得到了来自EIO
forioctl
的信息VIDIOC_STREAMON
。
34265 ioctl(7, VIDIOC_REQBUFS, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, memory=V4L2_MEMORY_MMAP, count=2 => 2}) = 0
34265 ioctl(7, VIDIOC_QUERYBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=0, memory=V4L2_MEMORY_MMAP, m.offset=0, length=1843200, bytesused=0, flags=V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC|V4L2_BUF_FLAG_TSTAMP_SRC_SOE, ...}) = 0
34265 ioctl(7, VIDIOC_QUERYBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=1, memory=V4L2_MEMORY_MMAP, m.offset=0x1c2000, length=1843200, bytesused=0, flags=V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC|V4L2_BUF_FLAG_TSTAMP_SRC_SOE, ...}) = 0
34265 ioctl(7, VIDIOC_EXPBUF, 0x7f0445e3da10) = 0
34265 futex(0x7f04486e10a8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
34265 ioctl(7, VIDIOC_QBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=0, memory=V4L2_MEMORY_MMAP, m.offset=0, length=1843200, bytesused=0, flags=V4L2_BUF_FLAG_MAPPED|V4L2_BUF_FLAG_QUEUED|V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC|V4L2_BUF_FLAG_TSTAMP_SRC_SOE, ...}) = 0
34265 futex(0x7f043800c628, FUTEX_WAKE_PRIVATE, 1) = 0
34265 ioctl(7, VIDIOC_EXPBUF, 0x7f0445e3da10) = 0
34265 ioctl(7, VIDIOC_QBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=1, memory=V4L2_MEMORY_MMAP, m.offset=0x1c2000, length=1843200, bytesused=0, flags=V4L2_BUF_FLAG_MAPPED|V4L2_BUF_FLAG_QUEUED|V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC|V4L2_BUF_FLAG_TSTAMP_SRC_SOE, ...}) = 0
34265 futex(0x7f043800c628, FUTEX_WAKE_PRIVATE, 1) = 0
34265 ioctl(13, VIDIOC_STREAMON, [V4L2_BUF_TYPE_VIDEO_CAPTURE]) = -1 EIO (Input/output error)
这是我遇到的问题。我下一步该看什么?
谢谢。
答案1
我想我搞明白了。我忽略的细节是摄像头通过 kvm hdmi/usb2.0 集线器。我找到了 uvcvideo FAQ (https://www.ideasonboard.org/uvc/faq/) 指出了 USB 带宽不足的可能性。这似乎是问题所在。当我通过直接插入我的台式机来绕过 kvm 时,网络摄像头就可以正常工作。如果我交换 kvm 端口,那么我的台式机就可以正常工作,而我的笔记本电脑则不能。
你可以在 lsusb 中看到这一点:
└──> lsusb -t
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 3: Dev 41, If 0, Class=Hub, Driver=hub/4p, 12M
|__ Port 1: Dev 45, If 2, Class=Audio, Driver=snd-usb-audio, 12M
|__ Port 1: Dev 45, If 0, Class=Video, Driver=uvcvideo, 12M
|__ Port 1: Dev 45, If 3, Class=Audio, Driver=snd-usb-audio, 12M
|__ Port 1: Dev 45, If 1, Class=Video, Driver=uvcvideo, 12M
...truncated...
交换 kvm 端口后的情况如下(并且网络摄像头在我的桌面上运行):
└──> lsusb -t
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 3: Dev 56, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 59, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 60, If 0, Class=Video, Driver=uvcvideo, 480M
|__ Port 2: Dev 60, If 3, Class=Audio, Driver=snd-usb-audio, 480M
|__ Port 2: Dev 60, If 1, Class=Video, Driver=uvcvideo, 480M
|__ Port 2: Dev 60, If 2, Class=Audio, Driver=snd-usb-audio, 480M
希望这能帮助其他人。