#!/bin/bash MOUNT_PATH="/mnt/extern" DATA="${MOUNT_PATH}/timelapse" CLIENT_FOLDER="/timelapse" DATA_FOLDER="" case ${1} in daily) DATA_FOLDER="daily" DATE=`ls "${DATA}/${DATA_FOLDER}/" | head -1 | cut -d"-" -f1` FILE_NAME="${DATA_FOLDER}_${DATE}" ;; weekly) DATA_FOLDER="weekly" DATE=`ls "${DATA}/${DATA_FOLDER}/" | head -1 | cut -d"-" -f1` DATE=`date --date="${DATE}" +%Y_%V` FILE_NAME="${DATA_FOLDER}_${DATE}" ;; monthly) DATA_FOLDER="monthly" DATE=`ls "${DATA}/${DATA_FOLDER}/" | head -1 | cut -d"-" -f1` DATE=`date --date="${DATE}" +%Y_%m` FILE_NAME="${DATA_FOLDER}_${DATE}" ;; *) DATA_FOLDER="yearly" DATE=`ls "${DATA}/${DATA_FOLDER}/" | head -1 | cut -d"-" -f1` DATE=`date --date="${DATE}" +%Y` FILE_NAME="${DATA_FOLDER}_${DATE}" ;; 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 # create video 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"