Install USB web camera on OpenWrt
I have an old USB web camera . I also have a router using OpenWrt. Why not connecting both?
I have reference the guide from Upsangel.com, Openwork forum and Madox.net
Since both my USB webcam and router I am using differ from theirs, I have developed the below guide:
I have reference the guide from Upsangel.com, Openwork forum and Madox.net
Since both my USB webcam and router I am using differ from theirs, I have developed the below guide:
- I assumed your OpenWrt installation has proper USB support configured.
- Check if USB camera is detected:
- telnet/ssh into your OpenWrt
- use command: dmesg | tail -n3
- You should see:
[437842.170000] usb 2-1: new full-speed USB device number 7 using ohci-platform
[437842.380000] usb 2-1: New USB device found, idVendor=05a9, idProduct=a511
[437842.390000] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 - Note your USB camera vendor code and device code.
- Nearly all USB cameras are either UVC or GSPCA, or unsupported. Check if your USB vendor code and product code are listed:
- UVC: ideasonboard.org
- GSPCA: mjmwired.net or linuxtv.org
- I found that my device is listed inside mjmwired.net, support GSPCA and need ov519 sub driver.
- Install the below packages:
- opkg update
- opkg install usbutils
- opkg install kmod-usb-core kmod-usb2 kmod-video-core
- opkg install kmod-video-uvc
- (for GSPCA) opkg install kmod-video-gspca-core kmod-video-gspca-xxxxx (note: xxxxx is your sub-driver code listed. In my case, I use ov519 and zc3xxx for my two old webcams.)
- (I installed both drivers as I don't know which device driver is suitable at my very beginning of this test.)
- As you have installed usbutil, you can use lsusb to check your device again: Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 041e:4034 Creative Technology, Ltd Webcam Instant
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub - You also need to install mjpg-streamer:
- opkg install mjpg-streamer
- Enable mjpg-streamer to be autorun:
- /etc/init.d/mjpg-streamer enable
- Then reboot your router
- Verify if your USB webcam is detected as video device:
- ls /dev/video*
[root@mybox:/root]#ls /dev/video*
/dev/video0 - Check if mjpg-streamer is running on 8080
- netstat -an | grep 8080
- ps | grep mjpg_streamer
- If it is not running yet, we can run it manually:
- Simple Version:
mjpg_streamer -i "input_uvc.so" -o "output_http.so"
MJPG Streamer Version: svn rev: Unversioned directory
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: not limited
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
i: The format asked unavailable, so the width 352 height 288
The input device does not supports MJPEG mode
You may also try the YUV mode (-yuv option),
or the you can set another supported formats using the -fourcc argument.
Note: streaming using uncompressed formats will require much more CPU power on your server
Init v4L2 failed !! exit fatal
i: init_VideoIn failedBut in my case, I cannot run the program in default input option. I need to specify the resolution as recommended by the program. - Complex version (tested with Creative Webcam Instant zc3xx): mjpg_streamer -i "input_uvc.so -r 352x288" -o "output_http.so"
MJPG Streamer Version: svn rev: Unversioned directory
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 352 x 288
i: Frames Per Second.: not limited
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
o: www-folder-path...: disabled
o: HTTP TCP port.....: 8080
o: username:password.: disabled
o: commands..........: enabled - It is because the CCD native resolution is 352 x 288!
- I have never succeed in using my OV519 cam!
- -i is for input options:
- -r is to specify the resolution to a supported resolution, rather than the default 640x480
- If your Webcam does not support JPEG format, you can turn to YUVY mode by adding -yuv in your input option.
- -o is for output options:
- -p for port number
- Then go to http://192.168.1.1:8080/?action=snapshot or http://192.168.1.1:8080/?action=stream to see the webcam output
- Press Ctrl-C to break after testing
- If you can see the output, then we need to save the verified config into config file at /etc/config/mjpg-streamer
- open editor: vi /etc/config/mjpg-streamer
- Press Esc, then a to start editing
- Change enabled to 1; Change the resolution to that verified in earlier step. Change the TCP port number as needed. Last change the username and password.
config mjpg-streamer 'core'
option enabled '1'
option input 'uvc'
option output 'http'
option device '/dev/video0'
option resolution '352x288'
option fps '5'
option www '/www/webcam'
option port '8080'
option username 'openwrt'
option password 'openwrt' - Press Esc, then :wq to save and quit
- use command /etc/init.d/mjpg-streamer enable to enable auto start of the service.
- use command /etc/init.d/mjpg-streamer start to manually start the service.
- use ps command to verify if the process has been run:
- #ps | grep mjpg
2575 root 8320 S /usr/bin/mjpg_streamer --input input_uvc.so --device - Then reboot and test the URL again for final check. That's it.
Comments