Recently I was nosing around the web on a Sunday afternoon, looking at my favorite webcams in the Faroe Islands. I like to keep an eye on what the weather is like over there because my family and I are planning a trip to the Faroe Islands, Iceland, and Ireland.
Since the weather is so changeable, I thought it would be great if I could somehow get shots from a webcam every 15 seconds over a 24-hour period. I could then make an animated video of all (or a portion) of the 24 hours. I did some searching on the web for freeware tools, but I didn't find anything that suited my simple yet specific needs. So, I built my own tool using VBScript.
The script, GetWebJPG.vbs, runs using Windows Script Host's (WSH's) CScript host environment. It creates the output folder needed to hold the webcam images if it doesn't already exist. After the folder is created, the script sends the web server an HTTP GET request for the current webcam .jpg file and saves a copy of it locally. GetWebJPG.vbs then goes to sleep until it's time to get the next picture. Each locally saved file is sequentially numbered.
GetWebJPG.vbs runs against the web server at the designated intervals until it reaches the maximum loop limit specified by the value of the MAXLOOP constant. The script will also stop if it encounters what I consider a "fatal" error (e.g., the web server goes offline). If you restart the script, it will resume from the last saved file.
Other types of errors can be included or excluded in GetWebJPG.vbs. For instance, I currently allow the script to continue on a typical 404 "not found" error, since the web server might have simply hiccupped. I didn't want the script to terminate due to a single missing file. The script's error checking is pretty minimal, so you might want to modify it as you encounter errors, deciding which errors can be ignored and which errors should stop the script.
You can download GetWebJPG.vbs by clicking the Download the Code Here button near the top of the page. I left a working webcam location in it so that you can collect .jpg files of the only airport in the Faroe Islands. As Listing 1 shows, the script captures copies of the webcam .jpg files generated at http://220.127.116.11/webcam/image.jpg. It captures a .jpg file every 15 seconds for more than 40 hours (i.e., 10,000 loops) and saves the files to the C:\WebShots folder. Each file is sequentially numbered, starting from FAE000001.jpg, so you'd get FAE000001.jpg, FAE000002.jpg, FAE000003.jpg, and so on.
Listing 1: Current Constant Settings in GetWebJPG.vbs
Const WEBFILE = "webcam/image.jpg"
Const MAXSECONDS = 15
Const MAXLOOP = 10000
Const DRIVE = "C:"
Const DOWNLOADS = "WebShots"
Const PREFIX = "FAE"
You can run more than one script against a web server to collect pictures from different webcams on that server. For example, if you want to run a second script to collect pictures from the second webcam at the Faroe Islands airport, you'd change the WEBFILE constant to "webcam/image31.jpg" and change the PREFIX constant to "FAE2". Because the set of files for the second webcam has a different prefix than the set of files for the first webcam, you can store the images from both webcams in the same folder.
An Internet search on webcams or web cameras can help you find other websites with webcams. Let's say you want to get copies of the webcam .jpg files generated by the Wiley Coyote website at http://www.acmecoyote.com/wiley/cam/roadrunner.jpg. You want to capture a .jpg file every 30 seconds for 24 hours (i.e., 2,880 loops) and save the files to the D:\WebShots folder. You want each file to be sequentially numbered, starting from RR000001.jpg, so you'd get RR000001.jpg RR000002.jpg, RR000003.jpg, and so on. To do this, you would modify the script's constants as Listing 2 shows, then run the script. (Note that http://www.acmecoyote.com/wiley/cam/roadrunner.jpg is a fictitious website, so if you want to run the script, you need to substitute your favorite webcam or use GetWebJPG.vbs as is.)
Listing 2: Example of Modified Constant Settings
Const WEBROOT = "www.acmecoyote.com"
Const WEBFILE = "wiley/cam/roadrunner.jpg"
Const MAXSECONDS = 30
Const MAXLOOP = 2880
Const DRIVE = "D:"
Const DOWNLOADS = "WebShots"
Const PREFIX = "RR"
After the 24 hours are up, you can check the pictures and decide whether you want to use some or all of them in your animated video. If you need to crop the pictures before building your movie, Microsoft Office Picture Manager (which is included with Microsoft Office) works pretty easily:
- Open Microsoft Office Picture Manager, and select Add Picture Shortcut on the File menu. Navigate to the folder containing the .jpg files, select it, and click Add.
- Select Thumbnails on the View menu, then choose Select All on the Edit menu.
- Click Edit Pictures, then select Crop in the Edit Pictures pane.
- Crop the first picture the way that you want all of them to be cropped. Click OK.
- Save them all by selecting Save All on the File menu.
Once the files are ready, you can use your favorite image or video editor to animate them. I use Windows Live Movie Maker to load the pictures and build a movie.
Here are two low-resolution animated videos I created from .jpg files collected with GetWebJPG.vbs. One animated video (April12.wmv) compresses just under three hours' worth of activity at the airport into 18 seconds.
The other animated video (April18.wmv) shows how empty the airport was in the aftermath of the Icelandic volcano eruption earlier this year. It also shows how changeable the weather can be in a three-hour period, which is compressed into 23 seconds.
I currently have several different scripts running on my computer, happily gathering webcam shots at specified intervals and saving them to my hard disk. The CPU and memory usage is pretty minimal, and the results are sometimes spectacular.