在树莓派上使用运动来解决网络摄像头流媒体问题



我有一个USB摄像头(未知品牌,没有标记),在我的树莓派上被检测到。

lsusb

的输出
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 0c45:608f Microdia PC Camera (SN9C103 + OV7630)
Bus 001 Device 005: ID 1267:0103 Logic3 / SpectraVideo plc G-720 Keyboard

然而,当我运行motion时,使用/dev/video0与唯一的默认配置改变了分辨率并设置了网络摄像头主机,以便我可以在网络上流式传输它。这是我的日志当我运行motion

Log of motion -n 
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478784
[0] Thread 1 is from /etc/motion/motion.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Thread 1 started
[1] cap.driver: "sonixb"
[1] cap.card: "USB camera"
[1] cap.bus_info: "usb-bcm2708_usb-1.2"
[1] cap.capabilities=0x05000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: S910 (S910)
[1] 1: BA81 (BA81)
[1] Selected palette BA81
[1] Test palette BA81 (480x640)
[1] Adjusting resolution from 480x640 to 160x120.
[1] Using palette BA81 (160x120) bytesperlines 160 sizeimage 19200 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255 
[1]     "Brightness", default 127, current 127
[1] found control 0x00980911, "Exposure", range 0,1023 
[1]     "Exposure", default 66, current 66
[1] found control 0x00980912, "Automatic Gain (and Exposure)", range 0,1 
[1]     "Automatic Gain (and Exposure)", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,255 
[1]     "Gain", default 127, current 127
[1] mmap information:
[1] frames=4
[1] 0 length=20480
[1] 1 length=20480
[1] 2 length=20480
[1] 3 length=20480
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] Error capturing first image
[1] Started stream webcam server in port 8081
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] Video device fatal error - Closing video device
[1] Closing video device /dev/video0
[1] Retrying until successful connection with camera
[1] cap.driver: "sonixb"
[1] cap.card: "USB camera"
[1] cap.bus_info: "usb-bcm2708_usb-1.2"
[1] cap.capabilities=0x05000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: S910 (S910)
[1] 1: BA81 (BA81)
[1] Selected palette BA81
[1] Test palette BA81 (480x640)
[1] Adjusting resolution from 480x640 to 160x120.
[1] Using palette BA81 (160x120) bytesperlines 160 sizeimage 19200 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255 
[1]     "Brightness", default 127, current 127
[1] found control 0x00980911, "Exposure", range 0,1023 
[1]     "Exposure", default 66, current 66
[1] found control 0x00980912, "Automatic Gain (and Exposure)", range 0,1 
[1]     "Automatic Gain (and Exposure)", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,255 
[1]     "Gain", default 127, current 127
[1] mmap information:
[1] frames=4
[1] 0 length=20480
[1] 1 length=20480
[1] 2 length=20480
[1] 3 length=20480
[1] Using V4L2
[1] Camera has finally become available
[1] Camera image has different width and height from what is in the config file. You should fix that
[1] Restarting Motion thread to reinitialize all image buffers to new picture dimensions
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] Closing video device /dev/video0
[0] Motion thread 1 restart
[1] Thread 1 started
[1] config image height (120) is not modulo 16
[1] Could not fetch initial image from camera
[1] Motion continues using width and height from config file(s)
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[1] Retrying until successful connection with camera
[1] config image height (120) is not modulo 16
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[1] Thread exiting
[0] Motion terminating

相机上的灯在开始时亮着,然后又熄灭了,有人认识到我得到的任何错误吗?

谢谢!

我认为您需要将配置文件中图像的高度和宽度设置为您的相机规格。我的直到我设置高640宽480才开始工作。流太棒了!只需要找出webstream认证的补丁。目前我有这个流到我的web服务器,需要登录,但这可以被绕过,如果有人进入我的IP加上端口流上。

即使在conf文件中配置不同,motion在运行时也会使用它检测到的可能的分辨率(至少在我的经验中)。

此外,似乎在conf文件中设置了一个不支持的调色板,并且motion从它检测到的两个调色板中选择一个支持。您是否尝试在conf文件中将调色板设置为"0"(S910) ?

最后,Pi的USB支持有一些已知的,到目前为止尚未解决的关于大数据块的问题。降低帧率在其他情况下也可能有所帮助(在这种情况下,我认为我不会帮助,因为这个过程已经失败了)。

试试v2l4-ctl --list-format-ext,看看你的相机支持什么像素格式和图像大小的组合。

S910是一个便宜的旧相机,你可能想要升级。

您的问题在日志中:

config image height (120) is not modulo 16

所以你需要一个不同的图像分辨率

查看您的设备支持的

$ uvcdynctrl -f

选择一个y分辨率是16的倍数的。例如:640x480,如果是为你的相机列出的。

我建议你尝试guvcview而不是motion。它运行得更快,在我的Pi上显示的图像也要好得多。

guvcview的两个注意事项-将电源线频率设置为您当地的电源频率。-设置分辨率为640 * 480。

guvcview占用大约50%的处理器功率。是的,也使用USB集线器!

中。

最新更新