How to Use FFmpeg Tile Filter to Create Grid Collages
This guide explains how to use FFmpeg's native tile
filter to assemble video frames and multiple video streams into custom
grid collages. You will learn the core syntax of the filter, how to
control dimensions, margins, and padding, and how to create both static
contact sheets and dynamic multi-video video collages.
Understanding the
tile Filter
The tile filter processes sequential frames from a
single incoming video stream and arranges them into a single output
frame laid out in a grid. By default, it operates on successive frames
of one input, but it can also be combined with the
interleave filter to assemble multiple distinct video files
into a simultaneous grid.
Basic Syntax and Core Parameters
The base syntax inside the -vf or
-filter_complex flag is:
tile=NxMNrepresents the number of columns (horizontal).Mrepresents the number of rows (vertical).
Common parameters include:
layout: Grid dimensions specified ascolumns x rows(e.g.,3x2).nb_frames: Number of frames to render per output tile. Defaults to0(fills the whole gridN x M).margin: Outer border width in pixels.padding: Space between individual tiles in pixels.color: Background color used for margins, padding, or empty tiles (e.g.,black,white,0x00FF00).init_padding: Number of empty frames before rendering the first frame.
Generating an Image Contact Sheet (Single Video)
To generate an image thumbnail grid representing moments across a
single video, sample frames using the fps or
select filter before passing them to tile.
ffmpeg -ss 00:00:10 -i input.mp4 -vf "select='not(mod(n\,100))',scale=320:180,tile=3x3" -frames:v 1 collage.pngselect='not(mod(n\,100))': Picks every 100th frame.scale=320:180: Resizes each frame so the final 3x3 output is manageable (960x540).tile=3x3: Arranges 9 selected frames into a 3-column, 3-row grid.-frames:v 1: Stops processing after one complete tiled output frame is written.
Adding Borders, Margins, and Padding
To create separation between images and add an outer border, use
margin, padding, and color:
ffmpeg -i input.mp4 -vf "fps=1/5,scale=320:180,tile=4x2:padding=10:margin=20:color=white" -frames:v 1 output_styled.pngfps=1/5: Samples one frame every 5 seconds.tile=4x2: Places 8 frames in 4 columns and 2 rows.padding=10: Inserts 10 pixels of white space between tiles.margin=20: Inserts a 20-pixel white border around the entire collage.color=white: Sets the fill color for borders and gaps.
Creating a Real-Time Multi-Video Grid
Because tile operates sequentially on a single stream,
playing multiple separate video files simultaneously in a grid requires
synchronizing and interleaving their frames into one stream before
piping them into tile.
2x2 Simultaneous Video Collage
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex \
"[0:v]scale=640:360[v0]; \
[1:v]scale=640:360[v1]; \
[2:v]scale=640:360[v2]; \
[3:v]scale=640:360[v3]; \
[v0][v1][v2][v3]interleave=4,tile=2x2[outv]" \
-map "[outv]" -c:v libx264 -crf 23 output_grid.mp4scale=640:360: Normalizes all four inputs to identical resolutions (required for consistent grid alignment).interleave=4: Takes one frame cyclically from each of the 4 inputs (v0,v1,v2,v3) in order.tile=2x2: Consumes the 4 interleaved frames and stitches them into a single 1280x720 video frame.-map "[outv]": Directs the filtered video output into the destination file.