This guide explains how to make a stop motion video using a raspberrypi with the camera module. As part of this exercise I also wanted to transfer the file over to another remote PC in an automated fashion.
The reason I wanted to do this was the using video made the filesize umanageable. With stop motion you can alter the interval, duration of process etc.
High level steps:
1. pi1 takes a picture every 10 seconds
2. pi1 copies the picture to pi2
3. pi1 deletes the local copy and takes another picture and repeats the process.
4. On pi2 there is a scheduled cronjob that creates a video from the still images and then deletes the images files.
On pi1:
Create a folder to store our images:
mkdir /home/pi/camera
Create a script to capture the images:
sudo nano /home/pi/camera.sh
Add the following to the camera.sh shell script. The script itself runs through a for loop, you can see in this example it runs through 3600 iterations. Within the loop the script takes a picture and outputs it to a file with a filename called picture-i (where i is the number where we are in the loop). The script then pauses for 10 seconds. This means that this script would take roughly 10 hours to work through the loop until it stops - you can obviously modify the values to suit your needs. The script then writes the file to pi2 using scp - you need to have already setup ssh login without password for this to work. The script then deletes the local file and returns to the start of the loop. The deletion of the local file is purely to save space - it is not compulsory:
#!/bin/bash
#DATE=$(date +"%Y-%m-%d_%H%M%S")
for ((i=1; i<=3600; i++))
do
DATE=$(date +"%Y-%m-%d_%H-%M-%S")
echo "*** Taking Picture $i ***"
raspistill -o /home/pi/camera/picture-$i.jpg
sleep 10
echo "*** Writing file $i to remote server ***"
scp /home/pi/camera/*.jpg pi@pi2:/home/pi/camera
rm /home/pi/camera/*.jpg
done
Press CTRL + X, followed by Y to close the file and save it:
mkdir /home/pi/camera
sudo nano /home/pi/make-video.sh
Press CTRL + X, followed by Y to close the file and save it: