diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-07-12 05:05:32 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-07-12 05:20:12 +0530 |
commit | 75722b037d0d1a273dceced9cfa82cc6a80d8adb (patch) | |
tree | 64614e3befa0ec9bce037c1ad06c8b0f7bd3c01f /yt_dlp/webvtt.py | |
parent | 2d6659b9ea24ecea1b0694c96711fef09aa87faa (diff) | |
download | hypervideo-pre-75722b037d0d1a273dceced9cfa82cc6a80d8adb.tar.lz hypervideo-pre-75722b037d0d1a273dceced9cfa82cc6a80d8adb.tar.xz hypervideo-pre-75722b037d0d1a273dceced9cfa82cc6a80d8adb.zip |
[webtt] Fix timestamps
Closes #474
Diffstat (limited to 'yt_dlp/webvtt.py')
-rw-r--r-- | yt_dlp/webvtt.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/yt_dlp/webvtt.py b/yt_dlp/webvtt.py index a184ee369..ef55e6459 100644 --- a/yt_dlp/webvtt.py +++ b/yt_dlp/webvtt.py @@ -120,12 +120,11 @@ def _format_ts(ts): Convert an MPEG PES timestamp into a WebVTT timestamp. This will lose sub-millisecond precision. """ - - ts = int((ts + 45) // 90) - ms , ts = divmod(ts, 1000) # noqa: W504,E221,E222,E203 - s , ts = divmod(ts, 60) # noqa: W504,E221,E222,E203 - min, h = divmod(ts, 60) # noqa: W504,E221,E222 - return '%02u:%02u:%02u.%03u' % (h, min, s, ms) + msec = int((ts + 45) // 90) + secs, msec = divmod(msec, 1000) + mins, secs = divmod(secs, 60) + hrs, mins = divmod(mins, 60) + return '%02u:%02u:%02u.%03u' % (hrs, mins, secs, msec) class Block(object): |