refactor: enhance error logging in RTSPReader for better debugging of frame capture issues
Some checks failed
Build Worker Base and Application Images / deploy-stack (push) Blocked by required conditions
Build Worker Base and Application Images / check-base-changes (push) Successful in 7s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Has been cancelled

This commit is contained in:
Siwat Sirichai 2025-09-26 01:42:30 +07:00
parent cb9ff7bc86
commit c6a4258055

View file

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