To make my timelapse video capture a little easier, I wrote a small script that handles creation of a new folder for every timelapse instance, deals with the runtime & frame interval flags & generally makes everything a little cleaner.
As with most of my code, it’s rough, but functional
#!/bin/bash INPUTFILE="$1" INPUTFILE+="_%d" FRAME_INTERVAL="$2" FRAME_INTERVAL_MIN="1250" RUNTIME="2073600000" DATE=$(date +"%T_%m-%d-%y") if [ -z $1 ] then echo "Raspberry Pi Timelapse Script v1.2" echo "2015 Ben Thomson 2E0GXE" echo "Images will be taken in 1920x1080 format for transcoding into video." echo "This script expects some options in the following format:" echo "./timelapse.sh <File Prefix> <Frame Interval>" echo "<File Prefix> The script will prepend this name to every image as a unique capture session identifier." echo "A sequential number is appended to the end of the filename for frame identification." echo "<Frame Interval> This is the interval between frames, in milliseconds. Minimum 1250." echo "This minimum is required to retain stability & prevent dropped frames." echo "Every time the program is started, a new folder with the current date & time is created for the images." exit 0 fi if [ $FRAME_INTERVAL -lt $FRAME_INTERVAL_MIN ] then echo Frame Interval Too Low! echo This will cause dropped frames! Exiting! exit 0 fi mkdir -p ./$DATE-$1 echo Image Folder $DATE-$1 Created echo Image Capture Interval $FRAME_INTERVAL ms echo Starting Timelapse Capture... CTRL+C To Exit... raspistill -k -n -ex auto -awb auto -mm average -w 1920 -h 1080 -o ./$DATE-$1/$INPUTFILE.jpg -tl $FRAME_INTERVAL -t $RUNTIME echo Timelapse Complete! echo File Prefix: $INPUTFILE echo Frame Interval: $FRAME_INTERVAL ms echo Folder Name: $DATE-$1