SmallPeaches / DanmakuRender

一个可以录制带弹幕直播流的小工具
361 stars 39 forks source link

录制虎牙时报错 AttributeError: 'NoneType' object has no attribute 'startswith' #211

Closed laomu61996 closed 5 months ago

laomu61996 commented 7 months ago

windows平台,使用V4版本(python3.9),使用ffmpeg或streamgears下载器均报错。录制虎牙平台,房间号为www.huya.com/127395 ,录制过程中发现仅此直播间会报错 报错如下

即将添加以下配置文件:['configs/replay-伊芙挽.yml']
[2024-04-15 21:38:24,338][INFO]: 添加直播:https://www.huya.com/127395
[2024-04-15 21:38:27,292][INFO]: 伊芙挽 录制开始.
[2024-04-15 21:38:34,674][ERROR]: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 215, in start_helper
    self.start_once()
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 121, in start_once
    width, height = FFprobe.get_resolution(stream_url,stream_request_header)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/DanmakuRender/DMR/utils.py", line 115, in get_resolution
    if url.startswith('http'):
       ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'
[2024-04-15 21:38:34,675][ERROR]: 录制 伊芙挽 遇到错误,即将重试.
SmallPeaches commented 7 months ago

应该是这个直播间获取的直播流有问题,你看看日志文件这个时间点具体报错信息是什么?

laomu61996 commented 7 months ago

log里面也是循环这些

[2024-04-15 21:38:24,337][main][DEBUG]: DEBUG VERSION: 2024.1.30
[2024-04-15 21:38:24,337][main][DEBUG]: args: Namespace(config='replay.yml', default_config='configs/default.yml', debug=False, version=False, skip_update=False)
[2024-04-15 21:38:24,337][main][DEBUG]: Full config: {
    "伊芙挽": {
        "output_dir": "./伊芙挽",
        "output_name": "{STREAMER}-{HOUR}点{MINUTE}分直播回放",
        "engine": "streamgears",
        "segment": 3600,
        "danmaku": true,
        "video": true,
        "auto_render": true,
        "end_cnt": 15,
        "resolution": [
            1920,
            1080
        ],
        "vid_format": "flv",
        "flow_cdn": "hs",
        "ffmpeg_stream_args": [
            "-fflags",
            "+discardcorrupt",
            "-reconnect",
            "1",
            "-rw_timeout",
            "10000000",
            "-analyzeduration",
            "15000000",
            "-probesize",
            "50000000",
            "-thread_queue_size",
            "16"
        ],
        "disable_lowspeed_interrupt": false,
        "check_stream_changes": false,
        "dm_format": "ass",
        "margin_h": 4,
        "margin_w": 0.05,
        "dmrate": 0.2,
        "font": "HarmonyOS Sans SC Bold",
        "fontsize": 36,
        "dst": 15,
        "dmduration": 16,
        "opacity": 0.7,
        "auto_fontsize": true,
        "outlinecolor": 0,
        "outlinesize": 0.7,
        "dm_delay_fixed": 2.0,
        "dm_auto_restart": 20,
        "dm_filter": [
            "截图",
            "最强",
            "手柄",
            "零食",
            "抖音",
            "关注",
            "捂脸"
        ],
        "advanced_video_args": null,
        "advanced_dm_args": null,
        "url": "https://www.huya.com/127395",
        "render": {
            "output_dir": null,
            "format": "mp4",
            "engine": "ffmpeg",
            "nrenders": 2,
            "hwaccel_args": null,
            "vencoder": "libx264",
            "vencoder_args": [
                "-b:v",
                "15M"
            ],
            "aencoder": "aac",
            "aencoder_args": [
                "-b:a",
                "320K"
            ],
            "output_resize": null,
            "advanced_render_args": null,
            "nproc": 2,
            "bufsize": 100,
            "danmaku_resort": false
        }
    }
}
[2024-04-15 21:38:24,338][__init__][INFO]: 添加直播:https://www.huya.com/127395
[2024-04-15 21:38:24,348][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:25,211][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:25,213][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:27,290][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:27,292][__init__][DEBUG]: PIPE MESSAGE: {'src': 'downloader', 'msg': 'start', 'type': 'info', 'group': '伊芙挽'}
[2024-04-15 21:38:27,292][__init__][INFO]: 伊芙挽 录制开始.
[2024-04-15 21:38:27,293][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:28,290][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:28,292][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:30,101][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:30,104][connectionpool][DEBUG]: Starting new HTTP connection (1): al.flv.huya.com:80
[2024-04-15 21:38:33,125][__init__][DEBUG]: HTTPConnectionPool(host='al.flv.huya.com', port=80): Read timed out. (read timeout=3)
[2024-04-15 21:38:33,126][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:34,672][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:34,674][__init__][ERROR]: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 215, in start_helper
    self.start_once()
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 121, in start_once
    width, height = FFprobe.get_resolution(stream_url,stream_request_header)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/DanmakuRender/DMR/utils.py", line 115, in get_resolution
    if url.startswith('http'):
       ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'
[2024-04-15 21:38:34,675][__init__][DEBUG]: PIPE MESSAGE: {'src': 'downloader', 'msg': 'restart', 'type': 'error', 'group': '伊芙挽', 'desc': AttributeError("'NoneType' object has no attribute 'startswith'")}
[2024-04-15 21:38:34,675][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:34,675][__init__][ERROR]: 录制 伊芙挽 遇到错误,即将重试.
[2024-04-15 21:38:34,675][__init__][ERROR]: 'NoneType' object has no attribute 'startswith'
[2024-04-15 21:38:35,974][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:35,976][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:35,976][__init__][DEBUG]: PIPE MESSAGE: {'src': 'downloader', 'msg': 'start', 'type': 'info', 'group': '伊芙挽'}
[2024-04-15 21:38:35,976][__init__][INFO]: 伊芙挽 录制开始.
[2024-04-15 21:38:38,260][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:38,262][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:39,128][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:39,130][connectionpool][DEBUG]: Starting new HTTP connection (1): al.flv.huya.com:80
[2024-04-15 21:38:42,149][__init__][DEBUG]: HTTPConnectionPool(host='al.flv.huya.com', port=80): Read timed out. (read timeout=3)
[2024-04-15 21:38:42,150][connectionpool][DEBUG]: Starting new HTTPS connection (1): mp.huya.com:443
[2024-04-15 21:38:43,264][connectionpool][DEBUG]: https://mp.huya.com:443 "GET /cache.php?m=Live&do=profileRoom&roomid=127395 HTTP/1.1" 200 None
[2024-04-15 21:38:43,266][__init__][ERROR]: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 215, in start_helper
    self.start_once()
  File "/root/DanmakuRender/DMR/Downloader/__init__.py", line 121, in start_once
    width, height = FFprobe.get_resolution(stream_url,stream_request_header)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/DanmakuRender/DMR/utils.py", line 115, in get_resolution
    if url.startswith('http'):
       ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'
[2024-04-15 21:38:43,266][__init__][DEBUG]: PIPE MESSAGE: {'src': 'downloader', 'msg': 'restart', 'type': 'error', 'group': '伊芙挽', 'desc': AttributeError("'NoneType' object has no attribute 'startswith'")}
[2024-04-15 21:38:43,266][__init__][ERROR]: 录制 伊芙挽 遇到错误,即将重试.
[2024-04-15 21:38:43,266][__init__][ERROR]: 'NoneType' object has no attribute 'startswith'
[2024-04-15 21:38:48,850][__init__][DEBUG]: 'NoneType' object has no attribute 'stop'
[2024-04-15 21:38:48,850][__init__][DEBUG]: render exit.
[2024-04-15 21:38:48,850][__init__][DEBUG]: uploader exit.
[2024-04-15 21:38:48,850][__init__][DEBUG]: Cleaner exit.
[2024-04-15 21:38:48,850][__init__][DEBUG]: DMR engine stop.
SmallPeaches commented 7 months ago

你试下换个cdn看看?把cdn改成tx试试。

laomu61996 commented 7 months ago

换过啦 这个房间只有al和hs的流 换了之后还是这样

SmallPeaches commented 7 months ago

那我有空研究一下

laomu61996 commented 7 months ago

感谢大佬