docs: Add 24 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 48s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 48s
This commit is contained in:
70
squashthumbnailmaker/process_videos.sh
Executable file
70
squashthumbnailmaker/process_videos.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Helper script for easier local usage of the thumbnail maker
|
||||
|
||||
# Check if Docker image exists
|
||||
if ! docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^squashthumbnailmaker_image:latest$"; then
|
||||
echo "Docker image not found. Please run install.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check arguments
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <video_file_or_directory>"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 /path/to/video.mp4 # Process single video"
|
||||
echo " $0 /path/to/videos/ # Process all videos in directory"
|
||||
echo ""
|
||||
echo "Options (set as environment variables):"
|
||||
echo " ENABLE_SMART_DETECTION=false # Disable YOLO detection"
|
||||
echo " THUMBNAIL_WIDTH=1280 # Change thumbnail width"
|
||||
echo " THUMBNAIL_QUALITY=90 # Change JPEG quality"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INPUT_PATH="$1"
|
||||
|
||||
# Get absolute path
|
||||
INPUT_PATH=$(realpath "$INPUT_PATH")
|
||||
|
||||
if [ ! -e "$INPUT_PATH" ]; then
|
||||
echo "Error: $INPUT_PATH does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine if input is file or directory and get the mount path
|
||||
if [ -f "$INPUT_PATH" ]; then
|
||||
# For a file, mount its directory and reference the file
|
||||
MOUNT_DIR=$(dirname "$INPUT_PATH")
|
||||
FILENAME=$(basename "$INPUT_PATH")
|
||||
CONTAINER_PATH="/data/$FILENAME"
|
||||
elif [ -d "$INPUT_PATH" ]; then
|
||||
# For a directory, mount it directly
|
||||
MOUNT_DIR="$INPUT_PATH"
|
||||
CONTAINER_PATH="/data"
|
||||
else
|
||||
echo "Error: $INPUT_PATH is neither a file nor a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build Docker run command
|
||||
DOCKER_CMD="docker run --rm"
|
||||
|
||||
# Add environment variables if set
|
||||
[ -n "$ENABLE_SMART_DETECTION" ] && DOCKER_CMD="$DOCKER_CMD -e ENABLE_SMART_DETECTION=$ENABLE_SMART_DETECTION"
|
||||
[ -n "$FALLBACK_TIME" ] && DOCKER_CMD="$DOCKER_CMD -e FALLBACK_TIME=$FALLBACK_TIME"
|
||||
[ -n "$THUMBNAIL_WIDTH" ] && DOCKER_CMD="$DOCKER_CMD -e THUMBNAIL_WIDTH=$THUMBNAIL_WIDTH"
|
||||
[ -n "$THUMBNAIL_QUALITY" ] && DOCKER_CMD="$DOCKER_CMD -e THUMBNAIL_QUALITY=$THUMBNAIL_QUALITY"
|
||||
[ -n "$MAX_SAMPLE_TIME" ] && DOCKER_CMD="$DOCKER_CMD -e MAX_SAMPLE_TIME=$MAX_SAMPLE_TIME"
|
||||
[ -n "$SAMPLE_INTERVAL" ] && DOCKER_CMD="$DOCKER_CMD -e SAMPLE_INTERVAL=$SAMPLE_INTERVAL"
|
||||
[ -n "$NICE_LEVEL" ] && DOCKER_CMD="$DOCKER_CMD -e NICE_LEVEL=$NICE_LEVEL"
|
||||
|
||||
# Add volume mount and run
|
||||
DOCKER_CMD="$DOCKER_CMD -v \"$MOUNT_DIR:/data\" squashthumbnailmaker_image:latest \"$CONTAINER_PATH\""
|
||||
|
||||
echo "Processing: $INPUT_PATH"
|
||||
echo "Running: $DOCKER_CMD"
|
||||
echo ""
|
||||
|
||||
# Execute the command
|
||||
eval $DOCKER_CMD
|
Reference in New Issue
Block a user