How to Set Background Color in FFmpeg Tile Filter
This article explains how to configure the background color of an
image grid or contact sheet using the FFmpeg tile video
filter. You will learn how to use the built-in color option
within the filter, how color behaves across margins, padding, and empty
frames, and the correct syntax for specifying named or hex-coded colors
in your command line.
The color
Parameter in the tile Filter
The FFmpeg tile filter includes a dedicated
color option that defines the background color. This color
fills the outer margins, the padding between frames, and any empty grid
slots when the number of input frames does not fill the complete
matrix.
The default background color is black. You can specify a
different color by setting color=<value>. FFmpeg
accepts standard color names (such as white,
red, blue) as well as 24-bit/32-bit
hexadecimal values (such as 0xFFFFFF or
#FFFFFF).
Syntax Overview
tile=layout:margin=pixels:padding=pixels:color=color_value
You can also use named key-value arguments:
tile=layout=3x3:margin=10:padding=10:color=white
Practical Examples
1. Basic Tile Grid with a White Background
To create a 3x3 contact sheet from a video with a white background:
ffmpeg -i input.mp4 -vf "select='not(mod(n\,100))',scale=320:180,tile=3x3:color=white" -frames:v 1 contact_sheet.pngIn this command:
select='not(mod(n\,100))'samples every 100th frame.scale=320:180resizes the extracted frames.tile=3x3:color=whitearranges nine frames into a 3x3 layout, filling any unpopulated cells with white.
2. Adding Margins and Padding with Color
The background color is most visible when defining space around the
images using margin (outer border) and padding
(inner gaps between tiles):
ffmpeg -i input.mp4 -vf "fps=1,scale=300:-1,tile=4x3:margin=20:padding=10:color=lightgray" -frames:v 1 output.jpgmargin=20leaves a 20-pixel border around the entire canvas.padding=10creates a 10-pixel gap between each frame.color=lightgrayapplies the color to both the outer margin and internal padding.
3. Using Hexadecimal Colors
To match a specific brand palette or interface theme, pass a hex code:
ffmpeg -i input.mp4 -vf "fps=1/5,scale=240:-1,tile=3x2:margin=15:padding=8:color=0x1E1E2E" -frames:v 1 preview.png0x1E1E2Esets a custom dark-slate background color.
4. Transparent Backgrounds
If you output to an image format that supports alpha channels (such as PNG), you can set the background to transparent:
ffmpeg -i input.mp4 -vf "fps=1,scale=320:-1,tile=3x3:margin=10:padding=10:color=none" -frames:v 1 transparent_sheet.png- Setting
color=noneorcolor=0x00000000creates fully transparent margins and gaps.