Skip to content

Commit

Permalink
添加ffmpeg封装需录制成功的判定条件
Browse files Browse the repository at this point in the history
  • Loading branch information
auqhjjqdo committed Jul 21, 2023
1 parent 73665d6 commit 8e5b674
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def run_record(self, stream: Union[StreamIO, HTTPStream], url, title, format):
if stream:
logger.info(f'{self.flag}开始录制:{filename}')
# 调用streamlink录制直播
self.stream_writer(stream, url, filename)
# format配置存在且不等于直播平台默认格式时运行ffmpeg封装
if self.format and self.format != format:
result = self.stream_writer(stream, url, filename)
# 录制成功、format配置存在且不等于直播平台默认格式时运行ffmpeg封装
if result and self.format and self.format != format:
self.run_ffmpeg(filename, format)
recording.pop(url, None)
logger.info(f'{self.flag}停止录制:{filename}')
Expand All @@ -148,6 +148,7 @@ def stream_writer(self, stream, url, filename):
recording[url] = (stream_fd, output)
logger.info(f'{self.flag}正在录制:{filename}')
StreamRunner(stream_fd, output, show_progress=True).run(prebuffer)
return True
except OSError as error:
if 'timeout' in str(error):
logger.warning(f'{self.flag}直播录制超时,主播可能已下播:{filename}\n{error}')
Expand Down

0 comments on commit 8e5b674

Please sign in to comment.