Page 1 of 1

Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 01:06
by Quaker56
I have two IP cameras that I like to monitor so I can be aware when customers are arriving. Watching one via RTSP stream straight up in VLC uses 1% CPU which is great. So, when I'm at work I fire up two VLC instances and move them into the corner of one of my monitors where they sit the rest of the day and only sip a measly 2%. The video doesn't lag, it's great compared to watching in the camera system's browser interface which used 20% and lagged hard.

Wanting to make things easier on myself I figured I would spin up a 'mosaic' with VLC so the two cams open with a single click and are bonded into one VLC instance. Well, that works nice but it uses 6% CPU as compared to 2%, probably because it's transcoding the two videos into a new one on the fly. Fair enough because I guess that's what I asked for... but between the choices I'll stick with the 2% dual instances and 10 seconds of manual daily positioning.

But... before I throw in the towel I figured it best to ask if there are any other suggestions for showing two streams side by side while retaining the better resource efficiency. The two RTSP streams are from identical cameras, same resolution (low 640x360), same framerate(15), and I don't want any audio. I would also be happy scripting the two separate VLC instances to launch at specified screen positions just to save the manual handling each day but I don't seem to be able to get the --video-x and --video-y settings to work, but that's a different topic... I just wanted to mention that it has been though of.

Thank you.

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 14:20
by Quaker56
Additional thoughts... I could offload the mosaic creation and transcoding from my computer to the camera system computer and have it spit out a new 'ready to view' RTSP stream. In-fact, other people in the office could then tap it too. Below is the output line from my conf-vlm file that works to display the mosaic locally. What do I need to add to for it to output an RTSP stream?

setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,vb=8500,acodec=none,fps=15,scale=1}:display

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 15:37
by Rémi Denis-Courmont
There are no ways to merge two encoded videos. You need to decode both, stitch and encode back the result. And then the client will decode again. So yes, it's going to be much slower.

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 17:33
by Quaker56
Thanks for the reply. Are you able to tell me how to have the mosaic output as a new RTSP stream? (I'm on Linux with VLC 3.0.9.x if that matters)

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 17:42
by Rémi Denis-Courmont
Not on top of my head. See the documentation.

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 17:56
by Quaker56
I did, and made several attempts, but I will revisit it and try again. Thanks.

Re: Live view multiple RTSP streams efficiently

Posted: 15 Dec 2020 19:33
by acffilterece
...and have it spit out a new RTSP stream...
Suggestion: use FFmpeg with the h-, vstack filters, then use ffserver to stream the encoded content. Note that, depending on codec, number of stacked streams, computer power, and eventual post-processing done, the encoded stream is either too big for your network to handle, or encoding is slow enough to not be realtime. Try libtheora, libvpx/-vp9, libxvid, mpeg1/2video (all free encoders, most in libavcodec, if your ffmpeg doesn't have it, get one of john van sickle's builds).