first commit

This commit is contained in:
Tobias Maier
2022-07-26 17:46:19 +02:00
commit 3151fc1503
2 changed files with 61 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
grabs/*
*.mp4

59
create_timelapse.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
set -euo pipefail #x for debug
while getopts i:d:D: flag
do
case "${flag}" in
i) input_folder=${OPTARG};;
d) days=${OPTARG};;
D) delete=${OPTARG};;
esac
done
if ! [[ -v input_folder ]] || ! [[ -v days ]] || ! [[ -v delete ]]
then
echo "Arguments missing. Use -i for input folder, -D to define if you want to delete processed images and -d for number of days"
exit
fi
if ! [[ delete=="true" ]]
then
echo "WARNING old files will be deleted"
fi
echo "Input: $input_folder";
echo "Delete: $delete";
echo "Days: $days";
echo "Getting timelapse from $(date -d "now - $days days" +%d-%m-%Y) to $(date -d "now - 1 days" +%d-%m-%Y)";
mkdir -p ./timelapse_temp
out_name="$(date -d "now - $days days" +%d-%m-%Y)__$(date -d "now - 1 days" +%d-%m-%Y)_timelapse.mp4"
startdate=$(date -d "now - $days days" +%d%m%Y)
enddate=$(date -d "now - 1 days" +%d%m%Y)
d=
n=0
until [ "$d" = "$enddate" ]
do
d=$(date -d "now - $days days" +%d%m%Y)
day=$(date -d "now - $days days" +%d)
month=$(date -d "now - $days days" +%m)
year=$(date -d "now - $days days" +%Y)
echo "Working on" $day $month $year
if [[ delete!="true" ]]
then
cp $input_folder/Frame_${year}-${month}-${day}*.jpg ./timelapse_temp
else
echo "NOT YET IMPLEMENTED"
fi
days=$(($days - 1))
done
echo Output: $out_name
ffmpeg -r 25 -pattern_type glob -i "./timelapse_temp/*.jpg" -s 1920x1080 -vcodec libx264 -crf 23 ${out_name}
rm -rf ./timelapse_temp