From ac54b8d607f6289103a033d4021c961bd951ad71 Mon Sep 17 00:00:00 2001 From: mrlt8 <67088095+mrlt8@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:00:24 -0700 Subject: [PATCH] Adjust sleep interval on frame error #1042 --- app/wyzecam/iotc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/wyzecam/iotc.py b/app/wyzecam/iotc.py index a88bcf37..0e5dfcca 100644 --- a/app/wyzecam/iotc.py +++ b/app/wyzecam/iotc.py @@ -316,7 +316,7 @@ def sleep_interval(self) -> float: delta = max(time.time() - self.frame_ts, 0.0) + self._sleep_buffer if self._sleep_buffer: - self._sleep_buffer = max(self._sleep_buffer - 0.1, 0) + self._sleep_buffer = max(self._sleep_buffer - 0.05, 0) return max((1 / self.preferred_frame_rate) - delta, 0.0) @@ -442,7 +442,7 @@ def recv_bridge_data(self) -> Iterator[bytes]: have_key_frame = False continue - if self._video_frame_slow(frame_info) and have_key_frame: + if have_key_frame and self._video_frame_slow(frame_info): continue if frame_info.is_keyframe: @@ -503,8 +503,7 @@ def _video_frame_slow(self, frame_info) -> Optional[bool]: def _handle_frame_error(self, err_no: int) -> None: """Handle errors that occur when receiving frame data.""" - # time.sleep(self.sleep_interval) - time.sleep(0.05) + time.sleep(1 / 25) if err_no == tutk.AV_ER_DATA_NOREADY or err_no >= 0: return