keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.65k stars 230 forks source link

allow a single docker container to proxy multiple cameras (for unraid template) #141

Closed Mearman closed 2 years ago

Mearman commented 2 years ago

First of all. This is the holy grail I've been looking for. I'm going to have a proper play later and create an Unraid template later.

Do you have any objections to my contributing or publishing an Unraid template?

I haven't looked through your source yet. But would it be possible to add support for multiple camera proxying from a single instance? This is mainly because of the limitation where Unraid templates don't directly support using docker-compose.

It's not an issue when not running in a container, so without looking at your code yet, I'm imagining the most straightforward way might be to add a supervisor process that looks at the args and if multiple cameras have been defined, spin up a process for each. I'm thinking it could either be in the main image or another tag if a compatibility breaking change is needed?

keshavdv commented 2 years ago

Contributing a template would be awesome! At the moment, I don't plan to have the proxy handle separate cameras within a single invocation mainly because I think there are much better "supervisors" that are already out there (e.g. docker, systemd, etc). While it's a bit painful, I'd imagine set up for cameras is mostly a one time thing and having an Unraid template would help on that front.

sreknob commented 2 years ago

Thanks @keshavdv for this. For the unRAID template, the only issue is that the FFMPEG arguments aren't exposed in the entrypoint.sh file, they would need to be added for a better template experience. Right now, you'd need to add any custom FFMPEG arguments to the end of the RTSP_URL. I think that adding "$FFMPEG_ARGS" to the end of your exec line might do the trick, then we could use that as a variable.

Here's a fun icon concept I threw together for mine - it's a mashup of the UniFi and FFMPEG logos - https://i.imgur.com/Xpk9CLx.png (black) https://i.imgur.com/QHEviq3.png (colour)

image

image

keshavdv commented 2 years ago

Thanks for the icon concepts, they're super cool! I'm a bit hesitant to use anything that might be mistaken as "official" -- do you think we could come up with a version that doesn't incorporate the Unifi brand itself?

I'm not an Unraid user myself, but on the template front, I'm not sure how to best expose specific implementations rather than just the RTSP version by default. In almost all cases, the brand-specific implementations are going to offer more functionality and better performance. Do you think there should just be an additional Implementation and Implementation Args variable that replaces the RTSP URL field where people can put everything in? Something like

Unifi Token: abcd...
Camera MAC: AB:CD...
Unifi NVR IP: 192.168.0.100
Camera IP: 192.168.0.200
Implementation: hikvision
Implementation Args: --ffmpeg-args 'my extras' -u username -p password
sreknob commented 2 years ago

Oh, that would be great if you could add an implementation too. To make it backwards compatible, you could you another IF statement and if the implementation arg is present, then use the customized entry point. Totally get the issue with official confusion. Here is another with some variations if you're interested. They're just SVGs that I was messing around with :-) Standard With Background Swirl With Background Standard Swirl No Background

And here are the sources for you as well. If you open them in inkscape you'll see the variations with different layers.

Source for the ones listed above

The UniFi Logo one from my earlier post is here

EDIT - Some more options :-D

https://i.imgur.com/Zi6CkJR.png Cam+FFMPEG

https://imgur.com/UMDuGOh Shutter-Link

Haasie commented 2 years ago

Hello, @sreknob how does your RTSP with FFMPEG args look like if i may ask? I have an RLC-811 and the proxy is working (thanks to your template) but it is not steady an heavy in recources.

regards,

sreknob commented 2 years ago

@Haasie I'm actually not using any arguments at the moment, just the default ones that invoking RTSP uses. The reason it would be nice to have an entrypoint for args is that I need to work on custom ones as my live view doesn't work properly (although it records just fine). Haven't had the time to sort it out yet though... The default shouldn't be heavy on resources though as it should be just copying the streams for FFMPEG. I'm using 3 proxies currently and they are about 1% CPU use each with two using ~190MB RAM and another using ~620MB.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fratinize commented 2 years ago

Whatever happened with this?