diff --git a/common_py/src/videoag_common/ffmpeg/ffprobe.py b/common_py/src/videoag_common/ffmpeg/ffprobe.py index aab86f6e33ef3d89e30c4f667c9065865360b061..0d1b011f1b611998a2398cd80e9235f47373e1c1 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}")