How to Use the FFmpeg Tile Filter
The FFmpeg tile filter is a powerful tool used to
combine multiple consecutive video frames into a single grid-like image
or video. This article provides a clear, step-by-step guide on how to
use the tile filter, explaining its core parameters, basic
syntax, and practical command-line examples to help you create custom
video contact sheets and thumbnail grids.
Basic Syntax of the Tile Filter
The most basic implementation of the tile filter
requires you to define the grid layout using columns and rows. The
syntax is:
tile=columnsxrowsFor example, tile=3x2 will arrange six consecutive video
frames into a grid of 3 columns and 2 rows.
Key Parameters
To customize your grid, you can append several optional parameters to the filter:
layout: The grid size defined ascolsxrows(e.g.,4x3).nb_frames: The number of frames to render in the grid. By default, this is equal to the number of cells in the layout (columns × rows).margin: The outer border thickness of the final image in pixels (default is 0).padding: The space between individual tiles in pixels (default is 0).color: The color of the background/padding area (default is black). You can use standard color names or Hex codes.
Practical Examples
Here are common ways to use the tile filter in your
terminal.
Example 1: Creating a Video Contact Sheet (Thumbnail Grid)
To create a single image containing a 3x3 grid of frames taken at
regular intervals, you can combine the select filter, the
scale filter, and the tile filter:
ffmpeg -i input.mp4 -vf "select='not(mod(n,100))',scale=320:-1,tile=3x3" -frames:v 1 output.pngselect='not(mod(n,100))': Selects every 100th frame of the video.scale=320:-1: Resizes each selected frame to a width of 320 pixels while maintaining the aspect ratio.tile=3x3: Arranges the 9 selected frames into a 3x3 grid.-frames:v 1: Tells FFmpeg to output only one single image.
Example 2: Adding Padding and Custom Background Color
To make the grid easier to read, you can add spacing between the images and change the background color to white:
ffmpeg -i input.mp4 -vf "scale=200:-1,tile=4x4:padding=10:color=white" -frames:v 1 output.pngIn this command, tile=4x4:padding=10:color=white creates
a 16-frame grid with 10 pixels of white space separating each
thumbnail.
Example 3: Creating a Continuous Tiled Video
If you do not limit the output to one frame using
-frames:v 1, FFmpeg will continuously generate grids for
the entire duration of the video, creating a new grid video:
ffmpeg -i input.mp4 -vf "scale=160:120,tile=2x2" output.mp4This command outputs a new video file where every frame is a 2x2 grid containing 4 frames from the original video playing in sequence.