diff --git a/aux.py b/aux.py index f053a6f..144a0f7 100644 --- a/aux.py +++ b/aux.py @@ -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. diff --git a/over-video.py b/over-video.py index c57054d..e059d19 100755 --- a/over-video.py +++ b/over-video.py @@ -262,9 +262,9 @@ if __name__ == "__main__": if out: output_buffer.append(out) - if b"frame=" in out: - frame_id = re.findall(b"frame= *(\d+) ", out)[0] - pb.set("a", int(frame_id) / info.video_fps.value) + if b"time=" in out: + t = aux.parse_time(out) + pb.set("a", t) pb.render() elif out is None: @@ -398,11 +398,11 @@ if __name__ == "__main__": if main.cfg.armed: pb = over.text.ProgressBar( - "§%f §rs [§=f>§ F] §sf (§ss) (Sest=§zs, Trem=§TF)", + "§%a §rs [§=a>§ A] §sa (§ss) (Sest=§zs, Trem=§TA)", { - "f": { - "unit": "f", - "top": int(info.video_fps.value * info.duration), + "a": { + "unit": "s", + "top": int(info.duration), "precision": 1, "min_width_rate": 9 }, @@ -424,9 +424,9 @@ if __name__ == "__main__": out = encode_cmd.get_output() if out: - if b"frame=" in out: - frame_id = re.findall(b"frame= *(\d+) ", out)[0] - pb.set("f", int(frame_id)) + if b"time=" in out: + t = aux.parse_time(out) + pb.set("a", int(t)) elif out is None: break diff --git a/version.py b/version.py index 60b4c2a..5ec5269 100644 --- a/version.py +++ b/version.py @@ -4,5 +4,5 @@ major = 1 # VERSION_MAJOR_IDENTIFIER minor = 112 # VERSION_MINOR_IDENTIFIER # VERSION_LAST_MM 1.112 -patch = 1 # VERSION_PATCH_IDENTIFIER +patch = 2 # VERSION_PATCH_IDENTIFIER str = ".".join(str(v) for v in (major, minor, patch))