custom-scripts/timelapse/tl-process

38 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2024-06-26 00:06:35 +00:00
#!/bin/bash
# Configuration Variables
SRC_DIR="/Volumes/media/tl/to-process/"
PROG_DIR="/Volumes/media/tl/in-progress/"
DONE_DIR="/Volumes/media/tl/processed/"
OUTPUT_DIR="/Volumes/media/tl/videos/"
# FFmpeg
FRAMERATE="30"
RESOLUTION="1920x1080"
# Other Variables
DATE=$(date +"%Y-%m-%d_%H-%M")
OUTPUT_FILE="${OUTPUT_DIR}${DATE}.mp4"
# Functions
process() {
echo "Moving images from ${SRC_DIR} to ${PROG_DIR}"
mv ${SRC_DIR}*.jpg ${PROG_DIR}
echo "Creating timelapse video from images in ${PROG_DIR}"
ffmpeg -framerate $FRAMERATE -pattern_type glob -i "${PROG_DIR}*.jpg" -s:v $RESOLUTION -c:v libx264 -pix_fmt yuv420p $OUTPUT_FILE
echo "Moving processed images to ${DONE_DIR}"
mv ${PROG_DIR}*.jpg ${DONE_DIR}
echo "Timelapse video created at ${OUTPUT_FILE}"
}
# Ensure directories exist
echo "Ensuring directories exist..."
mkdir -p $SRC_DIR $PROG_DIR $DONE_DIR $OUTPUT_DIR
# Run the process function
echo "Starting the timelapse creation process..."
process
echo "Process completed."