I’ve generated a couple time lapse videos in the past and I wanted to share my process with my readers.

Let’s say you’ve found a webcam source online and you wanted to capture a time lapse video from it. For instance, here is Old Faithful at Yellowstone National Park which publishes a .JPG every minute. How would you create a time lapse from it? And even better, how would you do it using completely FREE software?!

First, since the script is a Bash script you need to be running Bash. The easiest way to do this is to be running a version Linux (Ubuntu or Linux Mint are nice!) since Bash is usually the default shell. You could also use Cygwin to do this in Windows, but it is beyond the scope of this article on how to use it. From here on out, I will assume you are running Bash in Linux.

Way back in 2007 I published a Bash script that captures a URL at a provided interval and saves it to a directory. This is the heart the process. Go ahead and grab the script and save it in your home directory as iget.sh. Though it’s pretty self-explanatory there is a more detailed explanation on the script’s page as well. Once you have the script saved you need to give it execute permissions by running:

[bash] chmod +x ~/iget.sh [/bash]

Now we’re ready to capture the images. Launch a terminal session and create a directory to store the webcam images. Once created, change to that directory.

[bash] mkdir webcam cd webcam [/bash]

Run the iget.sh script with the required parameters.

[bash] ../iget.sh http://www.nps.gov/webcams-yell/oldfaithvc.jpg of.jpg 60 [/bash]

The first parameter is the URL to be downloaded. The second parameter (of.jpg) is a base file name, every file that is saved to your computer will be time stamped and ended with this. Make sure you use the same extension (.jpg) that the webcam is publishing. The third parameter (60) is the amount of seconds between captures. Since the Old Faithful webcam updates every minute, I’ve chosen 60 seconds.

Let the script run for as long as you want. After you’ve captured all the frames you want for your video, move on to the next step.

…Don’t worry, I’ll wait…

…Got them yet? Good!

Ok, the next step is to delete any duplicate frames that may exist. This can occur for a couple reasons but depending on what you’re using the video for you may or may not want to do this. I prefer to delete them since I mainly use it for entertainment purposes and it creates a smoother looking video. Save the following script to your home directory as rmdupe.sh.

[bash] #!/bin/bash

cksum * sort -n > filelist

old=”” while read sum lines filename do if [[ “$sum” != “$old” ]] ; then old=”$sum” continue fi rm -f “$filename”

done < filelist [/bash]

Give it execute permissions using chmod and then run it in the directory you saved the .JPG files to. [bash] chmod +x ~/rmdupe.sh ~/rmdupe.sh [/bash]

Great! Now we’ve got rid of all our duplicate files. The next step is to remove any frames that may be corrupt. To do this I’m going to use a utility called jpeginfo, don’t worry. It’s free. However, it may not be installed by default on your Linux distribution so you’ll have to install it.

[bash] sudo apt-get install jpeginfo [/bash]

Once it’s installed run this in the directory. It may take a while to go through but it will validate the JPEGs in the directory and delete any that fail validation. [bash] find . -name “*” -exec jpeginfo -c {} \; | grep -E “WARNING|ERROR” | cut -d “ “ -f 1 | xargs rm -r [/bash]

Now for the fun part where we convert the JPEGs to a movie. To do this I’m going to use mencoder, another free utility available in Linux. To install it run this:

[bash] sudo apt-get install mencoder [/bash]

And here’s a command to convert the JPGs to a movie. You can tweak the arguments to change the codec, framerate, bitrate so be sure to check out the documentation how to tweak it.

[bash] mencoder “mf://*.jpg” -mf fps=10 -o OldFaithful.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800 [/bash]

Once done, you’ll have a time lapse .AVI file! Here’s what it looked like after an afternoon of capturing.

Thanks for reading guys! Enjoy!

Gregory Strike

Husband, father, IT dude & blogger wrapped up into one good looking package.