Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry mechanism #11

Open
7aklhz opened this issue Nov 25, 2023 · 3 comments
Open

Retry mechanism #11

7aklhz opened this issue Nov 25, 2023 · 3 comments

Comments

@7aklhz
Copy link

7aklhz commented Nov 25, 2023

Hi. Thank you for sharing your code and experience. I'm looking at https://medium.com/@tom.humph/saving-rtsp-camera-streams-with-ffmpeg-baab7e80d767 and was wondering if you know how to implement and handle retry / relaunch on (stream) error?

@TomHumphries
Copy link
Owner

I've tried a couple of approaches.

The first method had the logic for connecting and saving the stream encapsulated within a class. This class has logic to catch disconnection errors and reopen the connection. However after a few days this would drop the connection in a way that wasn't caught. I was never sure how it slipped through as the stream just... stopped.

The second method involved creating a separate "watcher" method / service. It checked the folder the video files were saved into for changes to files. If there were no changes for at least X seconds it would assume that the stream had crashed. It would then tell the stream class kill the stream (if still open), and try to open it again.
This didn't always pick up crashed streams immediately, but did prove to be more reliable.

I'd be interested to hear what solution you've come up with!

@7aklhz
Copy link
Author

7aklhz commented Dec 5, 2023

This is actually what I ended up doing : https://gist.github.com/7aklhz/87bdf1bf2e1e06f77633b4949a0d948c

I make an infinity loop that tries to curl the url. If 200 ok then start ffmpeg if not retry curl after 5 seconds.

@TomHumphries
Copy link
Owner

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants