This script will take image every 5 seconds 1440 times leaving you with just enough to create 60 sec timelaps video using 24 fsp
#!/bin/bash
# Timelapse controller for USB webcam
DIR=/home/user/timelapse
x=1
while [ $x -le 1440 ]; do
filename=$(date -u +"%Y%m%d-%H%M-%S").jpg
raspistill -o $DIR/$filename -w 1280 -h 960 -n -t 1000
x=$(( $x + 1 ))
sleep 5;
done
Now you have 1440 images or the number you entered and next step is to create the video. Copy the images to your computer using
scp
or rsync
, you can add that to your script if the Raspberry pi is connected to network. When you have all your images on your computer you can render video with mencoder. Install mencoder if needed.
sudo apt-get install mencoder
#!/bin/bash
DIR=/home/user/timelapse/
ls $DIR/*.jpg > list.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=640:480 -o $DIR/$(date -u +"%Y%d%m-%H%M-%S").avi -mf type=jpeg:fps=24 mf://@list.txt
rm list.txt
All ideas about improving this code are welcome.
-cheers