Skip to content

Commit

Permalink
add duration to cache
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Nov 19, 2021
1 parent a3301e0 commit e6d2df5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frigate/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def move_files(self):
continue

if cache_path in self.end_time_cache:
end_time = self.end_time_cache[cache_path]
end_time, duration = self.end_time_cache[cache_path]
else:
ffprobe_cmd = [
"ffprobe",
Expand All @@ -144,9 +144,8 @@ def move_files(self):
p = sp.run(ffprobe_cmd, capture_output=True)
if p.returncode == 0:
duration = float(p.stdout.decode().strip())
self.end_time_cache[
cache_path
] = end_time = start_time + datetime.timedelta(seconds=duration)
end_time = start_time + datetime.timedelta(seconds=duration)
self.end_time_cache[cache_path] = (end_time, duration)
else:
logger.warning(f"Discarding a corrupt recording segment: {f}")
Path(cache_path).unlink(missing_ok=True)
Expand Down

0 comments on commit e6d2df5

Please sign in to comment.