Improve handling of empty frames (#13651)

This commit is contained in:
Nicolas Mowen 2024-09-10 07:39:37 -06:00 committed by GitHub
parent cae11cbb86
commit ceb7aa8b36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 13 deletions

View File

@ -881,7 +881,7 @@ class CameraState:
current_thumb_frames = { current_thumb_frames = {
obj.thumbnail_data["frame_time"] obj.thumbnail_data["frame_time"]
for obj in tracked_objects.values() 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 = { current_best_frames = {
obj.thumbnail_data["frame_time"] for obj in self.best_objects.values() obj.thumbnail_data["frame_time"] for obj in self.best_objects.values()

View File

@ -188,6 +188,7 @@ class CameraWatchdog(threading.Thread):
self.frame_queue = frame_queue self.frame_queue = frame_queue
self.frame_shape = self.config.frame_shape_yuv self.frame_shape = self.config.frame_shape_yuv
self.frame_size = self.frame_shape[0] * self.frame_shape[1] self.frame_size = self.frame_shape[0] * self.frame_shape[1]
self.fps_overflow_count = 0
self.stop_event = stop_event self.stop_event = stop_event
self.sleeptime = self.config.ffmpeg.retry_interval self.sleeptime = self.config.ffmpeg.retry_interval
@ -237,6 +238,10 @@ class CameraWatchdog(threading.Thread):
self.ffmpeg_detect_process.kill() self.ffmpeg_detect_process.kill()
self.ffmpeg_detect_process.communicate() self.ffmpeg_detect_process.communicate()
elif self.camera_fps.value >= (self.config.detect.fps + 10): elif self.camera_fps.value >= (self.config.detect.fps + 10):
self.fps_overflow_count += 1
if self.fps_overflow_count == 3:
self.fps_overflow_count = 0
self.camera_fps.value = 0 self.camera_fps.value = 0
self.logger.info( self.logger.info(
f"{self.camera_name} exceeded fps limit. Exiting ffmpeg..." f"{self.camera_name} exceeded fps limit. Exiting ffmpeg..."
@ -249,6 +254,9 @@ class CameraWatchdog(threading.Thread):
self.logger.info("FFmpeg did not exit. Force killing...") self.logger.info("FFmpeg did not exit. Force killing...")
self.ffmpeg_detect_process.kill() self.ffmpeg_detect_process.kill()
self.ffmpeg_detect_process.communicate() self.ffmpeg_detect_process.communicate()
else:
# process is running normally
self.fps_overflow_count = 0
for p in self.ffmpeg_other_processes: for p in self.ffmpeg_other_processes:
poll = p["process"].poll() poll = p["process"].poll()