Building a Video Thumbnail Generator With FFmpeg and Node.js
Thumbnails drive click-through rates on YouTube, and programmatic thumbnail generation is a solved problem with FFmpeg — but the implementation details matter enormously. Extracting the wrong frame...

Source: DEV Community
Thumbnails drive click-through rates on YouTube, and programmatic thumbnail generation is a solved problem with FFmpeg — but the implementation details matter enormously. Extracting the wrong frame (a blink, a dark transition, a blurry motion shot) is worse than a static placeholder. This post covers smart frame selection, multi-frame extraction, quality scoring, and the full Node.js implementation. This thumbnail pipeline is part of the processing stack at ClipSpeedAI, where thumbnails are generated for every processed clip. Basic Frame Extraction The simplest approach: extract a frame at a specific timestamp. // lib/thumbnails/basic.js import { execa } from 'execa'; export async function extractFrameAtTime(videoPath, outputPath, timestamp) { await execa('ffmpeg', [ '-ss', String(timestamp), '-i', videoPath, '-frames:v', '1', '-q:v', '2', // JPEG quality (2 = high, 31 = low) '-y', outputPath ]); return outputPath; } The -ss flag before -i (input seeking) is critical. Placing -ss befor