Skip to content

Commit

Permalink
add SLEEP_INTERVAL_FPS #388
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Dec 22, 2023
1 parent 225856c commit 4bfdd36
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/wyzecam/iotc.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def resolution(self) -> str:

@property
def sleep_interval(self) -> float:
if sleep_int_fps := os.getenv("SLEEP_INTERVAL_FPS"):
return 1 / int(sleep_int_fps)
return 1 / (self.preferred_frame_rate * 1.5)

def session_check(self) -> tutk.SInfoStructEx:
Expand Down Expand Up @@ -416,6 +418,7 @@ def recv_bridge_data(self) -> Iterator[bytes]:
)

if not frame_data or errno < 0:
# self.flush_pipe("audio")
self._handle_frame_error(errno)
continue

Expand Down Expand Up @@ -477,8 +480,8 @@ def _video_frame_slow(self, frame_info) -> Optional[bool]:

frame_ts = float(f"{frame_info.timestamp}.{frame_info.timestamp_ms}")
gap = time.time() - frame_ts
if gap > 20:
print("\n\nsuper slow\n\n")
if gap > 15:
print("\n\n[video] super slow\n\n")
self.clear_local_buffer()

if gap > 0.5:
Expand Down Expand Up @@ -583,8 +586,10 @@ def recv_audio_data(self, uri: str) -> None:
# Some cams can't sync
if self.frame_ts and frame_info.timestamp > 1591069888:
gap = self.frame_ts - frame_info.timestamp
if gap < -10 or gap > 10:
...
if gap < -15 or gap > 15:
print("\n\n[audio] super slow\n\n")
self.flush_pipe("audio")
self.clear_local_buffer()
if gap < -1:
logger.info(f"[audio] rushing.. {gap=}")
time.sleep(abs(gap) % 1)
Expand Down

0 comments on commit 4bfdd36

Please sign in to comment.