From a138463f7107f9dd1af5b938590eec0e3ca52fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20K=C3=BCnzel?= <simonk@fsmpi.rwth-aachen.de> Date: Sat, 3 May 2025 17:41:31 +0200 Subject: [PATCH] #45 FFProbe: Fix missing conversion from seconds to nanoseconds --- common_py/src/videoag_common/ffmpeg/ffprobe.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common_py/src/videoag_common/ffmpeg/ffprobe.py b/common_py/src/videoag_common/ffmpeg/ffprobe.py index aab86f6..0d1b011 100644 --- a/common_py/src/videoag_common/ffmpeg/ffprobe.py +++ b/common_py/src/videoag_common/ffmpeg/ffprobe.py @@ -34,7 +34,7 @@ class FFProbeImageStream(FFProbeStream): height: int -def _parse_duration_string_human(val: str) -> int: +def _parse_duration_string_human_to_ns(val: str) -> int: match = re.match("(?>(?>([0-9]+):)?([0-9]+):)?([0-9]+)(?>\\.([0-9]+))?", val) if match is None: raise ValueError(f"Unable to parse duration: {val}") @@ -43,8 +43,8 @@ def _parse_duration_string_human(val: str) -> int: seconds = int(match.group(3)) nanos = int(match.group(4) or "0") return math.ceil( - (hours * 60 + minutes) * 60 + seconds - + nanos / math.pow(10, 9) + ((hours * 60 + minutes) * 60 + seconds) * math.pow(10, 9) + + nanos ) @@ -56,7 +56,7 @@ def _get_stream_duration_ns(stream: dict): if tags is not None: duration_string = tags.get("DURATION") if duration_string is not None: - return _parse_duration_string_human(duration_string) + return _parse_duration_string_human_to_ns(duration_string) raise Exception(f"Unable to get duration from stream: {stream}") -- GitLab