苦逼技术宅的仓库
via x2x4
在openwrt上安装webcam
作者: x2x4日期: 2013 年 05 月 22 日
硬件环境
- 摄像头淘宝买的杂牌 lsusb结果
Bus 001 Device 005: ID 0c45:6340 Microdia
- 路由器
- 路由型号 NETGEAR WNDR3700v2
- 固件版本 OpenWrt Backfire 10.03.1 / LuCI 0.10.0 Release (0.10.0)
- 内核版本 2.6.32.27
参考文档
- 参考1 http://linuxtv.org/wiki/index.php/Webcam_Devices#Webcam_Devices_supported_by_Generic_Linux_Drivers
- 参考2 http://wiki.openwrt.org/doc/howto/usb.video
- 参考3 http://wiki.openwrt.org/doc/howto/webcam
- 参考4 https://forum.openwrt.org/viewtopic.php?id=23191
开工
根据硬件信息查参考1
SN9C* open source Microdia drivers under development
我猜想次摄像头kernel驱动应该叫SN9CXX 再查参考2
kmod-video-sn9c102 Kernel modules for supporting SN9C102 camera chips.
猜想可能是这个驱动,开工安装
opkg update opkg install kmod-video-sn9c102 mjpg-streamer
按照参考三,直接启动mjpg-stearmer,然后报错
/etc/init.d/mjpg-streamer start MJPG Streamer Version: svn rev: exported i: Using V4L2 device.: /dev/video0 i: Desired Resolution: 640 x 480 i: Frames Per Second.: 5 i: Format............: MJPEG Unable to set format: 1196444237 res: 640x480 Init v4L2 failed !! exit fatal i: init_VideoIn failed
找到参考4,发现以下命令可以让摄像头正常工作
mjpg_streamer -i "input_uvc.so -y -d /dev/video0 -r VGA -l on" -o "output_http.so -p 8080 -w /tmp/webcam" MJPG Streamer Version: svn rev: exported i: Using V4L2 device.: /dev/video0 i: Desired Resolution: 640 x 480 i: Frames Per Second.: 5 i: Format............: YUV i: JPEG Quality......: 80 Adding control for Pan (relative) Adding control for Tilt (relative) Adding control for Pan Reset Adding control for Tilt Reset Adding control for Pan/tilt Reset Adding control for Focus (absolute) mapping control for Pan (relative) mapping control for Tilt (relative) mapping control for Pan Reset mapping control for Tilt Reset mapping control for Pan/tilt Reset mapping control for Focus (absolute) mapping control for LED1 Mode mapping control for LED1 Frequency mapping control for Disable video processing mapping control for Raw bits per pixel o: www-folder-path...: /tmp/webcam/ o: HTTP TCP port.....: 8080 o: username:password.: disabled o: commands..........: enabled ^Csetting signal to stop setting signal to stop setting signal to stop setting signal to stop force cancellation of threads and cleanup resources o: cleaning up ressources allocated by server thread #00 force cancellation of threads and cleanup resources i: cleaning up ressources allocated by input thread done
访问浏览器http://192.168.3.1:8080/?action=stream 一切正常
接着分析,如果命令行能够执行成功,并且有画面说明只要让启动脚本按照能够正常执行的命令方式运行就可以了 接着看/etc/init.d/mjpg-streamer,第十七行出现了问题
[ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "input_uvc.so --device ....
修改成下面的
[ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "input_uvc.so -y --device
再执行启动脚本就没问题了
记得要打开自启动
/etc/init.d/mjpg-streamer enable
录像
待续