sclaflin / Plate-Minder

Monitor a video source for license plates and record them. Zero cloud dependencies.
MIT License
154 stars 22 forks source link

Feature request: Source auto-restart #5

Closed jseidl closed 2 years ago

jseidl commented 2 years ago

Hi, one feature that would be extremely helpful would be auto-restart for sources when they crash/fail.

My MJPEG source sometimes flick around and I have to manually restart the source. It would be awesome if it could be auto-restarted on failures. Maybe an option auto_restart: True paired with max_retries: N?

Sample errors I get:

http://<USER:PWD>@<ADDR>/mjpg/DrivewayLeft: Input/output error
...
[http @ 0x55ad52744b00] Stream ends prematurely at 111198147, should be 18446744073709551615 http://<USER:PWD>@<ADDR>/mjpg/DrivewayRight: Input/output error

LMK if you need more info regarding this.

sclaflin commented 2 years ago

Plate-Minder should already be doing this now. If FFMPEG exits with a non-zero exit code, the stream is restarted after a five second delay. Did you see any logging similar to: "source failed"? It may be that there's an issue with your stream, but FFMPEG never exited.

jseidl commented 2 years ago

Hmmm weird. I'm using Plateminder-Web for debugging and I'm getting the stream occasionally crapping and not restarting by itself. I'd assume this is a scenario where ffmpeg exits with a non-zero EC and restarts but 🤷 still have to manually click on Start Source to get it going again

image

sclaflin commented 2 years ago

Weird indeed. If you're not seeing "source failed" anywhere in your logs, it would seem that FFMPEG is exiting with a "0" exit code.

I can add an "alwaysRestart" config option that's off by default. Turning it on would have it restart regardless of exit code, which sounds like it would solve your problem. Downside would be that streams won't stay stopped when you manually stop them.

Thoughts?

jseidl commented 2 years ago

I can add an "alwaysRestart" config option that's off by default. Turning it on would have it restart regardless of exit code, which sounds like it would solve your problem.

Yeap, sounds like it!

Downside would be that streams won't stay stopped when you manually stop them.

That's OK, could be solved by having a toggle on plateminder-web next to the start/stop controls that would update the config and reload like the other config controls. Would that work? Not sure what other cases one would want to stop the source, maybe programmatically?

sclaflin commented 2 years ago

Added an 'alwaysRestart' option for sources. You'll need to re-pull sclaflin/plate-minder:latest and sclaflin/plate-minder-web:latest.

Let me know how it goes!

jseidl commented 2 years ago

Pulled, will let it you know! Thanks!

jseidl commented 2 years ago

Just to update, this seems to be working well so far! Thanks!