Skip to content

Commit

Permalink
Improve duration estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
frafra committed Jul 30, 2024
1 parent 1a3e95c commit ae2c504
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/data_manager/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ def get_video_duration(self, path: Path) -> str:
"""
try:
cap = cv2.VideoCapture(str(path))
fps = cap.get(cv2.CAP_PROP_FPS)
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
duration = frame_count / fps
cap.set(cv2.CAP_PROP_POS_AVI_RATIO, 1)
duration = cap.get(cv2.CAP_PROP_POS_MSEC)
return str(datetime.timedelta(seconds=duration))
except cv2.error as error:
logger.error("Error occurred: %s", error)
Expand Down

0 comments on commit ae2c504

Please sign in to comment.