WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

FR: Merge multiple RTSP cameras into one WebRTC stream

Open scstraus opened this issue 3 years ago • 8 comments

Hi,

A lot of people, including myself, are bumping up against the limits of how many WebRTC sessions we can have going in a single browser window. One thing that would really make this the "ultimate" camera option for hass would be if we could somehow merge those camera stream into one WebRTC stream. I think this would alleviate most of the issues people have about displaying multiple cameras. A google search returned this as a starting point: https://stackoverflow.com/questions/59320085/record-multiple-rtsp-streams-into-a-single-file#59324096 What do you think?

scstraus avatar May 25 '21 11:05 scstraus

I think it may be big CPU overhead on server. I prefer to make an online video on demand. But if someone makes an addon that merges together the video and outputs RTSP - it can be connected to WebRTC component.

AlexxIT avatar May 25 '21 12:05 AlexxIT

Problem with 1 WebRTC stream per camera is that there will always be a hard limit to how many you can display on an endpoint (for me it's 3-4). A single stream would solve that. Unfortunately I've found nothing that can easily merge streams yet.

If there's no chance to implement it, you can close it.

scstraus avatar May 25 '21 18:05 scstraus

I'm facing with the same problem. Have you found the way to merge multi merge multi webrtc stream into one from server? @scstraus

duy-nv avatar Aug 06 '21 02:08 duy-nv

No not really. Nothing easy enough for me to implement quickly at least.

scstraus avatar Aug 07 '21 09:08 scstraus

I'm extremely interested in this as well. I actually have no issue streaming 4 at once but when doing so to a Chromecast Ultimate, the frame rate drops into the single digits and sometimes the hardware overheats and locks up. Heh.

I'm trying to find a docker-based solution to combining 4 RTSP streams into 1. If I come up with something I'll report back. Please do the same.

RyanEwen avatar Aug 23 '21 20:08 RyanEwen

Hi, I found the same concept on this docker project https://hub.docker.com/r/migoller/live555proxyserverdocker I think we can do like what it implement

ahmadnbl avatar Nov 07 '21 11:11 ahmadnbl

Hi, I found the same concept on this docker project https://hub.docker.com/r/migoller/live555proxyserverdocker I think we can do like what it implement

This won't merge the streams into a single stream, it just proxies them so that multiple endpoints can access the stream without opening individual streams to the original source. I actually use it in my camera setup.

scstraus avatar Nov 08 '21 00:11 scstraus

https://github.com/aler9/rtsp-simple-server This is used by frigate to proxy streams out and it has an HTTP api to switch the streams. This may be what is needed

whinis avatar Aug 11 '22 01:08 whinis

Check my new project. It has integration with ffmpeg: https://github.com/AlexxIT/go2rtc

And ffmpeg can join multiple streams to one output: https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos%20using%20xstack

Unfortunately, I don't have the time to make the right command myself.

AlexxIT avatar Aug 21 '22 11:08 AlexxIT

I think the goal is less mosaic and more a switchable output but only 1 stream

whinis avatar Aug 21 '22 13:08 whinis

Well. You may create different Hass tabs and switch them. So only one stream will be simultaneously.

AlexxIT avatar Aug 21 '22 15:08 AlexxIT

Thanks AlexIT. The FFMPEG option may work for me. It is indeed a mosaic I need as I want to watch 4 streams on my Fire tablets around the house but they aren't strong enough to open 4 WebRTC cards at once. I think one big one with all 4 streams will be better. I don't want to switch between them, that would be worse than the FFMPEG streams that already work. Thanks

scstraus avatar Aug 25 '22 06:08 scstraus

Could you provide working command when you get it? I'll add it to docs :)

AlexxIT avatar Aug 25 '22 08:08 AlexxIT

I'll be honest, it's a bit of a big job so I'm not sure I will get to it very soon as I'm still working okay with my ffmpeg camera approach, despite acknowledging that this solution is likely superior in many ways.

scstraus avatar Aug 31 '22 18:08 scstraus