You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
timelapse/bin/timelapse_video.sh

55 lines
1.3 KiB

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