I use some Hikvision CCTV cameras, and wanted to stream a 4-in-1 view from my Kodi system. VLC provides this functionality with it's mosaic feature, so it can be configured to take 4 streams in, combine them, and stream them back out again.
I got most of my configuration from this blog - http://alex.mamchenkov.net/2014/11/27/vlc-mosaic-multiple-rstp-streams/
However, I had to lower the resolution on my inputs to get it to work. Soeven though the cameras support high resolution, I configured the cameras 'Sub Stream' to a 640x480 MJPEG stream, given that I will have them only taking up 1/4 of the screen.
My config looks like this:
new channel1 broadcast enabled
setup channel1 input "rtsp://user:password@camera1/Streaming/Channels/2"
setup channel1 output #mosaic-bridge{id=1,height=540,width=960}
new channel2 broadcast enabled
setup channel2 input "rtsp://user:password@camera2/Streaming/Channels/2"
setup channel2 output #mosaic-bridge{id=2,height=540,width=960}
new channel3 broadcast enabled
setup channel3 input "rtsp://user:password@camera3/Streaming/Channels/2"
setup channel3 output #mosaic-bridge{id=3,height=540,width=960}
new channel4 broadcast enabled
setup channel4 input "rtsp://user:password@camera4/Streaming/Channels/2"
setup channel4 output #mosaic-bridge{id=4,height=540,width=960}
new mosaic broadcast enabled
setup mosaic input file:///home/myhome/mosaic/bg.jpg
setup mosaic option image-duration=-1
setup mosaic option image-fps=10/1
setup mosaic option mosaic-rows=2
setup mosaic option mosaic-cols=2
setup mosaic option mosaic-position=1
setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,vb=4096,acodec=none,fps=10/1,scale=1}:rtp{dst=myserverip,port=50000,sdp=rtsp://myserverip:50000/cctv.sdp}
control channel1 play
control channel2 play
control channel3 play
control channel4 play
control mosaic play
(Just replacing user/password and camera IPs where appropriate and also replace myserverip for the system you will run VLC on)
Then run vlc against the config file:
/usr/bin/vlc -I dummy --vlm-conf /path/to/your/file/hikvision_mosaic.conf --mosaic-width 1920 --mosaic-order 1,2,3,4 --mosaic-height 1080
You're now ready to watch your stream by pointing your favourite client at:
rtsp://myserverip:50000/cctv.sdp
To view the stream from XBMC/Kodi you need to create a plain text file eg ;'cctv_montage.strm' and place the above URL here in 1 line (rtsp://myserverip:50000/cctv.sdp)
I've got some work to do to auto-start or daemonize this, but this is main part done.