From 88b903ba39c09a05f669234866693bfaa7d5ff9a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 29 Jan 2023 16:20:42 -0700 Subject: [PATCH] Restart ffmpeg if process exceeds detect fps by 10 (#5280) * Restart ffmpeg if process exceeds detect fps by 10 * Update frigate/video.py Co-authored-by: Felipe Santos * spelling --------- Co-authored-by: Felipe Santos --- frigate/video.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frigate/video.py b/frigate/video.py index 5e31dc457..d3467c9e9 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -269,7 +269,20 @@ class CameraWatchdog(threading.Thread): self.logger.info("Waiting for ffmpeg to exit gracefully...") self.ffmpeg_detect_process.communicate(timeout=30) except sp.TimeoutExpired: - self.logger.info("FFmpeg didnt exit. Force killing...") + self.logger.info("FFmpeg did not exit. Force killing...") + self.ffmpeg_detect_process.kill() + self.ffmpeg_detect_process.communicate() + elif self.camera_fps.value >= (self.config.detect.fps + 10): + self.camera_fps.value = 0 + self.logger.info( + f"{self.camera_name} exceeded fps limit. Exiting ffmpeg..." + ) + self.ffmpeg_detect_process.terminate() + try: + self.logger.info("Waiting for ffmpeg to exit gracefully...") + self.ffmpeg_detect_process.communicate(timeout=30) + except sp.TimeoutExpired: + self.logger.info("FFmpeg did not exit. Force killing...") self.ffmpeg_detect_process.kill() self.ffmpeg_detect_process.communicate()