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:

  1. I assumed your OpenWrt installation has proper USB support configured.
  2. Check if USB camera is detected:
    1. telnet/ssh into your OpenWrt
    2. use command: dmesg | tail -n3
      1. 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
  3. Note your USB camera vendor code and device code.  
  4. Nearly all USB cameras are either UVC or GSPCA, or unsupported. Check if your USB vendor code and product code are listed:
    1. UVC: ideasonboard.org
    2. GSPCA: mjmwired.net or linuxtv.org
  5.  I found that my device is listed inside mjmwired.net, support GSPCA and need ov519 sub driver. 
  6. Install the below packages:
    1. opkg update
    2. opkg install usbutils
    3. opkg install kmod-usb-core kmod-usb2 kmod-video-core
    4. opkg install kmod-video-uvc
    5. (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.)
    6. (I installed both drivers as I don't know which device driver is suitable at my very beginning of this test.)
  7. 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
  8. You also need to install mjpg-streamer:
    1. opkg install mjpg-streamer
  9. Enable mjpg-streamer to be autorun:
    1. /etc/init.d/mjpg-streamer enable
  10. Then reboot your router
  11. Verify if your USB webcam is detected as video device:
    1. ls /dev/video*
      [root@mybox:/root]#ls /dev/video*
      /dev/video0

  12. Check if mjpg-streamer is running on 8080
    1. netstat -an | grep 8080
    2. ps | grep mjpg_streamer
  13. If it is not running yet, we can run it manually:
    1. 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 failed
      But in my case, I cannot run the program in default input option.  I need to specify the resolution as recommended by the program.
    2. 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
      1. It is because the CCD native resolution is 352 x 288!
    3. I have never succeed in using my OV519 cam!
    4. -i is for input options:
      1. -r is to specify the resolution to a supported resolution, rather than the default 640x480
      2. If your Webcam does not support JPEG format, you can turn to YUVY mode by adding -yuv in your input option.
    5. -o is for output options:
      1.  -p for port number
  14.  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
  15. Press Ctrl-C to break after testing
  16. If you can see the output, then we need to save the verified config into config file at /etc/config/mjpg-streamer
    1. open editor: vi /etc/config/mjpg-streamer
    2. Press Esc, then a to start editing
    3. 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'
    4.  Press Esc, then :wq to save and quit
  17. use command /etc/init.d/mjpg-streamer enable to enable auto start of the service.
  18. use command /etc/init.d/mjpg-streamer start to manually start the service.
  19. use ps command to verify if the process has been run:
    1.  #ps | grep mjpg
       2575 root      8320 S    /usr/bin/mjpg_streamer --input input_uvc.so --device
  20.  Then reboot and test the URL again for final check.  That's it.

Comments

Anonymous said…
kmod-video-gspca-zc3xx
Anonymous said…
Many BIG thanks!!
Anonymous said…
What about audio?

Popular Posts