Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to set up a CCTV system with ffmpeg/ffserver/zoneminder and want a nice looking 4x4 grid without all the Java applet borders and window dongles on it, just a full screen 4x4 grid. I've gotten ffserver to stream webm for browsers and mpg for zoneminder, but when I build a page with 16 webm videos embedded into it it stalls out after loading about 5 at once. I'm looking for a way to take 16 live streams and combine them into a single live stream that is four times the width and height arranged in a grid.

I've tried using ffmpeg to handle this with the appropriate settings in /etc/ffserver.conf using the following:

/usr/local/bin/ffmpeg -i http://localhost:8090/0.webm -i http://localhost:8090/1.webm -i http://localhost:8090/2.webm -i http://localhost:8090/3.webm -i http://localhost:8090/4.webm -i http://localhost:8090/5.webm -i http://localhost:8090/6.webm -i http://localhost:8090/7.webm -i http://localhost:8090/8.webm -i http://localhost:8090/9.webm -i http://localhost:8090/10.webm -i http://localhost:8090/11.webm -i http://localhost:8090/12.webm -i http://localhost:8090/13.webm -i http://localhost:8090/14.webm -i http://localhost:8090/15.webm -filter_complex "
nullsrc=size=1280x960 [bg];
[0:v] setpts=PTS-STARTPTS, scale=320x240 [v0];
[1:v] setpts=PTS-STARTPTS, scale=320x240 [v1];
[2:v] setpts=PTS-STARTPTS, scale=320x240 [v2];
[3:v] setpts=PTS-STARTPTS, scale=320x240 [v3];
[4:v] setpts=PTS-STARTPTS, scale=320x240 [v4];
[5:v] setpts=PTS-STARTPTS, scale=320x240 [v5];
[6:v] setpts=PTS-STARTPTS, scale=320x240 [v6];
[7:v] setpts=PTS-STARTPTS, scale=320x240 [v7];
[8:v] setpts=PTS-STARTPTS, scale=320x240 [v8];
[9:v] setpts=PTS-STARTPTS, scale=320x240 [v9];
[10:v] setpts=PTS-STARTPTS, scale=320x240 [v10];
[11:v] setpts=PTS-STARTPTS, scale=320x240 [v11];
[12:v] setpts=PTS-STARTPTS, scale=320x240 [v12];
[13:v] setpts=PTS-STARTPTS, scale=320x240 [v13];
[14:v] setpts=PTS-STARTPTS, scale=320x240 [v14];
[15:v] setpts=PTS-STARTPTS, scale=320x240 [v15];
[bg][v0] overlay=shortest=1 [bg];
[bg][v1] overlay=shortest=1:x=320 [bg];
[bg][v2] overlay=shortest=1:x=640 [bg];
[bg][v3] overlay=shortest=1:x=960 [bg];
[bg][v4] overlay=shortest=1:y=240 [bg];
[bg][v5] overlay=shortest=1:x=320:y=240 [bg];
[bg][v6] overlay=shortest=1:x=640:y=240 [bg];
[bg][v7] overlay=shortest=1:x=960:y=240 [bg];
[bg][v8] overlay=shortest=1:y=480 [bg];
[bg][v9] overlay=shortest=1:x=320:y=480 [bg];
[bg][v10] overlay=shortest=1:x=640:y=480 [bg];
[bg][v11] overlay=shortest=1:x=960:y=480 [bg];
[bg][v12] overlay=shortest=1:y=720 [bg];
[bg][v13] overlay=shortest=1:x=320:y=720 [bg];
[bg][v14] overlay=shortest=1:x=640:y=720 [bg];
[bg][v15] overlay=shortest=1:x=960:y=720" http://localhost:8090/all_webm.ffm

But it comes in at only a few FPS and isn't suitable for live streaming.

Does anyone know how to do this with ffmpeg, or if there is a program that can do it that plugs into ffserver?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You are handling 16 streams, so your CPU has a hard job on it to convert. You seriously need enough CPU power to handle all that data.

I also see you are scaling each video. Scaling is a very time consuming process in a CPU. Maybe you can set up your camera streams to provide a scaled video already, so your CPU only needs to put them together.

You can also look for other options of encoding/decoding, because some encoders are like 10 times faster than the others.

share|improve this answer
    
I'm not sure why I had that scale in there, it was scaling to the same size as the inputs but removing it got me to 25FPS. –  CoryG Mar 18 '13 at 8:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.