Skip to content

NVR with realtime local object detection for IP cameras

Improve handling of empty frames (#13651)

Nicolas Mowenceb7aa8b3681
diff --git a/frigate/object_processing.py b/frigate/object_processing.py
index 330ba0e24a..50d9629178 100644
--- a/frigate/object_processing.py
+++ b/frigate/object_processing.py
@@ -881,7 +881,7 @@ class CameraState:
current_thumb_frames = {
obj.thumbnail_data["frame_time"]
for obj in tracked_objects.values()
- if not obj.false_positive
+ if not obj.false_positive and obj.thumbnail_data is not None
}
current_best_frames = {
obj.thumbnail_data["frame_time"] for obj in self.best_objects.values()
diff --git a/frigate/video.py b/frigate/video.py
index 80749c6546..f31b1d267b 100755
--- a/frigate/video.py
+++ b/frigate/video.py
@@ -188,6 +188,7 @@ class CameraWatchdog(threading.Thread):
self.frame_queue = frame_queue
self.frame_shape = self.config.frame_shape_yuv
self.frame_size = self.frame_shape[0] * self.frame_shape[1]
+ self.fps_overflow_count = 0
self.stop_event = stop_event
self.sleeptime = self.config.ffmpeg.retry_interval
@@ -237,18 +238,25 @@ class CameraWatchdog(threading.Thread):
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()
+ self.fps_overflow_count += 1
+
+ if self.fps_overflow_count == 3:
+ self.fps_overflow_count = 0
+ 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()
+ else:
+ # process is running normally
+ self.fps_overflow_count = 0
for p in self.ffmpeg_other_processes:
poll = p["process"].poll()