diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c11798..96bc516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 更新日志 +## 1.2.4 + +- 修复回收空间时文件不存在异常 +- 修复章节标记时间异常导致转封装出错 + ## 1.2.3 - 修复直播间标题有特殊字符导致文件创建失败 diff --git a/src/blrec/__init__.py b/src/blrec/__init__.py index acab0d5..00b0ef1 100644 --- a/src/blrec/__init__.py +++ b/src/blrec/__init__.py @@ -1,4 +1,4 @@ __prog__ = 'blrec' -__version__ = '1.2.3' +__version__ = '1.2.4' __github__ = 'https://github.com/acgnhiki/blrec' diff --git a/src/blrec/core/stream_recorder.py b/src/blrec/core/stream_recorder.py index d1e9944..2ceccdd 100644 --- a/src/blrec/core/stream_recorder.py +++ b/src/blrec/core/stream_recorder.py @@ -331,6 +331,9 @@ class StreamRecorder( logger.debug('Response received') response.raise_for_status() + if self._stopped: + return + assert self._stream_processor is not None self._stream_processor.process_stream( io.BufferedReader( diff --git a/src/blrec/disk_space/space_reclaimer.py b/src/blrec/disk_space/space_reclaimer.py index 86a7a93..3d9239a 100644 --- a/src/blrec/disk_space/space_reclaimer.py +++ b/src/blrec/disk_space/space_reclaimer.py @@ -7,6 +7,12 @@ import asyncio from functools import partial from typing import Iterable, List +from tenacity import ( + retry, + wait_none, + stop_after_attempt, + retry_if_exception_type, +) from .helpers import delete_file, is_space_enough from .space_monitor import SpaceMonitor, DiskUsage, SpaceEventListener @@ -65,6 +71,11 @@ class SpaceReclaimer(SpaceEventListener, SwitchableMixin): return True return False + @retry( + retry=retry_if_exception_type(OSError), + wait=wait_none(), + stop=stop_after_attempt(3), + ) async def _get_record_file_paths(self, max_ctime: float) -> List[str]: glob_path = os.path.join(self.path, '*/**/*.*') paths: Iterable[Path] diff --git a/src/blrec/postprocess/ffmpeg_metadata.py b/src/blrec/postprocess/ffmpeg_metadata.py index 90e98c0..8b801f1 100644 --- a/src/blrec/postprocess/ffmpeg_metadata.py +++ b/src/blrec/postprocess/ffmpeg_metadata.py @@ -1,3 +1,4 @@ +import logging import json from typing import Iterable, cast @@ -8,6 +9,9 @@ from ..flv.stream_processor import JoinPoint from ..flv.helpers import make_comment_for_joinpoints +logger = logging.getLogger(__name__) + + async def make_metadata_file(flv_path: str) -> str: path = flv_path + '.meta' async with aiofiles.open(path, 'wb') as f: @@ -57,11 +61,16 @@ def _make_chapters( result = '' for i in range(1, len(timestamps)): + start = timestamps[i - 1] + end = timestamps[i] + if end < start: + logger.warning(f'Chapter end time {end} before start {start}') + end = start result += f"""\ [CHAPTER] TIMEBASE=1/1000 -START={timestamps[i-1]} -END={timestamps[i]} +START={start} +END={end} title=segment \\#{i} """ return result