Skip to content

Commit

Permalink
Adjust sleep interval on frame error #1042
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Apr 19, 2024
1 parent 6f1b5b7 commit ac54b8d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/wyzecam/iotc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ac54b8d

Please sign in to comment.