refactor: improve error handling and logging in RTSPReader for frame capture failures
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
				
			
		
			
				
	
				Build Worker Base and Application Images / build-base (push) Has been skipped
				
			
		
			
				
	
				Build Worker Base and Application Images / build-docker (push) Successful in 2m55s
				
			
		
			
				
	
				Build Worker Base and Application Images / deploy-stack (push) Successful in 23s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
				
			Build Worker Base and Application Images / build-base (push) Has been skipped
				
			Build Worker Base and Application Images / build-docker (push) Successful in 2m55s
				
			Build Worker Base and Application Images / deploy-stack (push) Successful in 23s
				
			This commit is contained in:
		
							parent
							
								
									c6a4258055
								
							
						
					
					
						commit
						a1e7c42fb3
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -89,7 +89,11 @@ class RTSPReader:
 | 
			
		|||
                    continue
 | 
			
		||||
 | 
			
		||||
                # Read frame immediately without rate limiting for minimum latency
 | 
			
		||||
                ret, frame = self.cap.read()
 | 
			
		||||
                try:
 | 
			
		||||
                    ret, frame = self.cap.read()
 | 
			
		||||
                except Exception as read_error:
 | 
			
		||||
                    logger.error(f"Camera {self.camera_id}: cap.read() threw exception: {type(read_error).__name__}: {read_error}")
 | 
			
		||||
                    ret, frame = False, None
 | 
			
		||||
 | 
			
		||||
                if not ret or frame is None:
 | 
			
		||||
                    consecutive_errors += 1
 | 
			
		||||
| 
						 | 
				
			
			@ -98,10 +102,14 @@ class RTSPReader:
 | 
			
		|||
                    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!")
 | 
			
		||||
                    try:
 | 
			
		||||
                        if self.cap.isOpened():
 | 
			
		||||
                            backend = self.cap.getBackendName()
 | 
			
		||||
                            logger.debug(f"Camera {self.camera_id}: Capture still open, backend: {backend}")
 | 
			
		||||
                        else:
 | 
			
		||||
                            logger.error(f"Camera {self.camera_id}: Capture is closed!")
 | 
			
		||||
                    except Exception as info_error:
 | 
			
		||||
                        logger.error(f"Camera {self.camera_id}: Error getting capture info: {type(info_error).__name__}: {info_error}")
 | 
			
		||||
 | 
			
		||||
                    if consecutive_errors >= self.max_consecutive_errors:
 | 
			
		||||
                        logger.error(f"Camera {self.camera_id}: Too many consecutive errors ({consecutive_errors}), reinitializing")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue