OpenWrt Forum Archive

Topic: [Asus WL-500Gp] Using OpenWRT to record WebCam snapshots to USB drive

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

[WebCam] Using OpenWRT to record WebCam snapshots to USB drive

With this tutorial you'll be able to take snapshots from a WebCam every second and save them to your USB drive.

Prerequisites

  • Asus WL-500G Premium (important note: it must not be the V2 version!)

  • USB thumb drive (to save WebCam snapshots on) - either 4 GB (holds approx. 12 hours of snapshots) or 8 GB (holds approx. 24 hours)

  • Logitech QuickCam Pro 5000 (for other supported WebCams, see this and this list)

  • (Optional) Tp-Link TL-WN560G Mini PCI card (the one that comes with the router doesn't work with our firmware)

Installing OpenWRT firmware

  • Download this OpenWRT firmware and save it to desktop

  • Connect the router to your PC using port 1 - also disconnect any other LAN connections to your PC

  • Change the IP of your NIC to 192.168.1.10 and the subnet mask to 255.255.255.0

  • Push and hold the restore button and power on your router - the ON light should blink once a second

  • Wait 40 seconds and pull the power cord from the router

  • Change your PC's NIC IP settings to automatic (DHCP); you can also reattach any other connections

  • Turn on your router - the ON light shouldn't blink anymore - if it does, upload the firmware again and this time wait a little bit longer

  • After rebooting the router, you can no longer connect via telnet - you must use SSH; use PuTTY to connect to your router (its IP is 192.168.86.1) and login with "root" as username and with the passwod you chose

WLAN configuration

  • If you wish to use WLAN to connect to your router, you must open it and replace its wireless card

  • Edit the file /etc/config/wireless: add "#" before "option disabled 1"

  • Change the SSID at "option ssid", set "option encryption" to "psk2" and add "option key [your-password]"

Preparing the USB drive

  • Connect the USB drive to one of the router's 2 USB ports and wait approx. 10 seconds for the drive to initialize

  • You can access the files on your USB drive with any FTP client - use 192.168.86.1 for IP, username is "root" and the passwod is the one you chose earlier

Making the startup script

Additional

    Sources:

    cd [folder]

    (Last edited by KoMar on 20 May 2011, 11:24)

    Nice smile

    Thanks smile

    And FYI, the firmware is a freshly compiled trunk from SVN with the newest mjpg_streamer smile

    Very interesting. I want to do the same thing for the NSLU2 and a QC9000, so I'm rying to build the appropriate firmware from trunk just as you have. My builds seem to hang during startup, though, so I suspect I don't have the right kernel modules, or something. Could you possibly post the output of lsmod & ipkg list?

    Is there any particular advantage to building a unified firmware like this rather than starting with the stock build and loading the relevant packages/modules with ipkg and insmod, as required, until it works?

    Thanks,
    Nigel

    lsmod:

    root@OpenWrt:~# lsmod
    Module                  Size  Used by    Tainted: P
    uvcvideo               45744  1
    sg                     24704  0
    videodev               23104  2 uvcvideo
    compat_ioctl32           448  1 uvcvideo
    v4l1_compat            11280  2 uvcvideo,videodev
    v4l2_common            12608  2 uvcvideo,videodev
    usb_storage            28032  2
    uhci_hcd               19920  0
    ohci_hcd               16656  0
    ath_pci               114352  0
    wlan_xauth               480  0
    wlan_wep                4000  0
    wlan_tkip               9664  0
    wlan_ccmp               5440  3
    wlan_acl                1920  0
    ath_rate_minstrel       8256  1
    ath_hal               271168  3 ath_pci,ath_rate_minstrel
    wlan_scan_sta           8768  1
    wlan_scan_ap            6656  0
    wlan                  152592  10 ath_pci,wlan_xauth,wlan_wep,wlan_tkip,wlan_ccmp,wlan_acl,ath_rate_minstrel,wlan_scan_sta,wlan_scan_ap
    sd_mod                 18512  3
    nf_nat_tftp              480  0
    nf_conntrack_tftp       2480  1 nf_nat_tftp
    nf_nat_irc               960  0
    nf_conntrack_irc        2832  1 nf_nat_irc
    nf_nat_ftp              1472  0
    nf_conntrack_ftp        5152  1 nf_nat_ftp
    ppp_async               9856  0
    ppp_generic            20192  1 ppp_async
    slhc                    5376  1 ppp_generic
    crc_ccitt               1024  1 ppp_async
    ext3                   98064  1
    jbd                    55408  1 ext3
    usbcore               106576  5 uvcvideo,usb_storage,uhci_hcd,ohci_hcd
    scsi_mod               72256  3 sg,usb_storage,sd_mod
    switch_robo             4224  0
    switch_core             5024  1 switch_robo
    diag                    7056  0

    ipkg:

    root@OpenWrt:~# ipkg list_installed
    base-files-brcm47xx - 12-r10538 -
    bridge - 1.0.6-1 -
    busybox - 1.8.2-1 -
    dnsmasq - 2.40-1 -
    dropbear - 0.50-3 -
    e2fsprogs - 1.39-1 -
    fdisk - 2.13.0.1-1 -
    hostapd - 20071107_03ec0ec5cdb974d51a4a2a566bea4c4568138576-1 -
    hostapd-utils - 20071107_03ec0ec5cdb974d51a4a2a566bea4c4568138576-1 -
    hotplug2 - 0.9+r102-2 -
    iptables - 1.3.8-2 -
    kernel - 2.6.23.16-brcm47xx-1 -
    kmod-diag - 2.6.23.16-brcm47xx-2 -
    kmod-fs-ext3 - 2.6.23.16-brcm47xx-1 -
    kmod-ipt-nathelper - 2.6.23.16-brcm47xx-1 -
    kmod-madwifi - 2.6.23.16+r3314-brcm47xx-1 -
    kmod-ppp - 2.6.23.16-brcm47xx-1 -
    kmod-pppoe - 2.6.23.16-brcm47xx-1 -
    kmod-scsi-core - 2.6.23.16-brcm47xx-1 -
    kmod-scsi-generic - 2.6.23.16-brcm47xx-1 -
    kmod-switch - 2.6.23.16-brcm47xx-1 -
    kmod-usb-core - 2.6.23.16-brcm47xx-1 -
    kmod-usb-ohci - 2.6.23.16-brcm47xx-1 -
    kmod-usb-storage - 2.6.23.16-brcm47xx-1 -
    kmod-usb-uhci - 2.6.23.16-brcm47xx-1 -
    kmod-video-core - 2.6.23.16-brcm47xx-1 -
    kmod-video-uvc - 2.6.23.16+r151-brcm47xx-1 -
    libblkid - 1.39-1 -
    libgcc - 4.1.2-12 -
    libjpeg - 6b-1 -
    libopenssl - 0.9.8e-3 -
    libpthread - 0.9.29-12 -
    libuci - 0.3.0-1 -
    libuuid - 1.39-1 -
    mjpg-streamer - rev56-1 -
    mtd - 6 -
    ntpclient - 2003_194-6 -
    ppp - 2.4.3-9 -
    ppp-mod-pppoe - 2.4.3-9 -
    swap-utils - 2.13.0.1-1 -
    uci - 0.3.0-1 -
    uclibc - 0.9.29-12 -
    udevtrigger - 106-1 -
    vsftpd - 2.0.5-2 -
    wireless-tools - 29-2 -
    wpa-cli - 0.5.9-1 -
    wpa-supplicant - 0.5.9-1 -
    zlib - 1.2.3-5 -
    Done.

    Please note that I do not have USB 2.0 enabled in my firmware image since there could be issues with my QuickCam 5000 Pro.

    The primary advantage to building your own firmware image is you don't have to install everything seperately - it just works out of the box smile

    (Last edited by KoMar on 14 Mar 2008, 11:31)

    Very good. Has anyone tried the 2.4 kernel instead of 2.6. I cannot get the wifi to work with 2.6. Thanks.

    2.4 does not support UVC webcams... and of course you cannot get WLAN to work - that's why you need to replace the MiniPCI WLAN card inside with an Atheros one wink

    have you suceeded in enabling USB 2.0 support?

    I followed koMar's instruction and I it's working perfect with Logitech QuickCam Pro 9000. The only thing it work is that code I insert into /etc/init.d/done is not exectued, so I have to manually enter mount and mjpeg_streamer command everytime I reboot the router. If I try to enter following command, I get response:

    root@OpenWrt:~# /etc/init.d/done
    /bin/sh: can't open /etc/rc.common

    I would also like to make some additional steps:
    - put router in wireless client mode, that it will connect to my existing wireless network
    - save images to Windows server share in local network, instead on USB key
    - is it possible to enable motion detector with wl-500gp and make picture only when camera captures the motion

    About wireless part I managed to reconfigure wireless and network file, so wireless part get's ip number 192.168.1.107 from dhcp, but if I remove lan cable from router, it's not possible to connect to router on his ip anymore?

    Here are my wireless settings:

    config wifi-device  wifi0
        option type         atheros
        #option channel      auto
        option channel       6
        option txantenna     2
        option rxantenna     2
    
        # REMOVE THIS LINE TO ENABLE WIFI:
        #option disabled     1
    
    config wifi-iface
        option device    wifi0
        option network    wlan
        #option mode        ap
        option mode         sta
        option ssid         BENEDICIC
        option encryption    psk
        option key        [password]

    Network settings:

    config 'switch' 'eth0'
        option 'vlan0'     '1 2 3 4 5*'
        option 'vlan1'     '0 5'
    
    config 'interface' 'loopback'
        option 'ifname'     'lo'
        option 'proto'     'static'
        option 'ipaddr'     '127.0.0.1'
        option 'netmask'     '255.0.0.0'
    
    config 'interface' 'lan'
        option 'type'     'bridge'
        option 'ifname'     'eth0.0'
        option 'proto'     'static'
        option 'ipaddr'     '192.168.1.50'
        option 'netmask'     '255.255.255.0'
        option 'gateway'     '192.168.1.1'
        option 'dns'         '192.168.1.1'
    
    config 'interface' 'wan'
        option 'ifname'     'eth0.1'
        option 'proto'     'dhcp'
    
    config 'interface' 'wlan'
        option 'ifname'     'wifi0'
        option 'proto'     'dhcp'

    Response I get from "ifconfig" is:

    root@OpenWrt:~# ifconfig
    ath0      Link encap:Ethernet  HWaddr 00:1D:0F:AF:AD:57
              inet addr:192.168.1.107  Bcast:192.168.1.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:374 errors:0 dropped:0 overruns:0 frame:0
              TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:39764 (38.8 KiB)  TX bytes:1099 (1.0 KiB)
    
    br-lan    Link encap:Ethernet  HWaddr 00:18:F3:3B:69:9C
              inet addr:192.168.1.50  Bcast:192.168.1.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1310 errors:0 dropped:0 overruns:0 frame:0
              TX packets:532 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:163561 (159.7 KiB)  TX bytes:64693 (63.1 KiB)
    
    eth0      Link encap:Ethernet  HWaddr 00:18:F3:3B:69:9C
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1302 errors:0 dropped:0 overruns:0 frame:0
              TX packets:810 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:191345 (186.8 KiB)  TX bytes:162041 (158.2 KiB)
              Interrupt:4
    
    eth0.0    Link encap:Ethernet  HWaddr 00:18:F3:3B:69:9C
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1310 errors:0 dropped:0 overruns:0 frame:0
              TX packets:532 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:168801 (164.8 KiB)  TX bytes:66821 (65.2 KiB)
    
    eth0.1    Link encap:Ethernet  HWaddr 00:18:F3:3B:69:9C
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:286 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:0 (0.0 B)  TX bytes:92664 (90.4 KiB)
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:13 errors:0 dropped:0 overruns:0 frame:0
              TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:1064 (1.0 KiB)  TX bytes:1064 (1.0 KiB)
    
    wifi0     Link encap:UNSPEC  HWaddr 00-1D-0F-AF-AD-57-98-0E-00-00-00-00-00-00-00-00
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:15485 errors:0 dropped:0 overruns:0 frame:5
              TX packets:163 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:195
              RX bytes:2089583 (1.9 MiB)  TX bytes:11220 (10.9 KiB)
              Interrupt:6

    And "iwconfig":

    root@OpenWrt:~# iwconfig
    lo        no wireless extensions.
    
    eth0      no wireless extensions.
    
    eth1      no wireless extensions.
    
    eth0.0    no wireless extensions.
    
    eth0.1    no wireless extensions.
    
    br-lan    no wireless extensions.
    
    wifi0     no wireless extensions.
    
    ath0      IEEE 802.11g  ESSID:"BENEDICIC"  Nickname:""
              Mode:Managed  Frequency:2.437 GHz  Access Point: 00:14:BF:A5:43:52
              Bit Rate:36 Mb/s   Tx-Power:16 dBm   Sensitivity=1/1
              Retry:off   RTS thr:off   Fragment thr:off
              Encryption key:B35D-59C8-52D7-AF51-2416-6FD1-C944-B054   Security mode:restricted
              Power Management:off
              Link Quality=35/70  Signal level=-61 dBm  Noise level=-96 dBm
              Rx invalid nwid:7336  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:0   Missed beacon:0

    I am not so experienced in linux so I will be appreciate for any help!

    Nobody with some idea?

    Urose, so what is you question regarding the camera? It could be possible to save captured pictures to remote server, but regarding the motion detection it could require more resources than just UVC capture/stream.... there is also package "motion"...

    I would like to figure it out why my "done" script is not executing at boot and why my router doesn't want to work in wireless client mode if LAN cable is not connected (if it is connected it works - it gets new ip on wifi and I can connect with ssh).
    Is there any example how to configure motion with settings that cpu on wl-500gp will manage?

    I was searching for some tips how to save captures images to remote (local) server, but I didn't find anything.

    Check on you AP if the WL500GP is associated? Chech your DHCP settings. Try to setup manual ip on WiFi interface of client router.

    Try just for test disabling encryption. What WiFi card do you have (factory default - broadcom?)? Is your kernel 2.6?

    Also check http://forum.openwrt.org/viewtopic.php?id=11502 for settiong in sta mode with wpa

    I have tried everything... static IP, disabled encryption. I replaced wi-fi card with the one kOmAR suggested and wi-fi is connected and is working (it gets ip 192.168.1.107 and I can ssh), but if I unplug LAN cable and reboot, it's not possible to connect with ssh anymore. Wi-fi is still connected (I see connected clients on AP).

    Kernel is 2.6, I followed instructions step by step.

    Hi, I am new in OpenWrt. I installed before dd-wrt. I wanted to change because it had not support for UVC´s webcam. I felt very lucky to found this post (some days before I received a mini PCI atheros card). Yesterday I installed.

    I have followed it this post, step, to step, but I have a big problem.

    My router needs to use a specific MAC-address in order to connect to the Internet (WAN). How do I change my MAC-address in this version?.In this moment, this router doesn´t connect to the Internet.

    The previous version, in the OpenWrt page says how to do it (MAC address cloning) . But now, the nvram´s variables, exactly "wan_hwaddr", don´t exist. The solution doesn´t work now.

    Can you give me a solution for this?.

    Thank you.

    I had found the answer. And it works!!!!

    It is the next:

    This is how settings for WAN look like in /etc/config/network :

    #### WAN configuration
    config interface        wan
            option ifname   "eth0.1"
            option proto    dhcp
            option macaddr XX:XX:XX:XX:XX:XX

    Being XX:XX:XX:XX:XX:XX the MAC address given by the Internet supplier

    Greetings

    P.S. Thanks to Crow

    (Last edited by Jhon_Doe on 28 Nov 2008, 23:38)

    My webcam works. But the router can´t do anything more. I can´t  conect to internet at the same time.

    And now, I don´t know how to unactivate the webcam recording. I have a 8 GB USB drive. I tried to add "#" before the options of file "/etc/init.d/done"

    umount /dev/sda1
    e2fsck /dev/sda1
    mount /dev/sda1 /mnt
    killall httpd
    while true; do
    mjpg_streamer -i "input_uvc.so -f 15" -o "output_http.so -p 80 -w /webcam_www" -o "output_file12h.so -f /mnt -d 1000"
    done

    But said to me the  the unit is full. I couldn´t save it.

    Help! What can I do?

    Greetings

    (Last edited by Jhon_Doe on 29 Nov 2008, 12:01)

    I solved the previous question: I conected via FTP, deleted the images files and changed the file "/etc/init.d/done" directly.

    I have a new doubt. What version is  this: http://rapidshare.com/files/117509522/o … s.trx.html? I would like to know it  because I wanted  to install ipkg, and I wouldn´t  like to  mix different  versions.

    And now I have a bigger problem. When I was instaling somehing (for example activing swap), I don´t know when it has happened, the router is working, I can access to it by FTP and by SSH(with Putty), but I lose the Internet connection and twice. After watching the configuration files, I didn´t find any reason for this problems.The only thing I thought was to "flash" it again with the version of this post. This time I didn´t even install the webcam. I was trying to install ipkg files and I lost the Internet connection (in both cases, the connection only work less than an hour).

    Can you give any idea about this problem? 

    Thank you.

    (Last edited by Jhon_Doe on 30 Nov 2008, 13:51)

    I have solved the problem about the Internet connection. The solution was: /etc/init.d/network restart.

    How to do it regularly in order to keep the connection ?

    Thank you.

    Hi,
    The most recent MJPG-streamer (r78) revision contains some changes for the "output_file.so" plugin. There are also a few scripting examples (subfolder "examples") how you can deal with the files. Renaming a file and storing it in some special way can be implemented with a little script, it should not be necessary anymore to patch the plugin.

    There is also a ringbuffer, which keeps the last N files.
    I improved the performance to the previous version. Also, if you allow the ringbuffer to exceed the number N by lets say 10, it will only tidy up the destination folder every tenth picture, thus lesser runs of the cleanup routine, thus saving CPU cycles.

    Regards,
    Tom

    I which mjpg-streamer has an easier syntax for it's CLI usage so one could easier write an LuCI application for it...

    (Last edited by Yanira on 27 Jan 2009, 10:48)

    Hi Yanira,
    Yes, I tried to write a LuCI config one night myself, but I could not find a good solution how to write such a file. However, recommendations are welcome. I think it is not really a matter of the command line parameters, it is more a matter of understanding how to make the config file as modular as the program. It is not an easy config to start with LuCI (which i tried anyway without results).

    I really would like to ask some of the more experienced LuCI developers to have a look at it.

    Regards,
    Tom

    (Last edited by Tom on 1 Feb 2009, 06:20)

    I have 2 webcams Logitech Sphere AF that works perfect with WL-500G Premium (Kamikaze 7.09), but I would like to know two things:

    1. How can I start both webcams automaticaly when router turns on? Right now I am using following command in /etc/init.d/done:

    killall httpd
    while true; do
    mjpg_streamer -i "input_uvc.so --device /dev/video0" -o "output_http.so -p 91 -w /webcam_www"
    done

    and then I have to log in router manually and also enter command for second camera:
    mjpg_streamer -i "input_uvc.so --device /dev/video1" -o "output_http.so -p 92 -w /webcam_www" &

    Is it possible to run both commands in this loop in script /etc/init.d/done?


    2. I was searching on internet how it is possible to turn the picture upsite-down, because I would like to mount camera upsite-down too, so the picture should be turned then?


    And I realized one more thing... Tom's instructions for installing mjpg_streamer are only for Kamikaze 7.09: http://mjpg-streamer.wiki.sourceforge.n … cam-server
    I was trying to make it work on latest release 8.09 RC2, but I didn't managed to run mjpg_streamer. For example, ipkg is gone, now there is a command opkg instead. Unforunatelly I am not so experienced in linux, I am only following step-by-step manuals smile

    If have finally managed to run both cameras on the same time at startup - it was parameter "-b" missing:

    killall httpd
    while true; do
    mjpg_streamer -i "input_uvc.so --device /dev/video0" -o "output_http.so -p 91 -w /webcam_www" -b
    mjpg_streamer -i "input_uvc.so --device /dev/video1" -o "output_http.so -p 92 -w /webcam_www" -b
    done


    Now I only have to figure out how to make image upsite-down with mjpg_streamer if it is even possible?

    Is there anyone advanced in C programming who can help me with two things:

    1. modificate output plugin "output_file.so" to make new folder every day and every our, for example:
    \2008-02-04
    \2008-02-04\00-00
    \2008-02-04\01-00
    \2008-02-04\02-00
    \2008-02-04\03-00
    \2008-02-04\...
    \2008-02-05
    \2008-02-05\00-00
    \2008-02-05\01-00
    \2008-02-05\02-00
    \2008-02-05\03-00
    \2008-02-05\...
    \...

    2. modificate input plugin to add rotate function or vertical/horizontally mirrored (as Logitech driver has from default). This will be useful for all who will have webcam mounted upsite-down.

    The discussion might have continued from here.