Generate a thumbnail contact sheet
A contact sheet is a single image with a grid of thumbnails from a video. It is the right tool for a quick visual index of a long file, or for a preview that shows the pacing of the content. The `thumbnail` filter in libavfilter picks the most representative frames and the `tile` filter lays them out in a grid.
The command
ffmpeg -i in.mp4 -vf "thumbnail,scale=320:180,tile=4x4" -frames:v 1 -an contact_sheet.pngWhat it does
The `thumbnail` filter picks the most representative frames from the input — frames with the most varied content, not just the first N. The `scale` filter resizes each frame to a thumbnail size. The `tile` filter arranges the thumbnails in a 4x4 grid. The output is a single image with 16 thumbnails. The number of frames is determined by `tile=4x4`; for more, use `tile=5x5` (25 frames) or `tile=6x4` (24 frames).
Requirements
Any video input. The filters are in libavfilter. CPU-only — the `thumbnail` filter decodes the entire file to pick the best frames, so the cost is proportional to the input duration. For a 1-hour input, the analysis can take several minutes.
Things to avoid
- Using a very high tile count. A 10x10 grid means 100 thumbnails, which the `thumbnail` filter will pick from the entire file. The output PNG will be huge and the analysis will be slow.
- Confusing `thumbnail` with `select`. `select` picks frames at a fixed interval (e.g., every 10 seconds); `thumbnail` picks the most representative frames, which is a better visual index.
- Forgetting the `-frames:v 1` flag. Without it, the output is a video of the thumbnails; for a single image, the flag is required.
- Re-encoding the audio. The output is an image, so the audio is irrelevant. Use `-an` to drop it explicitly.