How to join two images into one with FFmpeg?

n2v2rda2 picture n2v2rda2 · Jul 7, 2014 · Viewed 13.6k times · Source

There are two images: a.jpg and b.jpg.

I just want to know how to join them into one image using ffmpeg.

How should I finish the ffmpeg -i a.jpg -i b.jpg command to get a c.jpg output image?

This is an example of what I am trying to achieve:

  1. a.jpg

    a.jpg

  2. b.jpg

    b.jpg

  3. c.jpg

    a.jpg and b.jpg side-by-side on one image

Answer

llogan picture llogan · Jun 19, 2016

Use the hstack filter.

2 images:

ffmpeg -i a.jpg -i b.jpg -filter_complex hstack output.jpg

3 images:

ffmpeg -i a.jpg -i b.jpg -i c.jpg -filter_complex "[0][1][2]hstack=inputs=3" output.jpg