Tuesday, November 25, 2008

Cheap time lapse with a webcam, VLC, and ffmpeg

I've always been fascinated with time lapse videos of all sorts. Recently I've had the urge to do a little time lapse myself. My ultimate goal is to do something with my DSLR, but I guess you have to crawl before you walk right?



1. Get a webcam

2. Get VLC from Videolan.org (Windows, Mac, and Linux)

      * if using Ubuntu type the following: sudo apt-get install vlc

3. Get ffmpeg from ffmpeg.mplayerhq.hu

      * if using Ubuntu type the following: sudo apt-get install ffmpeg

      * You can find Windows binaries for ffmpeg from Google

4. Capture your stills using VLC

      * cvlc v4l2:// :v4l2-dev="/dev/video0" -V "image" --image-out-prefix img --image-out-format jpg --image-out-ratio 10 --v4l-fps 30

This means you'll save every 10th image from /dev/video0. You'll want to replace that with where ever your webcam is. It'll most likely be under /dev/video, but you can use dmesg to find your cam.

5. Let your video run as long as you'd like (or until your hard drive fills up)


6. Stitch your images back together using ffmpeg

      * ffmpeg -b 1800 -i img%06d.jpg video.mpg

After that you'll have a video named video.mpg that looks similar to the one above. You'll want to play with the number of images you grab with the image-out-ratio and you may want to explore varying the play back speed by taking a look at the options ffmpeg has to offer.


Although I had to figure out the VLC command by reading and just trying stuff, I found the ffmpeg command from: Catswhocode.com

It's also worth mentioning that I found a good article about extracting time lapse from a video. This sounds good for shooting video with my camcorder and then getting different types of time lapse from the video. You can find that article at: wp.pr0gr4gr4mm3r.com

4 comments:

Irialk said...
This comment has been removed by the author.
Irialk said...

The file I'm getting out is very big and i want to leave the camera recording for a long period of time??

Irialk said...
This comment has been removed by the author.
Irialk said...
This comment has been removed by the author.