Fixed deleting, added path

This commit is contained in:
Tobias Maier
2022-07-26 20:25:31 +02:00
parent 3151fc1503
commit 1de7cced42

View File

@@ -1,24 +1,27 @@
#!/bin/bash
set -euo pipefail #x for debug
while getopts i:d:D: flag
while getopts i:d:D:o: flag
do
case "${flag}" in
i) input_folder=${OPTARG};;
d) days=${OPTARG};;
D) delete=${OPTARG};;
o) output_path=${OPTARG};;
esac
done
if ! [[ -v input_folder ]] || ! [[ -v days ]] || ! [[ -v delete ]]
if ! [[ -v input_folder ]] || ! [[ -v days ]] || ! [[ -v delete ]] || ! [[ -v output_path ]]
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" ]]
if [ $delete == "true" ]
then
echo "WARNING old files will be deleted"
else
echo NO DELETO
fi
@@ -43,17 +46,20 @@ do
month=$(date -d "now - $days days" +%m)
year=$(date -d "now - $days days" +%Y)
echo "Working on" $day $month $year
if [[ delete!="true" ]]
if ! [ $delete == "true" ]
then
echo Not deleting
cp $input_folder/Frame_${year}-${month}-${day}*.jpg ./timelapse_temp
else
echo "NOT YET IMPLEMENTED"
echo DELETING FILES
mv $input_folder/Frame_${year}-${month}-${day}*.jpg ./timelapse_temp
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}
mkdir -p ${output_path}
ffmpeg -r 25 -pattern_type glob -i "./timelapse_temp/*.jpg" -s 1920x1080 -vcodec libx264 -preset veryfast -crf 25 ${output_path}/${out_name}
rm -rf ./timelapse_temp