custom-scripts/timelapse/tl-capture

41 lines
1019 B
Plaintext
Raw Normal View History

2024-06-24 21:40:34 +00:00
#!/bin/bash
2024-06-24 21:40:34 +00:00
# Customizable variables
# Paths
IMG_DIR="/tmp/TL"
2024-06-24 22:28:23 +00:00
NAS_MOUNT_DIR="/mnt/media"
2024-06-25 22:23:31 +00:00
SYNC_DES_PATH="/tl/to-process"
# Command variables
RESOLUTION="1920x1080"
DEVICE="/dev/video0"
FRAMES="1"
SKIPS="5"
2024-06-24 21:40:34 +00:00
# Pre-script configurations
# Generate the date for the filename
DATE=$(date +"%Y-%m-%d_%H-%M")
# Form the filename
FILENAME="TL-$DATE.jpg"
# Functions
# Capture an image and save it locally
2024-06-24 21:40:34 +00:00
capture() {
# Capture an image for the timelapse and save it to /tmp/TL-YYYY-MM-DD_HH-MM.jpg
echo "Capturing image and saving it to $IMG_DIR/$FILENAME"
fswebcam -r "$RESOLUTION" -d "#DEVICE" "$IMG_DIR/$FILENAME" -F 1 -S 5
2024-06-24 21:40:34 +00:00
}
# Sync images from local to a remote mounted storage device
2024-06-24 21:40:34 +00:00
sync() {
echo "Syncing $IMG_DIR to $SYNC_DES_PATH..."
rsync -av --progress --remove-source-files "$IMG_DIR/" "$NAS_MOUNT_DIR$SYNC_DES_PATH/" $1
if [[ $? -eq 0 ]]; then
echo "Success"
else
echo "Unable to complete sync. Exiting"
exit 1
fi
2024-06-24 21:43:33 +00:00
}
# Actually run everything
capture
sync