Working with the Raspberry Pi camera module
Time-Lapse Photography
A really fantastic way to make use of the Raspberry Pi camera is for time-lapse photography – taking pictures at regular intervals and then stitching them together into a video. You have probably seen this technique many times in wildlife videos.
It is really easy to use the Pi camera for time-lapse photography with the parameter -tl
. For example, to take a picture every 10 seconds for an hour, type:
$ raspistill -o test_%03d.jpeg -tl 10000 -t 3600000
I recommend executing the preceding command from within a directory called /home/pi/timelapse
or similar, as it will make the next part much easier if only the time-lapse photos exist in the directory.
The preceding command will generate 360 images. The %03d
allocates 3 decimal places for the number in the filename. In this case the filenames will start with test_001.jpeg
and end with test_360.jpeg
. If you are doing a time-lapse over a longer period, you would probably need to increase this to %04d
or %05d
to accommodate a 4- or 5-digit number in the filename.
Stitching Them Together
To stitch the time-lapse images into a video, you need mencoder:
$ sudo apt-get install mencoder
You will make a list of all the files to pass through to mencoder later. You need to be within the /home/pi/timelapse
directory (or wherever you saved all the pictures) and then type:
$ ls *.jpeg > timelapse.txt
Then, create an 1080p HD video of the images using the following command:
$mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mftype=jpeg:fps=24 mf://@timelapse.txt
You can change the name of the output file by changing timelapse.avi
to another name.
Once you get to know the time-lapse photography option, think of all the creative videos you can make! And what about creating a battery-powered time lapse camera rig using a model A Raspberry Pi, a camera module, and a large battery? Add a solar panel and place it in a remote location, and you could be snapping for days on end.
Buy this article as PDF
Pages: 2
(incl. VAT)