diff --git a/bin/timelapse_monthly.sh b/bin/timelapse_monthly.sh index 363e30b..1a59733 100755 --- a/bin/timelapse_monthly.sh +++ b/bin/timelapse_monthly.sh @@ -6,11 +6,13 @@ DATA="${MOUNT_PATH}/timelapse" CLIENT="timelapse@192.168.111.2" CLIENT_FOLDER="/timelapse" -set -x - -if [[ "${1}" =~ [01]*[0-9] ]] +if [[ "${1}" =~ [0-9]+ ]] then MONTH=${1} + if [ ${MONTH} -lt 10 ] + then + MONTH="0${MONTH}" + fi else MONTH=`date --date="1 month ago" +%m` fi diff --git a/bin/timelapse_video.sh b/bin/timelapse_video.sh index 5cd34c7..14250f4 100755 --- a/bin/timelapse_video.sh +++ b/bin/timelapse_video.sh @@ -8,19 +8,23 @@ DATA_FOLDER="" case ${1} in daily) - DATA_FOLDER="${1}" + DATA_FOLDER="daily" + FILE_NAME="${DATA_FOLDER}_`date +%Y%m%d`" DATE=`date --date="1 day ago" +%Y%m%d` ;; weekly) - DATA_FOLDER="${1}" + DATA_FOLDER="weekly" + FILE_NAME="${DATA_FOLDER}_`date +%Y_%V`" DATE=`date --date="1 week ago" +%Y%m%d` ;; monthly) - DATA_FOLDER="${1}" + DATA_FOLDER="monthly" + FILE_NAME="${DATA_FOLDER}_`date +%Y_%m`" DATE=`date --date="1 month ago" +%Y%m%d` ;; *) DATA_FOLDER="yearly" + FILE_NAME="${DATA_FOLDER}_`date +%Y`" DATE=`date +%Y%m%d` ;; esac @@ -44,4 +48,4 @@ then fi # sort files -ffmpeg -y -loglevel quiet -framerate 30 -pattern_type glob -i "${DATA}/${DATA_FOLDER}/*.jpg" -vcodec libx265 -crf 20 -vf scale=1920:1080 "${DATA}/video/${DATA_FOLDER}_${DATE}.mp4" +ffmpeg -y -loglevel quiet -framerate 30 -pattern_type glob -i "${DATA}/${DATA_FOLDER}/*.jpg" -vcodec libx265 -crf 20 -vf scale=1920:1080 "${DATA}/video/${FILE_NAME}.mp4"