10

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.

Machavity
  • 30,841
  • 27
  • 92
  • 100
CoryG
  • 2,429
  • 3
  • 25
  • 60
  • possible duplicate of [Best way to combine 16 live streams into a live 4x4 collage within Linux](http://stackoverflow.com/questions/15390530/best-way-to-combine-16-live-streams-into-a-live-4x4-collage-within-linux) – Hasturkun Mar 13 '13 at 18:15
  • 2
    It's not a duplicate, I've been leaning toward ffmpeg but I asked if there was a better way in another thread to see if there is one. This thread is specifically how to accomplish a live streaming collage in ffmpeg. – CoryG Mar 13 '13 at 18:59

1 Answers1

9

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.

Digikata
  • 1,821
  • 17
  • 25
  • Is there a way to use the overlay filter as an output stream? – CoryG Mar 13 '13 at 18:05
  • 1
    Yes, 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 http://ffmpeg.org/trac/ffmpeg/wiki/StreamingGuide – Digikata Mar 13 '13 at 18:13
  • 3
    Also see the [multiple input overlay in 2x2 grid](https://ffmpeg.org/trac/ffmpeg/wiki/FilteringGuide#multipleinputoverlayin2x2grid) example on the [FFmpeg Community Contributed Documentation Wiki](https://ffmpeg.org/trac/ffmpeg/wiki). – llogan Mar 13 '13 at 18:16
  • Thanks for the great references! – CoryG Mar 13 '13 at 18:58
  • 1
    There's a also tutorial here: http://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos – BenC Jul 21 '13 at 07:18