QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
354 stars 49 forks source link

Add more control to pause feature #30

Closed dkerr64 closed 1 year ago

dkerr64 commented 1 year ago

I'd suggest two new controls be added to the pause feature.

  1. A timer... so that a paused stream starts automatically again after a specified number of seconds. And then stops based on whatever criteria are set (ie, if no motion then after the timeout).
  2. To immediately stop on an Iframe... unless other activity blocks the stop (e.g. motion, a rtsp client steaming).

These controls would be optionally set in the config file.

With these neolink would be able to e.g. sleep for 10 minutes, start a stream, capture a single Iframe, and then pause until something triggers it again.

Thanks.

QuantumEntangledAndy commented 1 year ago

Since your trying to achieve a jpeg every x seconds it might be more intuitive to make an option that says writes a jpeg every x seconds rather than these complicated options.

dkerr64 commented 1 year ago

It's not that I'm trying to save a jpeg every X seconds. I'm content to save one on every Iframe as what I want is extremely fast access (via a web page that I have built) to whatever the most recent jpeg is.

But, what I am trying to achieve is power optimization. The camera I need this for is Argus 3 pro that is Wifi and battery powered. It is located such that it can only be charged for a few hours a day... so it needs to be able to run up to, say, 20 hours between charges. While I have not tried it, I'm pretty sure that if I stream continuously then it will not last 20 hours.

My objective is therefore to start a stream, capture a jpeg, then sleep for X seconds (e.g. 10 minutes), then start the process again. As pausing the video steam achieves my power objectives (I hope?), I thought that the simplest way to achieve a periodic wake/sleep cycle would be to camp-on to the existing pause capability in neolink. It is not unique to jpeg, it could apply just as usefully to the rtsp pause feature.

How it is exposed in config file could be "save jpeg every X seconds" but that feels too specific and not in fact what I want nor what I think is the simplest to implement.

QuantumEntangledAndy commented 1 year ago

I see. This should be ok to do but I’d like to keep the config simple if possible. There’s already a lot of options in there. If we have anything complex it might be worth adding controls to the mqtt interface (or make a rest interface) so we can let the user script it.

I should note that this sort of power optimisation might not be enough. User report a fast drain on power just by being logged even without the stream. I was planning to make pause do a full logout and then await an email from the camera when motion is detected instead of staying logged in but it’s not implemeted yet.

dkerr64 commented 1 year ago

I'd be interested to know how you will implement receiving an email. I have setup my own mail server to receive emails (not general purpose, but like this use case very specific to an action I want to trigger). But my ISP blocks port 25. The only workaround I came up with is to use a virtual server at a hosting provider so my MX record points there. That VM uses iptables to NAT forward (over a VPN) to my actual mail server which monitors and can act on incoming email.

QuantumEntangledAndy commented 1 year ago

Yeah it may be difficult to do. I am not expecting it to work outside of the local network. Also we can set ports other than 25 on the camera, but this will still fail without the appropriate NAT forwards which won't work at all if your behind a CGNAT like I am. It will just be another option that may sometimes work for certain users. Might also want to see how hard it would be to emulate the push notification method too.

QuantumEntangledAndy commented 1 year ago

I suppose we could also do a setup with sendgrid or similar and the ask for an api key for the app. That would get around a lot of the NAT issues.

dkerr64 commented 1 year ago

On my Argus 3 pro, I can set a from address and a to address but cannot configure a custom SMTP server, so I assume it is hardwired to connect to a Reolink mail server. That means that any email will originate externally and attempt to send via MX record for the domain.

Can sendgrid API notify a listener on receipt of an email? That may work.

For me however, it adds no value. On the battery cameras the email cannot be set to a schedule (like send me a JPEG every 10 minutes) instead it is only triggered on motion detection, which I have found not very reliable. And in many cases the camera is too slow to respond... if a person walks by, or car drives by, then the picture is takes is too late... person or car has already moved out of frame !!! Duh!

QuantumEntangledAndy commented 1 year ago

Can sendgrid API notify a listener on receipt of an email? That may work.

I think you can setup webhooks to send a post-request to a server of your choice but I haven't used that feature yet

QuantumEntangledAndy commented 1 year ago

but cannot configure a custom SMTP server

Thats a little odd I can definitely setup the smtp in both my E1 and Argus2E. Might still be able to set it via sending the right commands even if the UI on your app lacks it

dkerr64 commented 1 year ago

but cannot configure a custom SMTP server

Thats a little odd I can definitely setup the smtp in both my E1 and Argus2E. Might still be able to set it via sending the right commands even if the UI on your app lacks it

You are right. I found it down under the "from email address" section. I forgot that I had set SMTP server in there.

However, if you want, you can close this as will not implement. I was suggesting it as a method for me to capture the still images at regular intervals. But I think we have that accomplished with the image feature now added. What we are left with on that is to make sure that we are power optimized (ie, should we explicitly log out after capturing the image). I have not yet started a periodic capture so don't yet know how the battery is going to last.

THanks David

QuantumEntangledAndy commented 1 year ago

Sure shall close then, hope we can optimise the battery usage. I suspect you will need an explicit logout and disconnect to save power. Just staying connected to requires an acknowledgment packet every 0.1s and a keepalive every 0.5s or so which will add up I think

dkerr64 commented 1 year ago

Battery messages are sent regularly from the camera. I think we should capture them and "do something" what exactly I don't know yet, but progress would be at least recording the status. I'll open another issue for that.

Thanks David