Thumbnails and preview animations are essential for video platforms. FFmpeg can generate them automatically.
Single Thumbnail at Specific Time
# Capture frame at 10 seconds ffmpeg -i video.mp4 -ss 00:00:10 -frames:v 1 thumbnail.jpg # Higher quality ffmpeg -i video.mp4 -ss 00:00:10 -frames:v 1 -q:v 2 thumbnail.jpg
Multiple Thumbnails at Intervals
# One thumbnail every 60 seconds ffmpeg -i video.mp4 -vf "fps=1/60" thumb_%03d.jpg # One thumbnail every 30 seconds ffmpeg -i video.mp4 -vf "fps=1/30" thumb_%03d.jpg
Thumbnail Grid (Sprite Sheet)
Create a grid of thumbnails in a single image (useful for video scrubbing):
# 5x5 grid of thumbnails ffmpeg -i video.mp4 -vf "fps=1/10,scale=160:90,tile=5x5" sprite.jpg
Animated GIF Preview
# 5-second GIF starting at 30 seconds ffmpeg -i video.mp4 -ss 00:00:30 -t 5 -vf "fps=10,scale=320:-1:flags=lanczos" -loop 0 preview.gif
Animated WebP Preview (Smaller than GIF)
ffmpeg -i video.mp4 -ss 00:00:30 -t 5 -vf "fps=10,scale=320:-1" -loop 0 -preset default -an preview.webp
Video Preview (Short MP4 Clip)
# 10-second preview starting at 30 seconds ffmpeg -i video.mp4 -ss 00:00:30 -t 10 -c:v libx264 -crf 28 -preset fast -an -movflags +faststart preview.mp4
Thumbnail at Percentage of Duration
# Get duration first duration=$(ffprobe -v error -show_entries format=duration -of csv=p=0 video.mp4) # Capture at 25% of video position=$(echo "$duration * 0.25" | bc) ffmpeg -i video.mp4 -ss $position -frames:v 1 thumb_25pct.jpg
Batch Generate Thumbnails
for f in *.mp4; do
ffmpeg -i "$f" -ss 00:00:05 -frames:v 1 "${f%.mp4}_thumb.jpg"
done
Tip: For video platforms, generate thumbnails at upload time using a cron job or queue worker.