Add more debug logs for preview and output (#14833)

This commit is contained in:
Nicolas Mowen 2024-11-06 06:59:33 -07:00 committed by GitHub
parent fc0fb158d5
commit 2eb5fbf112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View File

@ -63,6 +63,7 @@ def output_frames(
birdseye: Optional[Birdseye] = None
preview_recorders: dict[str, PreviewRecorder] = {}
preview_write_times: dict[str, float] = {}
failed_frame_requests: dict[str, int] = {}
move_preview_frames("cache")
@ -99,7 +100,16 @@ def output_frames(
if frame is None:
logger.debug(f"Failed to get frame {frame_id} from SHM")
failed_frame_requests[camera] = failed_frame_requests.get(camera, 0) + 1
if failed_frame_requests[camera] > config.cameras[camera].detect.fps:
logger.warning(
f"Failed to retrieve many frames for {camera} from SHM, consider increasing SHM size if this continues."
)
continue
else:
failed_frame_requests[camera] = 0
# send camera frame to ffmpeg process if websockets are connected
if any(

View File

@ -154,6 +154,7 @@ class PreviewRecorder:
self.start_time = 0
self.last_output_time = 0
self.output_frames = []
if config.detect.width > config.detect.height:
self.out_height = PREVIEW_HEIGHT
self.out_width = (
@ -274,7 +275,7 @@ class PreviewRecorder:
return False
def write_frame_to_cache(self, frame_time: float, frame) -> None:
def write_frame_to_cache(self, frame_time: float, frame: np.ndarray) -> None:
# resize yuv frame
small_frame = np.zeros((self.out_height * 3 // 2, self.out_width), np.uint8)
copy_yuv_to_position(
@ -303,7 +304,7 @@ class PreviewRecorder:
current_tracked_objects: list[dict[str, any]],
motion_boxes: list[list[int]],
frame_time: float,
frame,
frame: np.ndarray,
) -> bool:
# check for updated record config
_, updated_record_config = self.config_subscriber.check_for_update()
@ -332,6 +333,10 @@ class PreviewRecorder:
self.output_frames,
self.requestor,
).start()
else:
logger.debug(
f"Not saving preview for {self.config.name} because there are no saved frames."
)
# reset frame cache
self.segment_end = (