Create Video Grids with FFmpeg Tile Filter
This guide explains how to use the FFmpeg tile video
filter to automatically arrange a sequence of video frames into a custom
grid collage image. You will learn the core syntax of the filter, how to
define the grid dimensions, how to control frame selection so your
collage covers the entire video duration, and how to customize the
layout with padding, margins, and background colors.
Understanding the Tile Filter Syntax
The tile filter takes consecutive frames from an input
video and arranges them into a single, grid-formatted image. The most
basic syntax for the filter is:
tile=columnsxrowsFor example, tile=3x2 will create a grid with 3 columns
and 2 rows, containing a total of 6 frames.
Basic Command to Generate a Grid
If you run the tile filter on a standard video without limiting the input frames, FFmpeg will simply grab the first few frames of the video (which are often identical or black) and put them into the grid. To create a meaningful collage, you must scale the frames down and choose which frames to capture.
Here is a standard command to create a 3x3 grid collage from a video:
ffmpeg -i input.mp4 -vf "select='not(mod(n,100))',scale=320:-1,tile=3x3" -vsync vfr output.pngHow this command works:
-i input.mp4: Specifies your input video file.select='not(mod(n,100))': This selects every 100th frame of the video. Adjust this number based on your video’s length and frame rate to space out your collage images.scale=320:-1: Scales each individual tile to a width of 320 pixels while automatically maintaining the aspect ratio. This prevents the output image from becoming massive.tile=3x3: Places the selected, scaled frames into a 3-column, 3-row grid.-vsync vfr: Ensures variable frame rate handling so the output image writes correctly.
Customizing the Grid Layout
The tile filter offers several optional parameters to
customize the visual appearance of your collage, such as adding borders
and changing the background color.
The extended syntax is:
tile=layout:margin:padding:colorlayout: The grid size (e.g.,4x3).margin: The outer border thickness around the entire collage in pixels (default is 0).padding: The spacing between individual tiles in pixels (default is 0).color: The color of the margins and padding area (default is black). You can use standard color names or hex codes (e.g.,whiteor0xFFFFFF).
Example with Custom Styling:
To create a 4x4 grid with a 10-pixel outer margin, 5-pixel gaps between the images, and a white background, use the following command:
ffmpeg -i input.mp4 -vf "select='not(mod(n,50))',scale=240:-1,tile=4x4:margin=10:padding=5:color=white" -vsync vfr collage.pngCreating Collages by Time Intervals
If you prefer to capture frames at specific time intervals (for
example, one frame every 10 seconds) rather than by frame count, you can
use the fps filter before the tile filter:
ffmpeg -i input.mp4 -vf "fps=1/10,scale=300:-1,tile=5x2" -vsync vfr timeline_collage.pngIn this command, fps=1/10 extracts one frame every 10
seconds, which are then scaled and arranged into a 5x2 grid.