From d2e4d43c52d090940687269d7f08935573ee4104 Mon Sep 17 00:00:00 2001 From: acgnhik Date: Sun, 22 Oct 2023 13:54:16 +0800 Subject: [PATCH] fix: failed to remux m4s file urllib.error.URLError: --- src/blrec/postprocess/ffmpeg_metadata.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/blrec/postprocess/ffmpeg_metadata.py b/src/blrec/postprocess/ffmpeg_metadata.py index b772e1e..8a7ab9a 100644 --- a/src/blrec/postprocess/ffmpeg_metadata.py +++ b/src/blrec/postprocess/ffmpeg_metadata.py @@ -157,11 +157,13 @@ def _make_comment_for_discontinuities(timestamps: Iterable[int]) -> str: async def _get_discontinuities(playlist_path: str) -> Tuple[List[int], float]: loop = asyncio.get_running_loop() - playlist = await loop.run_in_executor(None, m3u8.load, playlist_path) - duration = Decimal() - timestamps: List[int] = [] - for seg in playlist.segments: - if seg.discontinuity: - timestamps.append(int(duration * 1000)) - duration += Decimal(str(seg.duration)) - return timestamps, float(duration) + async with aiofiles.open(playlist_path) as file: + content = await file.read() + playlist = await loop.run_in_executor(None, m3u8.loads, content) + duration = Decimal() + timestamps: List[int] = [] + for seg in playlist.segments: + if seg.discontinuity: + timestamps.append(int(duration * 1000)) + duration += Decimal(str(seg.duration)) + return timestamps, float(duration)