Monthly Archive for May, 2009

How to create a time lapse video with Ubuntu

Currently I spend most of my days working from home where I have a beautiful view from my desk in the 10th floor.
I’ve always wanted to share this view with everyone by recording a 24h time lapse video.
After seeing James Broad (friend and ex-colleague back from my Yahoo days) post about Making a time lapse video on Mac it got me thinking about how I could do the same using Ubuntu.

The first thing to do is to get the right tools. For this, I’ll use VLC Media Player to record the series of images and then use mencoder to convert the images into a movie clip.

Step 1 - Install the software

sudo apt-get install vlc mencoder

Step 2 - Capture the images

vlc -I dummy v4l2:// -V image --image-out-width 450 --image-out-height 338 --image-out-ratio 1440 --run-time 86400 --image-out-prefix img vlc://quit 2> /dev/null

In James’ guide, he uses a cronjob to run a command line utility that takes a photo every minute.
Instead of that, I choose to run VLC for 86400 seconds (1 day) saving an image for every 1440 frames (about 1 image every couple of minutes depending on your camera frame rate).
The “-I dummy” is used to disable the graphical interface and v4l2:// is my webcam address which you can find out by running VLC on it’s own and opening the capture device.
To get the values right, you can try running it for shorter periods (like a few minutes) and seeing how many images it creates.

Step 3 - Create the Video

mencoder mf://*.png -mf w=450:h=338:fps=12:type=png -ovc lavc -lavcopts vcodec=mp4:mbd=2:trell -oac copy -o output.avi

To create the video, just browser into the directory with all the snapshots and run mencoder to generate the video.

Step 4 - Share it with the World!

Ok, I’m a sucker for Macs so I had to edit the video with iMovie to add some cheesy sound and text ;-)