The Raspberry Pi’s lightweight, compact properties mean it can be used as a hidden camera when combined with the popular camera module and portable battery. With that in mind, I recently shot five amazing time-lapse videos. You can too.
What will you need
Next, you’ll need a battery to make the Pi portable. You can do it yourself. or buy a compact battery. I used one from RAVPower (UK) which gives you 36-48 hours on a full charge.
Time lapse and Raspberry Pi in place
raspistill -t 30000 -tl 2000 -o image%04d.jpg
The options specify a timeout (-t) after 30 seconds (30000 milliseconds) and an interval (-tl) of 2 seconds between each frame (2000 ms). Each image will be saved in the current folder with filenames in the image000x.jpg format as specified in the image%04d.jpg condition. This calculator can help you get the right numbers.
By default, the camera takes pictures at a resolution of 2592 x 1944, and the resulting image is about 2.5 MB each. For a few hours of time-lapse, this can be a bit of a strain on your Pi. Therefore, it is recommended to specify a slightly lower resolution. So the command can read
raspistill -t 30000 -tl 2000 -o image%04d.jpg -w 1280 -h 960
All I’ve done — and all you’ll need to do — is adjust the script’s timeout and timeslot conditions to match the specific script.
Remote connection to Raspberry Pi
If you are using your Raspberry Pi outside and outside of your home network, you will need to set up a dedicated network to connect to your Pi from your smartphone via SSH. This is the best way to start capturing time-lapse images remotely; You can use an ad hoc network with a laptop if you like, but a smartphone or tablet is more portable.
You will now be able to directly connect to your Raspberry Pi via SSH, making slow motion shooting a lot easier. Alternatively, you can use a script and a Python button, as explained in our stop motion studio tutorial
If any of this seems like too much work, you can always rely on a standard SSH connection over a wireless network to start capturing the time lapse and then bring the Pi to its intended location. As long as your battery has sufficient life and you have specified a suitable duration in the burst script, everything should go well. Before compiling images as videos (see below), just discard the ones you don’t need!
At this point, you can exit and start setting up and capturing your footage. Read on if you’re short on ideas, but first we’ll walk you through the process of fixing images and turning it all into a video.
Viewing time spans
If you create images every five or ten seconds for an hour or more, you will probably have a lot of these images. Please note that by default they are in high resolution. This means they eat up space on your Raspberry Pi very quickly. Thus, it is a good idea to limit yourself to one film project at any one time. Once you’ve finished capturing, create a movie (see below) and delete the original shots.
For now, you only have pictures. You will need to edit them together into a video file.
Start by looking at the images and make sure they are oriented correctly. If not, you can use the ImageMagick software to rotate them as needed.
sudo apt-get install imagemagick for file in *.png; do convert $file -rotate 90 rotated-$file; done
This will rotate every image in the current directory 90 degrees clockwise. In some cases, I had to rotate .JPG files counterclockwise by 90 degrees:
for file in *.jpg; do convert $file -rotate -90 rotated-$file; done
Create a slow motion video
Once that was done, I removed the original files and used the avconv software to create a video file compiling each shot into a video. You will find avconv as part of the libav-tools package.