Create Video Contact Sheets with FFmpeg Tile Filter
Generating a video contact sheet or thumbnail grid is a highly
efficient way to preview video content at a glance. This guide explains
how to configure and use the tile video filter in FFmpeg to
create custom contact sheets, detailing the essential parameters for
frame selection, scaling, and grid layout.
The Basic Command Structure
To create a contact sheet, FFmpeg needs to extract frames from a video, optionally resize them, and then arrange them into a grid.
Here is the standard command template:
ffmpeg -i input.mp4 -vf "fps=1/10,scale=320:-1,tile=4x3" output.pngHow the Filters Work
The key to creating a clean contact sheet lies in the video filter
(-vf) chain. The filters are applied in order from left to
right, separated by commas.
1. Frame Selection
(fps or select)
By default, FFmpeg processes every single frame. If you pass every
frame to the tile filter, your contact sheet will only
represent a fraction of a second of video. You must limit the input
frames: * Time-based (fps): Use
fps=1/10 to capture one frame every 10 seconds, or
fps=1/60 for one frame every minute. * Frame-based
(select): Use
select='not(mod(n\,100))' to select every 100th frame.
2. Thumbnail Scaling
(scale)
If your source video is 1080p or 4K, placing those frames directly
into a grid will result in an enormous image file. *
scale=320:-1 resizes each thumbnail to a width of 320
pixels and automatically calculates the height to maintain the original
aspect ratio.
3. Grid Layout (tile)
The tile filter defines the layout of the final contact
sheet using the format columnsxrows. *
tile=4x3 creates a grid of 4 columns and 3 rows (12
thumbnails total). * Once the grid is full, FFmpeg will output the
image. If the video is long enough to fill the grid multiple times,
FFmpeg will generate multiple output files (e.g.,
output_%03d.png).
Advanced Configuration Options
The tile filter accepts additional parameters to
customize the look of the contact sheet. Parameters are separated by
colons.
ffmpeg -i input.mp4 -vf "fps=1/10,scale=320:-1,tile=4x3:nb_frames=12:padding=10:color=white" output.pngnb_frames: Limits the maximum number of frames rendered in the grid. Settingnb_frames=12in a4x3grid ensures the process stops immediately once the grid is filled.padding: Adds a border (in pixels) around each thumbnail.margin: Adds an outer border (in pixels) around the entire contact sheet.color: Defines the color of the padding and margin area (e.g.,white,black,red, or hex codes like0xEEEEEE).
Real-World Example
If you want to generate a single 5x5 grid (25 thumbnails total) from a 5-minute video, you need a frame roughly every 12 seconds (\(300 \text{ seconds} / 25 = 12\)).
ffmpeg -i input.mp4 -vf "fps=1/12,scale=240:-1,tile=5x5:padding=5:color=black" contact_sheet.jpgThis command extracts a frame every 12 seconds, scales them to 240px wide, arranges them in a 5x5 grid with a 5-pixel black border, and saves the output as a JPG file.