commit ef1c11f1d7820e929148e80b83693e6ebcfe36ef parent 116eaaae012aa23b30195d75c8400c7cf1b842c6 Author: breadcat <breadcat@users.noreply.github.com> Date: Sat, 27 Sep 2025 00:36:25 +0100 Add backfill shell script for missing video thumbnails Diffstat:
A | backfill.sh | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/backfill.sh b/backfill.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -euo pipefail + +upload_dir="uploads" +thumb_dir="$upload_dir/thumbnails" + +mkdir -p "$thumb_dir" + +# Loop through all video files in uploads (not including thumbnails) +find "$upload_dir" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.webm" -o -iname "*.mov" -o -iname "*.avi" -o -iname "*.mkv" \) | while read -r file; do + filename=$(basename "$file") + thumb="$thumb_dir/${filename}.jpg" + + if [[ -f "$thumb" ]]; then + echo "Skipping $filename as thumbnail already exists" + continue + fi + + echo "Generating thumbnail for $filename as $thumb" + if ! ffmpeg -y -ss 00:00:05 -i "$file" -vframes 1 -vf scale=400:-1 "$thumb" 2>/dev/null; then + echo "Failed at 5s, retrying from start..." + ffmpeg -y -i "$file" -vframes 1 -vf scale=400:-1 "$thumb" + fi +done