Frame time fix (#17816)

* Don't update thumbnail/snapshot if frame is not in the frame cache

This follows up on changes originally made in https://github.com/blakeblackshear/frigate/pull/17671 - it is possible that is_better_thumbnail is true but the frame_time for the object is not the same as the current_frame_time. So rather than checking the frame cache, this change will only update the thumbnail_data when the two frame time values are the same.

* add camera name to debug log
This commit is contained in:
Josh Hawkins 2025-04-21 17:36:10 -05:00 committed by GitHub
parent d5f9153c94
commit 6936d33172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -138,29 +138,15 @@ class TrackedObject:
if not self.false_positive and has_valid_frame: if not self.false_positive and has_valid_frame:
# determine if this frame is a better thumbnail # determine if this frame is a better thumbnail
if self.thumbnail_data is None or ( if self.thumbnail_data is None or is_better_thumbnail(
better_thumb := is_better_thumbnail(
self.obj_data["label"], self.obj_data["label"],
self.thumbnail_data, self.thumbnail_data,
obj_data, obj_data,
self.camera_config.frame_shape, self.camera_config.frame_shape,
)
): ):
# use the current frame time if the object's frame time isn't in the frame cache if obj_data["frame_time"] == current_frame_time:
selected_frame_time = (
current_frame_time
if obj_data["frame_time"] not in self.frame_cache.keys()
else obj_data["frame_time"]
)
if (
obj_data["frame_time"] not in self.frame_cache.keys()
and not better_thumb
):
logger.warning(
f"Frame time {obj_data['frame_time']} not in frame cache, using current frame time {selected_frame_time}"
)
self.thumbnail_data = { self.thumbnail_data = {
"frame_time": selected_frame_time, "frame_time": obj_data["frame_time"],
"box": obj_data["box"], "box": obj_data["box"],
"area": obj_data["area"], "area": obj_data["area"],
"region": obj_data["region"], "region": obj_data["region"],
@ -177,6 +163,10 @@ class TrackedObject:
), ),
} }
thumb_update = True thumb_update = True
else:
logger.debug(
f"{self.camera_config.name}: Object frame time {obj_data['frame_time']} is not equal to the current frame time {current_frame_time}, not updating thumbnail"
)
# check zones # check zones
current_zones = [] current_zones = []