Connecting a webcam and using the router to stream video around the place should be one of the easiest things to do. A bit too easy in that I neglected to provide simple instructions on how to set it up.

mjpg-streamer and the necessary drivers are included in the standard images I provide on the TP-Link TL-WR703N project page.

Preliminary steps :-

  1. Get a router, load it with the standard image.
  2. Set-up wireless or any other networking changes.  See an example here.
  3. Plug in the camera

Now there are two ways to get mjpg-streamer to auto-start, there is an easy way and an elegant way.

  • Easy way : Just add the command to the auto start script using LuCi…
  • Elegant way : Edit the configuration files /etc/init.d/mjpg-streamer and /etc/config/mjpg-streamer

I prefer the easy way you are less likely to screw it up.  First we should check that the camera works well with mjpg-streamer…

  1. Telnet/SSH into the router
  2. Run the following command :

    mjpg_streamer -i “./input_uvc.so -n -r VGA -f 6 -d /dev/video0″ -o “./output_http.so -p 8080 -n”

    This command uses VGA (640×480) resolution “-r VGA” at 6 frames per second “-f 6″.

  3. If that doesn’t work and an error appears, it most likely means your camera doesn’t support JPEG images.  If so, try the following command instead :

    mjpg_streamer -i “./input_uvc.so -n -q 60 -r QVGA -f 6 -d /dev/video0″ -o “./output_http.so -p 8080 -n”

    This command forces mjpg-streamer to convert into raw into JPEG at (-q) quality 60, at resolution (-r) QVGA, this can be “160×120″ for example.  The frame rate is specified by the -f (6).  This method is MUUUUUUUUCH more CPU intensive and you might have to tweak the resolution and frame rate down.

  4. Using a device connected to the router, use a web browser (e.g. Chrome) to connect to the following to get a live view:

    http://192.168.1.1:8080/?action=stream

    You can also get a single snapshot at:

     http://192.168.1.1:8080/?action=snapshot

  5. If you need to play around with the commands, use CTRL-C to kill mjpg-streamer and try again.  Avoid high resolutions (e.g. 1920×1080) as that will just crash the router.  I used 640×480 at 25 frames per second relatively happily on a JPEG enabled camera (e.g. Logitech/Microsoft ones, not the cheap no brand ones).
  6. Once you have a workable set-up, copy the command you have and put it into the local start-up.  Append the command line with an ampersand “&” so it runs in the background.  e.g.

    mjpg_streamer -i “./input_uvc.so -n -r VGA -f 6 -d /dev/video0″ -o “./output_http.so -p 8080 -n” &

    Hint – In Luci, select the Systems tab, then select Startup, scroll down to the Local Startup section and add your command to the box and press save and apply.

Enjoy? :)

Please Flattr me if you found this useful :)
13 Responses to “TL-WR703N Example Project 4 : Webcam Streaming”
  1. Korzar says:

    Hi Madox.

    I’ve run into a problem when trying to set all this up. I make all configuration changes using the wired ethernet connection, I tested mjpg-streamer and works like a charm when connected by wire. I used, as you invite to do, your wireless printer guide to set up all network related steps.

    However, when I unplug the ethernet cable and try to access the router by its assigned IP (I have a static DHCP table in my main home router to achieve this, so IP’s are bound to devices’ MAC addresses), being it connected to my Wi-Fi network, it just doesn’t load up the page, nor I can ping the device.
    I tried also your USBIP image and set up everything to test if with wireless USB worked, but no. It behaved exactly the same way. As soon as I unplug the ethernet cable, even with all the wireless networks set up, it stops working.

    Do you have any idea why is this happening? It should work as you state in your articles, but I just can’t fin the way to make the TP-Link work as a client, as if it were just another PC in my wireless network.

    • Madox says:

      Hi, I suspect you’ve missed one step that I point out in the USBIP page (Step 6). By default the WiFi will be assigned to a ‘WAN’ firewall zone that will block access, you either need to change the firewall rules for that or assign the WiFi to the ‘LAN’ firewall zone.

      • Madox says:

        Just checking – The above is the most obvious, but please do note that the MAC addresses for the WiFi and the LAN ports are different. So when you still have the LAN connected, check that the WiFi is actually connecting and the IP address is correct. Also you can check accessing your other PCs via the WiFi when you have the LAN connected so you can confirm my suspicion that it is the firewall rules before you go and tweak it :)

  2. Korzar says:

    Hi again.

    Thank you very much for answering so quickly. You were right, it was firewall’s fault. I changed it from wan to lan and it’s working perfectly.

    I’m getting quite interested to see what more can this little device do. Streaming video works very well at 720p@30fps. It’s certainly a cheap approach to a surveillance system or to add video capabilities to any robot or RC gear. I saw some of your videos in YouTube showing that : ).

    Thanks for maintaining your blog, the new compiled images for the device and for all the hard work you’re putting here. It’s so nice to meet people willing to help ^^.

  3. Simon says:

    hi Maddox,

    have a problem with my webcam. upon pasting the second command above into the SSH terminal, i get this:
    root@OpenWrt:~# mjpg_streamer -i “./input_uvc.so -n -q 60 -r QVGA -f 6 -d /dev
    /video0″ -o “./output_http.so -p 8080 -n”
    mjpg_streamer: unrecognized option `-n’
    ———————————————————————–
    Usage: mjpg_streamer
    -i | –input ” [parameters]”
    -o | –output ” [parameters]”
    [-h | --help ]……..: display this help
    [-v | --version ]…..: display version information
    [-b | --background]…: fork to the background, daemon mode
    ———————————————————————–
    Example #1:
    To open an UVC webcam “/dev/video1″ and stream it via HTTP:
    mjpg_streamer -i “input_uvc.so -d /dev/video1″ -o “output_http.so”
    ———————————————————————–
    Example #2:
    To open an UVC webcam and stream via HTTP port 8090:
    mjpg_streamer -i “input_uvc.so” -o “output_http.so -p 8090″
    ———————————————————————–
    Example #3:
    To get help for a certain input plugin:
    mjpg_streamer -i “input_uvc.so –help”
    ———————————————————————–
    In case the modules (=plugins) can not be found:
    * Set the default search path for the modules with:
    export LD_LIBRARY_PATH=/path/to/plugins,
    * or put the plugins into the “/lib/” or “/usr/lib” folder,
    * or instead of just providing the plugin file name, use a complete
    path and filename:
    mjpg_streamer -i “/path/to/modules/input_uvc.so”
    ———————————————————————–

    i then pasted the command from example 1, and it gave me this:

    root@OpenWrt:~# mjpg_streamer -i “input_uvc.so -d /dev/video1″ -o “output_http.s
    o”
    MJPG Streamer Version: svn rev: exported
    i: Using V4L2 device.: /dev/video1
    i: Desired Resolution: 640 x 480
    i: Frames Per Second.: 5
    i: Format…………: MJPEG
    ERROR opening V4L interface: No such file or directory
    Init v4L2 failed !! exit fatal
    i: init_VideoIn failed
    root@OpenWrt:~#

    can you help me?
    thanks a lot

    Simon

  4. Here’s an other guide that uses regular mjpg-streamer configuration files: http://wiki.reseaulibre.ca/guides/openwrt+webcam/

  5. simon says:

    Hi Madox,
    need a little help – having trouble following your instructions for the mini exterminator project as well as this one here. how do i copy the files from the mini exterminator project over to the router? i’ve tried ftp and sftp, as well as mounting a usb stick at /. it seems to mount right but the directory is empty, but on my computer it shows as having the two necessary files in it. also when i navigate to 192.168.1.1/webcam (my router’s IP address) the mjpeg-streamer doesn’t recognise the webcam.

    thanks a lot for any help

    Simon.

  6. mluckham says:

    Many thanks for your work! My Logitech Quickcam Pro 9000 works using your instructions, although unplugging the webcam stops mjpg_streamer. I suppose a shell script checking for /dev/video0 could respawn it.

    I tried Microsoft Lifecam VX-3000 or an even older Labtec are not detected – they are not UVC (no /dev/video0 device appears)

    – first is the Labtec (no /dev/video0)

    [ 1262.240000] usb 1-1: new high-speed USB device number 3 using ehci-platform
    [ 1262.530000] uvcvideo: Found UVC 1.00 device (046d:08ca)
    [ 1262.590000] input: UVC Camera (046d:08ca) as /devices/platform/ehci-platform/usb1/1-1/1-1:1.0/input/input1
    [ 1495.660000] usb 1-1: USB disconnect, device number 3
    [ 1495.660000] uvcvideo: Failed to resubmit video URB (-19).
    [ 1495.660000] uvcvideo: Failed to resubmit video URB (-19).

    - next the Microsoft Lifecam VX-3000 (no /dev/video0)

    [ 1509.520000] usb 1-1: new high-speed USB device number 4 using ehci-platform
    [ 1509.810000] uvcvideo: Found UVC 1.00 device (046d:08ca)
    [ 1509.870000] input: UVC Camera (046d:08ca) as /devices/platform/ehci-platform/usb1/1-1/1-1:1.0/input/input2
    [ 1576.910000] usb 1-1: USB disconnect, device number 4
    [ 1586.070000] usb 1-1: new full-speed USB device number 5 using ehci-platform
    [ 1629.410000] usb 1-1: USB disconnect, device number 5
    [ 1657.200000] usb 1-1: new full-speed USB device number 6 using ehci-platform
    [ 1666.720000] usb 1-1: USB disconnect, device number 6

    - now the Logitech Quickcam Pro 9000 (/dev/video0 appeared)

    [ 1671.930000] usb 1-1: new high-speed USB device number 7 using ehci-platform
    [ 1672.220000] uvcvideo: Found UVC 1.00 device (046d:08ca)
    [ 1672.270000] input: UVC Camera (046d:08ca) as /devices/platform/ehci-platform/usb1/1-1/1-1:1.0/input/input3

  7. mluckham says:

    Thanks for answering so quickly Madox.

    I presume you mean a powered hub – no difference. Here are the VX-3000, Labtec, and Logitech Pro 9000 all connected to the hub (one at a time, in that order, ending up with all three plugged into the hub). Only the Pro 9000 resulted in /dev/video0 appearing.

    [ 600.250000] usb 1-1.4.1: new full-speed USB device number 8 using ehci-platform
    [ 617.140000] usb 1-1.4.4: new full-speed USB device number 9 using ehci-platform
    [ 667.320000] usb 1-1.4.3: new high-speed USB device number 10 using ehci-platform
    [ 667.580000] uvcvideo: Found UVC 1.00 device (046d:08ca)
    [ 667.640000] input: UVC Camera (046d:08ca) as /devices/platform/ehci-platform/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/input/input0

    I presume it’s simply that the older webcams are not UVC-compliant. I found these:

    https://forum.openwrt.org/viewtopic.php?id=42552 which claims VX-3000 worked for them

    opkg install kmod-video-gspca-sonix doesn’t install for the Madox binary

    VX-3000 is apparently a GSPCA webcam …

    http://kyleabaker.com/2010/07/12/microsoft-lifecam-vx-1000-linux-gspca-patch/

  8. mluckham says:

    Maybe the Labtec V-UH13 different again

    http://qce-ga.sourceforge.net/

    By the way, what is your host development environment when you make builds for the WR703N?

  9. regi says:

    Hi,

    I’d like to know whether or not there is a repository where I can find these binary packages:

    kmod-video-gspca_main
    kmod-video-gspca_zc3xx

    for your TP-Link 703n 2013-02-23 standard image & kernel version.
    Linux OpenWrt 3.7.9 #4 Sat Feb 23 00:21:01 EST 2013 mips GNU/Linux

    as I have a Logitech QuickCam for Notebooks (046d:08ae)

    Many thanks in advance

  10. JA says:

    Anyone knows how to get video+sound ?

  11.  
Leave a Reply