Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine multiple ffmpeg streams into a single 4x4 collage?

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.

like image 498
CoryG Avatar asked Mar 13 '13 16:03

CoryG


1 Answers

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.

like image 158
Digikata Avatar answered Sep 21 '22 15:09

Digikata