How to combine multiple ffmpeg streams into a single 4x4 collage?
I think you're looking for the ffmpeg overlay filter, here is the documentation with some examples. A copy of a 2x1 example is below, but you'll have to make adjustments for your stream format, frame sizes and more panels.
ffmpeg -i left.avi -i right.avi -filter_complex "
nullsrc=size=200x100 [background];
[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
[background][left] overlay=shortest=1 [background+left];
[background+left][right] overlay=shortest=1:x=100 [left+right]
"
Alternately, there's also a way to generate a mosiac with VLC.
CoryG
Updated on July 23, 2022Comments
-
CoryG almost 2 years
I have a server with 16 video capture card channels coming into it and want to stream them with ffmpeg, is it possible to have another stream going out that is a 4x4 collage of the 16 unique channels?
Edit: Adding a bounty since no working answer has been submitted yet - will reward it to the first one that can show the code to produce a 4x4 grid of 16 live channels (input device being http:// localhost:8090/x.mpg where x= a number 0-15, 352x288 video in MPEG1VIDEO format, YUV420P color at 24-30FPS) - or code that leads me to that solution - the output will be located at http:// localhost:8090/all.mpg and will be a 1408x1152 mpg live stream.
-
CoryG over 11 yearsIs there a way to use the overlay filter as an output stream?
-
Digikata over 11 yearsYes, the output of the filter can be plugged into a stream just like any other ffmpeg output. The exact setup of the streaming can be complex answer depending on what your requirements are, but see ffmpeg.org/trac/ffmpeg/wiki/StreamingGuide
-
llogan over 11 yearsAlso see the multiple input overlay in 2x2 grid example on the FFmpeg Community Contributed Documentation Wiki.
-
CoryG over 11 yearsThanks for the great references!
-
BenC almost 11 yearsThere's a also tutorial here: trac.ffmpeg.org/wiki/…