From c6a4258055c9694c2cd19a6d3b4e55c6510d843f Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 26 Sep 2025 01:42:30 +0700 Subject: [PATCH] refactor: enhance error logging in RTSPReader for better debugging of frame capture issues --- core/streaming/readers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/streaming/readers.py b/core/streaming/readers.py index 32a424a..78a3d45 100644 --- a/core/streaming/readers.py +++ b/core/streaming/readers.py @@ -94,8 +94,17 @@ class RTSPReader: if not ret or frame is None: consecutive_errors += 1 + # Verbose logging to see actual errors + logger.error(f"Camera {self.camera_id}: cap.read() failed - ret={ret}, frame={frame is not None}") + + # Try to get more info from the capture + if self.cap.isOpened(): + logger.debug(f"Camera {self.camera_id}: Capture still open, backend: {self.cap.getBackendName()}") + else: + logger.error(f"Camera {self.camera_id}: Capture is closed!") + if consecutive_errors >= self.max_consecutive_errors: - logger.error(f"Camera {self.camera_id}: Too many consecutive errors, reinitializing") + logger.error(f"Camera {self.camera_id}: Too many consecutive errors ({consecutive_errors}), reinitializing") self._reinitialize_capture() consecutive_errors = 0 time.sleep(self.error_recovery_delay)