[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
- Use the command line and navigate to the folder with the .trx file in it with
and execute the following command:
Code:
tftp -i 192.168.1.1 PUT openwrt-brcm47xx-stamcar-2.6-squashfs.trx
Please note: Vista users must manually install tftp and telnet: Control Panel -> Programs and Features -> Turn Windows features on or off -> check "Telnet Client" and "TFTP Client" -> OK - 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
- When the router finishes booting, type this into the command prompt:
Code:
telnet 192.168.86.1
and then
then type your desired password twice - this password will be used to login into your router after this point - Connect the internet connection to router's WAN port and execute:
- 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]"
- Then execute
Code:
/etc/init.d/network restart
to restart the network
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
- First, run the fdisk utility with
and delete any existing partitions as instructed, then type in the following commands (press "enter" after each letter or number):
Code:
n -> p -> 1 -> "enter" -> "enter"
You can now save the changes with "w" - To format the USB drive for data storage, type
Code:
mke2fs -j /dev/sda1
- 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
- To avoid manual mounting and to automatically start recording each time the router starts we need to create a startup script - edit the "/etc/init.d/done" file and add the following in a new line after "set_state done":
Code:
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
If you possess an 8 GB USB drive, type output_file24h.so instead of output_file12h.so - Now reboot your router and the recording should start automatically
- On your PC, visit http://192.168.86.1/java_simple.html and enjoy live streaming video
Additional
- ntpclient is integrated into the firmware. If you wish to change its timezone, execute the following:
Code:
echo GMT-1 > /etc/TZ
Sources: