fixed progressbar crashing on non-video media

This commit is contained in:
Martin Sekera 2019-03-18 07:04:47 +01:00
parent 2929725416
commit e94c3d166f
3 changed files with 29 additions and 11 deletions

18
aux.py
View file

@ -4,6 +4,7 @@
import os
import pathlib
import over
import re
# --------------------------------------------------
@ -17,6 +18,23 @@ def parse_fps(raw):
# --------------------------------------------------
def parse_time(raw):
"""
Parses ffmpeg's state sentence containing the time= token.
E.g. b"... time=00:01:11.85 ..."
Returns the time in seconds, e.g. 71.85.
"""
s = re.findall(b"time=([^ ]+) ", raw)[0]
hh, mm, ss = (float(t) for t in s.split(b":"))
return hh * 3600 + mm * 60 + ss
# --------------------------------------------------
def to_Path(raw_path):
"""
Returns pathlib.Path pointing to raw_path, handling "~/" correctly.