TL-WR703N Example Project 4 : Webcam Streaming

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? 🙂

33 thoughts on “TL-WR703N Example Project 4 : Webcam Streaming”

  1. 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.

    1. 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.

      1. 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. 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. 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

    1. I experienced similar problem as you did before.
      i.e. get below reply
      mjpg_streamer: unrecognized option `-n’

      Did you manage to resolve the problem?
      If YES, How? Please help.

      1. in the start up configuration paste the following:

        /etc/init.d/mjpg-streamer enable
        mjpg_streamer -i “input_uvc.so” -o “output_http.so -p 8090″ &

        (make sure to save it)

        browse to 192.168.1.1:8090/?action=stream

  4. 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.

  5. 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

  6. 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/

  7. 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

  8. Hi!
    I flashed your firmware (Openwrt TLWR703_2013-07-02) into my router, but I don’t know how to start .I cannot get on the web of the router by 192.168.1.1, nor telnet/ssh to the IP . Please give me help .Thank you!

    1. Are you plugging in via Ethernet cable and confirming you’re getting a DHCP address? You need to set your IP to automatic, or manually configure it to be something like 192.168.1.200.

      1. Dear Madox:Thank you for your hints, but I didn’t expect you could answer me so fast, and before you answered me I went in failsafe mode and telneted to the router and did ‘firstboot’ so that I could change the password of root and use the defualt IP. Then I exit and restarted the router, but I can no longer ssh to the defualt IP of the router as a root with changed password. So that my router became a ‘ brick’, could you help me save my router? I’m very sad!

  9. Hello Madox
    Before mid August, everything works fine. I didn’t change the WR703N configuration .
    But since mid-August the “stream” does not work, but the snapshoot works good.
    I tested several web browser on PC IE9 and Chrome and Android with the default browser and chrome same problem on all.
    Do you see this problem?

    1. My camera’s id codes for the usb were listed here: http://www.ideasonboard.org/uvc/ , so I knew that at least my camera “should” work. However it did not. And mucking about I finally ended up where you’re at…..

      Eventually adjusting the resolution and frame rate fixed this for me. To figure out what settings might work well I checked the manufacturer’s specs for the device (this helped with the frame rate setting which was -f 8 in mjpg_streamer). Then I plugged the webcam into another computer and ran “fswebcam” in verbose mode (i.e. the command is -> fswebcam –verbose). This helped me with the proper resolution setting in mjpg_streamer resolution (-r 320×240) and let me know that the camera also only worked in YUV mode (i.e. this required adding -y after “input_uvc.so”.

      (Oh yeah, I did finally have to add in a -n to the “input” string to turn off the camera control stuff (pan, tilt and so forth).)

      Hope that helps some.

      – Bob, w9ya

  10. Hello Madox and thanks for your posts!
    I have read and followed your instructions. I am using a TL-703N router (Blue Color) V1.6
    When I plug in the camera, I get the following errors:
    root@OpenWrt:/# [ 78.810000] usb 1-1: new full-speed USB device number 2 using ehci-platform
    [ 79.030000] usb 1-1: device descriptor read/64, error -71
    [ 79.350000] usb 1-1: device descriptor read/64, error -71
    [ 79.580000] usb 1-1: new full-speed USB device number 3 using ehci-platform
    [ 79.800000] usb 1-1: device descriptor read/64, error -71
    [ 80.120000] usb 1-1: device descriptor read/64, error -71
    [ 80.350000] usb 1-1: new full-speed USB device number 4 using ehci-platform
    [ 80.830000] usb 1-1: device not accepting address 4, error -71
    [ 80.950000] usb 1-1: new full-speed USB device number 5 using ehci-platform
    [ 81.430000] usb 1-1: device not accepting address 5, error -71
    [ 81.430000] hub 1-0:1.0: unable to enumerate USB device on port 1
    Any ideas of what may be the problem?
    Thanks!

  11. My cam needs the kmod-video-gspca-pac7311 driver, but I’m not sure how I could get that loaded. I’m running your image Standard 35706_2013_02_23

  12. Newbie help needed. First off, I’m way out of my depth. I’m an ME gear head who is only capable of typing or copying specific instructions. I do not know my DHCP from my TCIP.

    My goal is to wirelessly connect an old Logitech QuickCam Pro 5000 USB camera for a robot project. Right now I’m trying to view the video over a wired connection. The pixel range for this camera is 320 x 240.

    So far I have flashed the OpenWRT images below from the original Chinese firmware. This should be the standard images:

    openwrt_tl-wr703n_standard_2013-02-23_squash-factory.bin
    openwrt_tl-wr703n_standard_2013-02-23_squash-sysupgrade.bin

    When I log on to the server using IE the firmware is shown as:

    Madox TL-WR703N Standard 35706_2013-02-23 / LuCI Trunk (trunk+svn9668)

    I set up to my wireless router in my home, and got the wwan highlight to turn green. It looks like it’s connected.
    Uptime: 0h 33m 12s
    MAC-Address: 0C:82:68:DD:CB:4A
    RX: 574.73 KB (2747 Pkts.)
    TX: 1.26 KB (5 Pkts.)
    IPv4: 192.168.1.9/24

    So I’ve gotten pretty far and managed to not brick my device which took almost a month to get here to Chicago from China.
    FOR THE PURPOSE OF MY QUESTION BELOW I’M USING THE WIRED CONNECTION

    So the next thing I want to do is hook up my old Logitech QuickCam Pro 5000 web cam and start to pull in images.

    So I plug the camera into the TP-Link
    Plug network cable into my laptop, and into the TP-Link

    Using Putty.exe to connect to 192.168.1.1 using SSH (whatever SSH is)

    Login to server from Putty: root / root

    Shows I have BARRIER BREAKER (35706_2013-02-23, r35706)

    So I copy in:
    mjpg_streamer -i “./input_uvc.so -n -r VGA -f 6 -d /dev/video0″ -o “./output_http.so -p 8080 -n”
    And get an error message:
    mjpg_streamer: unrecognized option `-n’

    and a litany of other messages.

    So I try:
    mjpg_streamer -i “./input_uvc.so -n -q 60 -r QVGA -f 6 -d /dev/video0″ -o “./output_http.so -p 8080 -n”
    and get the same error message as above.

    As an alternate I paste:

    mjpg_streamer -i “input_uvc.so -r 320×240 -f 6” -o “output_http.so -p 8080”

    NOTE I change 640 to 320 and 480 to 240 to match the camera output.

    I get the following:

    MJPG Streamer Version: svn rev: exported
    i: Using V4L2 device.: /dev/video0
    i: Desired Resolution: 320 x 240
    i: Frames Per Second.: 6
    i: Format…………: MJPEG
    Adding control for Pan (relative)
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    Adding control for Tilt (relative)
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    Adding control for Pan Reset
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    Adding control for Tilt Reset
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    Adding control for Pan/tilt Reset
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    Adding control for Focus (absolute)
    UVCIOC_CTRL_ADD – Error: Inappropriate ioctl for device
    mapping control for Pan (relative)
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Tilt (relative)
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Pan Reset
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Tilt Reset
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Pan/tilt Reset
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Focus (absolute)
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for LED1 Mode
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for LED1 Frequency
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Disable video processing
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    mapping control for Raw bits per pixel
    UVCIOC_CTRL_MAP – Error: Inappropriate ioctl for device
    o: www-folder-path…: disabled
    o: HTTP TCP port…..: 8080
    o: username:password.: disabled
    o: commands……….: enabled

    Just for giggles I closed Putty, and put:
    http://192.168.1.1:8080/?action=stream
    into IE and get nothing on the screen.
    So what am I doing wrong? I feel like I’m close, but something is just missing.
    Thanks,
    Steve

    1. I had the same problem. Adding -n to the end of the input string seems to remove the pan and tilt control et al.

      – Bob, w9ya

  13. Hi Madox,
    I’m trying for 4 hours to set up a wireless connection (to my home router), with no success.
    I’ve connected to my home network as a client, set the firewall mode to LAN, and tried more methods, but I just can’t connect to the inferface using the wireless connection. Also no SSH of anything else.

    Besides, using the ethernet connection I can only see snapshots and no video (media player stuck on opening….).

    Thanks for any help!

  14. Hi Madox,

    Thanks for all the info, this has been awesome. I’ve flashed my own copy of OpenWRT and installed kmod-video-uvc mjpeg-streamer.

    However, I have a problem with my camera: I plug it in, the status LED flashes a couple of times, then it turns off.

    To me this suggests that drivers aren’t behaving?
    Any ideas? The camera works in my windows PC.
    It’s a Microsoft Lifecam HD-3000. I’ve checked, and it’s definitely UVC supported (i found that info here: http://www.ideasonboard.org/uvc/)

    1. By the way, here is a dmesg dump:

      [ 2477.460000] usb 1-1: new high-speed USB device number 5 using ehci-platform
      [ 2477.620000] uvcvideo: Found UVC 1.00 device Microsoft® LifeCam HD-3000 (045e:0779)
      [ 2477.640000] input: Microsoft® LifeCam HD-3000 as /devices/platform/ehci-platform/usb1/1-1/1-1:1.0/input/input3

      Cheers!

  15. Hi Madox,

    thanks for your work arount openwrt and wr703n.
    I am trying to use an usb webcam with the wr703n.
    From inside my private network (192.168.1.x) I have no problem
    to stream, but I don’t reach at all to stream on the internet.
    I tried to use the port forwarding, in the same way I did for my
    IP webcams but it doesn’t work.
    It is always impossible to stream it.
    I noted some change when (from luci interface) I select DHCP protocol
    addressing instead static one, but I don’t understand what difference
    there could be.

    I mean… if I use DHCP protocol, and I find the IP address assigned
    by my routher and I, on the fly, create a port forward in the router itself
    it seems that for a while the streaming in the internet is ok.

    I tried to use static addressing with firewall disabled but nothing.
    In your opinion, what I didn’t catch?
    From my point of view, static ip addressing is a need in order
    to enable the port forwarding from my public IP to my private fixed one.

    Thanks for your attention and for any help!

    lore

  16. how can i get high speed?>?? in my case i got a only 1000kb/s bitrate at 320×240 , framerate 15

    In my assumption router can operate 150Mbps wifi therefore it at best 10Mbps…..

    if you know how to get faster speed.. then plz ….send me email

  17. hello,
    i am very thanks for your work!

    but i met a problem in you firewall.
    i have use a uvc camera and i can get stream from the web site, but after a time(like ten minutes), there were no stream and i can still log on 192.168.1.1.
    but the cpu usage of mjpg_streamer is 0%.
    i don’t know why

  18. Hi , is there some way to stream over udp using the owrt box as client instead a http server?
    It would be great since my cctv system is accesible via public static interface.
    Regards.

  19. I purchased a Microsoft Lifecam HD-3000 specifically for the mjpg support.
    However, whenever I try to use it with mjpg streamer in mjpg mode, it looks like it is working, but when I go to the streaming URL I get an error message that the images can’t be displayed due to an error.

    When I add the -y or -yuv option the video shows up as it is supposed to, but of corse the CPU usage goes through the roof as it’s not using MJPG mode.

    Anybody know anything special I have to do to make the camera work? My command line is very generic….

    Thanks,
    Jay
    ./mjpg_streamer -i “input_uvc.so -d /dev/video0 -r 1280×720 -f 20” -o “output_http.so -p 8080”

  20. 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”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.