auqhjjqdo / LiveRecorder

基于Streamlink的全自动直播录制工具,已支持哔哩哔哩、斗鱼、虎牙、抖音、YouTube、Twitch等
MIT License
539 stars 58 forks source link

[Bug]: 录制抖音直播时有报错 #30

Closed zhangmx999 closed 1 year ago

zhangmx999 commented 1 year ago

运行环境

版本号:v2.18 运行平台:win10 运行架构: Python版本:

配置文件

{
            "platform": "Douyin",
            "id": "91551668001",
            "name": "我罗慈悲",
            "output": "output/我罗慈悲",
            "interval": 10
        },

复现步骤(可选)

1.正常运行一段时间后,会报错,也许与主播关播有关 2. 3. ...

错误描述

可能主播关播以后,程序会出现异常

错误日志

[2023-07-19 00:28:05][ERROR][main][stream_writer:156][Douyin][我罗慈悲]直播录制未知错误 Could not open stream: Unable to open URL: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d (404 Client Error: Not Found for url: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d) Traceback (most recent call last):

File "streamlink\plugin\api\http_session.py", line 175, in request

File "requests\models.py", line 1021, in raise_for_status

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "streamlink_cli\main.py", line 305, in open_stream

File "streamlink\stream\http.py", line 62, in open

File "streamlink\plugin\api\http_session.py", line 183, in request

streamlink.exceptions.StreamError: Unable to open URL: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d (404 Client Error: Not Found for url: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "threading.py", line 973, in _bootstrap

File "threading.py", line 1016, in _bootstrap_inner

File "threading.py", line 953, in run

File "concurrent\futures\thread.py", line 83, in _worker

File "concurrent\futures\thread.py", line 58, in run

File "main.py", line 133, in run_record

File "main.py", line 146, in stream_writer

File "streamlink_cli\main.py", line 307, in open_stream

streamlink.exceptions.StreamError: Could not open stream: Unable to open URL: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d (404 Client Error: Not Found for url: http://pull-flv-l11.douyincdn.com/stage/stream-689853974488547473_or4.flv?expire=1690302431&sign=ab8197664b707ce425f26025b739c65d)

错误截图(可选)

屏幕截图 2023-07-19 014107 屏幕截图 2023-07-19 014038

auqhjjqdo commented 1 year ago

出现此报错后是否会重新录制?或者是只有关播之后才会出现? 如果会重新录制则说明抖音的直播流地址会出现更换的现象,需要寻找直播流地址更换的触发机制 如果是关播才出现则是正常现象,关播后直播流会中断,只能通过报错来停止录播

zhangmx999 commented 1 year ago

程序对主播关播的行为,应该进行提示吧,而不能抛出异常吧,能改就改吧,反正凑合能用

auqhjjqdo commented 1 year ago

程序对主播关播的行为,应该进行提示吧,而不能抛出异常吧,能改就改吧,反正凑合能用

录制过程是由streamlink接管的,正常情况应该是如下图所示 image streamlink在关播后的判定方式是通过直播流地址超时抛出异常然后退出录制,此时才会回到程序进行后续操作 由于streamlink官方并不支持抖音直播,只能由程序先提取出直播流地址再由streamlink录制,而抖音关播后直播流地址找不到,streamlink就直接报错Could not open stream: Unable to open URL,如果直接捕获该异常然后提示主播已下播,在真正遇到直播流找不到的情况下就会出现错误判定,所以这个判定是不好改的,需要有大量下播的测试环境,目前暂时只能搁置该问题

zhangmx999 commented 1 year ago

好的

auqhjjqdo commented 1 year ago

我特意看了下streamlink的源码,Could not open stream的报错是来自于开始录制时无法打开直播流,并非录制结束后的报错,如果你在下次遇到该报错时,先留意一下主播的直播是否是黑屏缓冲之类的状态,是否在多次报错后正常录制,感谢提交bug

zhangmx999 commented 1 year ago

谢谢啦