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 = {
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()

View File

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