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 <felipecassiors@gmail.com>

* spelling

---------

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
This commit is contained in:
Nicolas Mowen 2023-01-29 16:20:42 -07:00 committed by GitHub
parent 116edce3dc
commit 88b903ba39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()