12

I wish to combine multiple images into a single strip of images, using FFMPEG.

I have been trying to search this thing on google, but unable to find anything useful. All links take me to places where multiple images are combined to give a video output.

Assuming that all the files are of the same width and height, how can I join them to get a single strip of images. Can anybody help me?

Manu
  • 953
  • 2
  • 7
  • 9
  • Number of images would be variable. It can range from 10 to several 100s. And I want a horizontal strip. – Manu Jul 30 '13 at 05:36

2 Answers2

22

Use the tile filter

tile

Using the scale and tile video filters with input files 001.png to 005.png:

ffmpeg -i %03d.png -filter_complex "scale=120:-1,tile=5x1" output.png

If you have file names that are in a non-numbered sequential order you can use the glob pattern type (not supported by Windows):

ffmpeg -pattern_type glob -i "*.png" -filter_complex tile=5x1 output.png

Margin / border

You can also add a margin (outer border space) and padding (space between frames):

tile with margin and padding

ffmpeg -i %03d.png -filter_complex "scale=120:-1,tile=5x1:margin=10:padding=4" output.png

Default color is black. Add the color option if you want to change the border/margin color:

ffmpeg -i %03d.png -filter_complex "scale=120:-1,tile=5x1:margin=10:padding=4:color=white" output.png

A vertical orientation is possible. tile=1x5 for this example:

vertical tile

More info

See the tile filter documentation.

llogan
  • 57,139
  • 15
  • 118
  • 145
  • 1
    I'm using your command but the result I'm getting is (only first image is shown, all other are black): https://i.ibb.co/zPgPJ0V/Untitled.png – user2988257 Dec 03 '18 at 15:32
  • @user2988257 I can't duplicate that behavior. Provide a link to a pastebin that shows your full command and the complete console output. – llogan Dec 03 '18 at 17:59
  • @llogan If I have single image then How can I create tile from that? – Abhay Koradiya Jun 23 '21 at 08:01
  • @AbhayKoradiya `ffmpeg -i input.jpg -i input.jpg -i input.jpg -filter_complex "[0][1][2]hstack=inputs=3" -vframes 1 output.jpg` See [Vertically or horizontally stack (mosaic) several videos using ffmpeg?](https://stackoverflow.com/a/33764934/) – llogan Jun 24 '21 at 02:29
  • how can i set the color of the padding to be white? – Kong Jul 11 '21 at 01:36
  • 1
    @Kong According to the [tile filter documentation](https://ffmpeg.org/ffmpeg-filters.html#tile) use the `color` option: `ffmpeg -i %03d.png -filter_complex "scale=120:-1,tile=5x1:margin=10:padding=4:color=white" output.png` – llogan Jul 11 '21 at 16:44
  • I wanted to simply tile images together without reducing image quality and found this post. I modified it for my task using: ffmpeg -i %03d.png -filter_complex "tile=5x1" tiled.png What a great function: just by changing tile to untile you reverse the effect, and using 1x5 gives you vertical stitching. – Tony M Apr 06 '22 at 19:08
  • Didn't work for me had to use hstack instead https://stackoverflow.com/a/37903609/3984575 – dvdhns Dec 10 '22 at 02:47
5

If you've got do it with ffmpeg then I don't know. If you want to get the job done and are willing to use another program suitable for the task then convert is part of ImageMagick.

convert sepimage-0.png sepimage-1.png sepimage-2.png -channel RGB \
-combine imagecopy.png
slhck
  • 223,558
  • 70
  • 607
  • 592
cybernard
  • 13,380
  • 3
  • 29
  • 33