Skip to content

Instantly share code, notes, and snippets.

@jrohland
Created March 18, 2018 15:59
Show Gist options
  • Save jrohland/ab299c56bb9de3820056ef42e0b85165 to your computer and use it in GitHub Desktop.
Save jrohland/ab299c56bb9de3820056ef42e0b85165 to your computer and use it in GitHub Desktop.
Create timelapse from synology security station recordings
#!/bin/bash
camera="WansView - NCM624GB"
outputdir="/volume2/Shared/Bubby Night Timelapse"
today=$(date "+%Y%m%d")
yesterday=$(date --date yesterday "+%Y%m%d")
tempdir=~/timelapse/$today
inputfiles=$tempdir/files.txt
outputfile=$outputdir/$today.mp4
mkdir $tempdir
cat /dev/null > $inputfiles
for hour in $(seq -f "%02g" 20 23)
do
find "/volume1/surveillance/$camera/${yesterday}PM" -type f -name "$camera$yesterday-$hour*" >> $inputfiles
done
for hour in $(seq -f "%02g" 0 7)
do
find "/volume1/surveillance/$camera/${today}AM" -type f -name "$camera$today-$hour*" >> $inputfiles
done
counter=0;
while IFS='' read -r line || [[ -n "$line" ]];
do
echo "Converting $line"
outputindex=$(printf "%04d" $counter)
ffmpeg -i "$line" -nostdin -filter:v "setpts=0.005*PTS" -an "${tempdir}/${outputindex}.mp4"
counter=$((counter + 1))
done < "$inputfiles"
ls $tempdir/*.mp4|sort -n| sed -e "s/^\(.*\)$/file '\1'/" > $tempdir/final.txt
echo "Combining videos"
ffmpeg -f concat -safe 0 -i $tempdir/final.txt -nostdin -c copy "$outputfile"
echo "Removing temp dir"
rm -rf $tempdir
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment