#!/bin/bash videos_dir="${1:-static/media}" output_dir="${2:-static/media/thumbnails}" for file in "$videos_dir/"*.mp4; do out="$output_dir/${file%.*}.png" ffmpeg -i "$file" -vf "thumbnail,scale=640:360" -frames:v 1 "$out" done