This is the shell script I use for creating time-lapse videos using a Raspberry Pi. It is designed to run as cron job, so it is somewhat fail-safe to power outages. The script assumes that the Pi has a couple of USB drives attached to it, for storing the images, but other than that, it should be fairly self-explanatory.
Note: the script is just responsible for taking the photos. There are some instructions for building the actual video with MEncoder at the top of the script.