Capture Live Webcam Images and Create Time-Lapse Videos with Linksys WVC54GCA

On occasion I get an e-mail asking me about my live webcam. What model is it? Does it support FTP/SSH? How does it automatically upload to your site? And so on...

Some answers:

Model: Linksys WVC54GCA Wireless G Home Monitoring Camera
FTP/SSH support: Nope

Capturing Live Images

So how do I automate taking pictures with the thing? Well, a hidden feature to the camera is to navigate to the static picture site of the webcam. For my example, I use DNS to map my camera hostname garfunkel to its IP address. You may want to enter whatever IP your camera uses instead of garfunkel.
http://garfunkel/img/snapshot.cgi?size=3&quality=1
To grab a picture at any given time, use wget.
wget http://garfunkel/img/snapshot.cgi?size=3\\&quality=1 -O webcam.jpg
If you have a UNIX-based or UNIX-like OS, you can schedule a cron job to grab this image as often as you like. I prefer capturing once every half hour, so I use this template:
\*/30 \* \* \* \* /path/to/wget/script
Now, if you have your own web page, you can use ftp/sftp/scp to upload the picture to your server using one script.

Creating Time-Lapse Videos

If you can capture a picture once every minute, you can create a pretty neat time-lapse video every day. This can be accomplished using wget and ffmpeg. For my camera, I point it outside, so it's only worth capturing between certain hours, say 6am to 6pm. After 6pm, I will have created over 700 pictures. I can then use ffmpeg to stitch them together to form a short video on the day's weather. It's a little complicated to discuss every detail behind this, so I'll just post the bourne script I use.
#!/bin/sh

hour=`date +%H`
captime=`date +%H%M`
dirpath="/location/of/your/timelapse/directory"
img=`ls ${dirpath}\*jpg | wc -l`;
expr=`expr 1 + $img`

timelapse()
{
	# File format will be Month.Day.Year.flv (flv for flash)
	date=`date +%m.%d.%y.flv`

	# ffmpeg reads in each image and incrementally makes a flash video at
	# 16 fps
	cd ${dirpath}
	ffmpeg -i %04d.jpg -r 16 ${dirpath}${date}

        # Cleanup, upload time-lapse to server and remove all jpg files
	# scp user@host:location
	# rm ${dirpath}\*jpg
}

capture()
{
        # ffmpeg expects pictures in the format 0001.jpg ... 0001.jpg so
        # we need to add a fluff of zeros to make each pic 4 digits long

	if [ $expr -lt 10 ]
	then
        	expr="000${expr}"

	elif [ $expr -lt 100 ]
	then
        	expr="00${expr}"

	elif [ $expr -lt 1000 ]
	then
        	expr="0${expr}"
	fi

        wget http://garfunkel/img/snapshot.cgi?size=3\\&quality=1 --output-document=${dirpath}${expr}.jpg
} 

case "$hour" in
# Eliminate the hours of the day that are too dark to capture
00|01|02|03|04|05|19|20|21|22|23)
	;;
# If it is 6:00pm (18), time to make a video
18)
	if [ $captime -eq 1800 ]
	then
		timelapse
	fi
	;;
# Every other hour is assumed to have light, so take a pic
\*)
	capture
	;;
esac
You might want to change the dirpath variable to wherever you want to store the pictures. Finally, add a cron entry to run every minute:
\* \* \* \* \* /path/to/timelapse/script
After 6pm, you will have an flv file. This is a flash file that can be played by various flash players for viewing on the web. You can change the file format to avi or mpg instead of flv if you just want to view it on your computer.

Sample video from my camera

Comments:

this is fav

Posted by guest on July 10, 2010 at 08:11 AM MDT #

I'm having a weird problem..seems as if

ffmpeg -i %04d.jpg -r 16 ${dirpath}${date}

Is only doing the first few pictures until the filename changes to 0010

so it makes a movie from 0001 > 0010 and stops..

any ideas? thanks

Posted by Dan on October 07, 2010 at 10:39 PM MDT #

Thanks for sharing this source..

Posted by Webcam Recorder on November 03, 2010 at 09:06 PM MDT #

Is there a capability in FFMPEG where I can save the live streaming of the video on to the hardrive?

I was trying this by using the command “ffmpeg –i http://192.168.1.3 –vcodec mpeg4 –y out.avi” .But many errors are cropping up.

So i tried to atleast get the images from the video stream. Is there any way i can do that.please help me on this.and i am trying to do this on Windows

Posted by Hansraj on January 05, 2011 at 03:48 AM MST #

Hello
Can we achieve similar image capture on a Vivotek camera?

Posted by guest on July 04, 2011 at 06:59 PM MDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Hiya, my name is Paul Johnson and I'm a software engineer working on the ZFS storage appliance .

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today