sitewww/casamento/thumbnails.sh

33 lines
999 B
Bash
Raw Normal View History

2026-01-18 16:03:22 -03:00
#!/bin/bash
# Generate video thumbnails for all videos in conteudo directories
# Requires: ffmpeg
CONTENT_DIR="./conteudo"
echo "Generating video thumbnails..."
# Find all video files
find "$CONTENT_DIR" -type f \( -iname "*.mp4" -o -iname "*.mov" -o -iname "*.avi" -o -iname "*.webm" -o -iname "*.mkv" \) | while read video; do
# Get the thumbnail path (same name but .jpg)
thumbnail="${video%.*}.jpg"
# Skip if thumbnail already exists
if [ -f "$thumbnail" ]; then
echo " ⏭ Skipping (exists): $(basename "$thumbnail")"
continue
fi
echo " ⚡ Generating: $(basename "$thumbnail")"
# Extract frame at 1 second (or first frame if video is shorter)
ffmpeg -i "$video" -ss 00:00:01 -vframes 1 -q:v 2 "$thumbnail" -y 2>/dev/null
# If that failed (video too short), try first frame
if [ $? -ne 0 ]; then
ffmpeg -i "$video" -vframes 1 -q:v 2 "$thumbnail" -y 2>/dev/null
fi
done
echo "✓ Done! Video thumbnails generated."