#!/bin/bash MOUNT_PATH="/mnt/extern" DATA="${MOUNT_PATH}/timelapse" CLIENT_FOLDER="/timelapse" DATA_FOLDER="" case ${1} in daily) DATA_FOLDER="daily" FILE_NAME="${DATA_FOLDER}_`date +%Y%m%d`" DATE=`date --date="1 day ago" +%Y%m%d` ;; weekly) DATA_FOLDER="weekly" FILE_NAME="${DATA_FOLDER}_`date +%Y_%V`" DATE=`date --date="1 week ago" +%Y%m%d` ;; monthly) 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 mountpoint -q ${MOUNT_PATH} if [ ${?} != 0 ] then sudo mount --uuid ${DATA_DEVICE_UUID} -o uid=1000,gid=1000,umask=0022 ${MOUNT_PATH} || echo "Cannot mount data device with UUID ${DATA_DEVICE_UUID}!"; exit 1 fi if [ ! -e "${DATA}" ] then echo "No directory: ${DATA}" exit 401 fi if [ ! -e "${DATA}/video" ] then echo "No directory: ${DATA}/video" exit 402 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/${FILE_NAME}.mp4"