SmallPeaches / DanmakuRender

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

【bug反馈】B站填写cdn无法获取到流 #301

Open laomu61996 opened 2 weeks ago

laomu61996 commented 2 weeks ago

使用版本:DanmakuRender v5 环境:linux+python3.11 网络环境:海外

在b站正常播放视频,发现是有d1--ov-gotcha207这个流的 ov-gotcha207 故在配置文件中填写为:

download_args:
  # 下载类型
  dltype: live
  # 直播间链接
  url: 'https://live.bilibili.com/13873215'
  # 录制输出文件夹,设置为空则使用主播名称作为文件夹
  output_dir: ./测试2
  # 录制文件名称格式,可使用关键字替换,默认效果:飞天狙想要努力变胖-2023年3月1日20点30分,注意这里不能含有冒号,斜杠等非法字符!!
  output_name: '{STREAMER.NAME}-{CTIME.YEAR}年{CTIME.MONTH:02d}月{CTIME.DAY:02d}日{CTIME.HOUR:02d}点{CTIME.MINUTE:02d}分'
  # 录播分段时间(秒),默认一个小时
  segment: 600
  # 录制程序引擎,可选ffmpeg, streamgears 或者 streamlink
  # 在使用streamgears作为录制引擎时,录制视频格式可能会根据直播流的不同而不同
  # 建议PC推流的直播使用ffmpeg录制,手机推流的直播使用streamgears录制
  # 录制twitch等特殊平台建议使用streamlink
  engine: streamlink
  # 是否录制弹幕
  danmaku: True
  # 是否录制直播流
  video: True
  # 延迟下播计时(分钟)
  # 使用这个功能可以把主播短暂下播又开播认定为同一场直播
  stop_wait_time: 3
  # 录制视频的格式,默认flv
  output_format: mp4
  stream_option:
    stream_cdn: d1--ov-gotcha207
    stream_type: hls
    bili_watch_cookies: .login_info/cookieskmg.json
  # 以下是弹幕录制参数
  # 弹幕录制格式,只能选择ass

运行时发生报错: image 完整日志文件: DMR-20240828.log

感谢大佬

laomu61996 commented 2 weeks ago

还有一个问题就是,斗鱼切换cdn貌似无法生效。目前斗鱼会拉黑大部分海外ip导致无法获取流(无限分小片段,提示403),当前可以使用的cdn有华为、阿里、腾讯、火山(已停止解析,但是仍然有流)(tx\hw 两个cdn会拉黑、ali不是所有主波都有流) 手动切换cdn后发现仍然使用同一个地址进行下载:wsa.douyu.cdn

RuntimeError: FFmpeg 退出.
[2024-08-27 20:10:14,635][danmaku][debug]: danmaku writer stoped.
[2024-08-27 20:10:14,635][ffmpeg][debug]: 测试4 ffmpeg: frame=    0 fps=0.0 q=-1.0 size=       0kB time=-00:00:00.01 bitrate=  -0.0kbits/s speed=N/A
[https @ 0x563e68a86680] Stream ends prematurely at 4115846, should be 18446744073709551615
Last message repeated 1 times
Error demuxing input file 0: Input/output error
https://wsa.douyucdn.cn/live/2448877rRbQ0NicQ.flv?wsAuth=f2a691666d73df8ce128ade000c97ab4&token=web-h5-0-2448877-260d903f5aac34e33c06fe89d2feed5bd6007ca8b4a678e3&logo=0&expire=0&did=10000000000000000000000000001501&pt=2&st=0&sid=398660475&mcid2=0&origin=tct&mix=0&isp=: Input/output error
frame=  130 fps=0.0 q=-1.0 Lsize=N/A time=00:00:02.13 bitrate=N/A speed=3.49x
video:3972kB audio:42kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

[2024-08-27 20:10:14,734][danmaku][debug]: Cancel the future.
[2024-08-27 20:10:15,636][danmaku][error]: 弹幕 ./测试3/[正在录制]测试4-20240827-201011-Part000.ass 分段失败: [Errno 2] No such file or directory: './测试3/[正在录制]测试4-20240827-201011-Part000.ass' -> './测试3/20岁天才歌手Running-2024年08月27日20点10分.ass'.
[2024-08-27 20:10:15,637][engine][debug]: {'source': 'downloader', 'target': 'replay/测试4', 'event': 'livesegment', 'request_id': None, 'msg': '视频分段 ./测试3/20岁天才歌手Running-2024年08月27日20点10分.mp4 录制完成.', 'dtype': 'VideoInfo', 'data': {'streamer': {'name': '20岁天才歌手Running', 'uid': None, 'platform': 'douyu', 'room_id': '2448877', 'url': 'https://www.douyu.com/2448877', 'face_url': 'https://apic.douyucdn.cn/upload/avatar_v3/202307/8eaa7643ac554a5eb0c3aceb398cfe99_big.jpg', 'cover_url': 'https://rpic.douyucdn.cn/asrpic/240827/2448877_2006.png/dy1'}, 'duration': 7.047347068786621, 'resolution': (1920, 1080), 'title': '赋能就在今天!', 'taskname': '测试4', 'dm_video_id': None, 'src_video_id': None, 'dm_file_id': './测试3/20岁天才歌手Running-2024年08月27日20点10分.ass', 'group_id': '4be352d4', 'segment_id': 0, 'file_id': '51ae43e0646d11ef8e0da036bca6da11', 'dtype': 'src_video', 'path': './测试3/20岁天才歌手Running-2024年08月27日20点10分.mp4', 'size': 4116261, 'ctime': datetime.datetime(2024, 8, 27, 20, 10, 8, 588961)}}
[2024-08-27 20:10:15,637][liveevents][info]: 测试4: 视频分段 ./测试3/20岁天才歌手Running-2024年08月27日20点10分.mp4 录制完成.
[2024-08-27 20:10:15,637][engine][debug]: {'source': 'replay/测试4', 'target': 'render', 'event': 'newtask', 'request_id': '51ae7b94646d11ef9233a036bca6da11', 'msg': '', 'dtype': None, 'data': {'taskname': '测试4', 'mode': 'dmrender', 'video': {'streamer': {'name': '20岁天才歌手Running', 'uid': None, 'platform': 'douyu', 'room_id': '2448877', 'url': 'https://www.douyu.com/2448877', 'face_url': 'https://apic.douyucdn.cn/upload/avatar_v3/202307/8eaa7643ac554a5eb0c3aceb398cfe99_big.jpg', 'cover_url': 'https://rpic.douyucdn.cn/asrpic/240827/2448877_2006.png/dy1'}, 'duration': 7.047347068786621, 'resolution': (1920, 1080), 'title': '赋能就在今天!', 'taskname': '测试4', 'dm_video_id': None, 'src_video_id': None, 'dm_file_id': './测试3/20岁天才歌手Running-2024年08月27日20点10分.ass', 'group_id': '4be352d4', 'segment_id': 0, 'file_id': '51ae43e0646d11ef8e0da036bca6da11', 'dtype': 'src_video', 'path': './测试3/20岁天才歌手Running-2024年08月27日20点10分.mp4', 'size': 4116261, 'ctime': datetime.datetime(2024, 8, 27, 20, 10, 8, 588961)}, 'output': './测试3(弹幕版)/20岁天才歌手Running-2024年08月27日20点10分(弹幕版).mp4', 'args': {'output_dir': None, 'output_name': None, 'format': 'mp4', 'hwaccel_args': None, 'vencoder': 'h264_qsv', 'vencoder_args': ['-profile:v', 'high', '-global_quality:v', 21, '-look_ahead', 0, '-g', 600, '-low_power', False, '-preset', 'medium', '-scenario', 'archive'], 'aencoder': 'aac', 'aencoder_args': ['-b:a', '320K'], 'output_resize': None, 'advanced_render_args': {'fps': None, 'filter_complex': "subtitles=filename='{DANMAKU}'"}}}}
[2024-08-27 20:10:15,648][ffmpeg][debug]: ffmpeg downloader stoped.
[2024-08-27 20:10:15,648][engine][debug]: {'source': 'downloader', 'target': 'replay/测试4', 'event': 'liveerror', 'request_id': None, 'msg': '录制过程出错:FFmpeg 退出.', 'dtype': 'Exception', 'data': RuntimeError('FFmpeg 退出.')}
[2024-08-27 20:10:15,649][liveevents][info]: 测试4: 录制过程出错:FFmpeg 退出.
[2024-08-27 20:10:16,791][engine][debug]: {'source': 'downloader', 'target': 'replay/测试4', 'event': 'livestart', 'request_id': None, 'msg': '直播开始', 'dtype': 'str', 'data': '4be352d4'}
[2024-08-27 20:10:16,792][liveevents][info]: 测试4: 直播开始
[2024-08-27 20:10:19,346][ffmpeg][debug]: FFmpegDownloader args:
[2024-08-27 20:10:19,347][ffmpeg][debug]: ['ffmpeg', '-y', '-headers', 'Content-Type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36 \r\n', '-rw_timeout', '10000000', '-analyzeduration', '15000000', '-probesize', '50000000', '-thread_queue_size', '16', '-i', 'https://wsa.douyucdn.cn/live/2448877rRbQ0NicQ.flv?wsAuth=b289b095e5ac0558ad64aa4cc5c37782&token=web-h5-0-2448877-260d903f5aac34e3284eacb588747a011e05a65bb7dc7ca0&logo=0&expire=0&did=10000000000000000000000000001501&pt=2&st=0&sid=398660475&mcid2=0&origin=tct&mix=0&isp=', '-c', 'copy', '-f', 'segment', '-segment_time', '600', '-reset_timestamps', '1', '-movflags', 'faststart+frag_keyframe+empty_moov', './测试3/[正在录制]测试4-20240827-201019-Part%03d.mp4']
[2024-08-27 20:10:20,349][ffmpeg][debug]: FFmpeg exit.
[2024-08-27 20:10:20,350][ffmpeg][debug]: 
[2024-08-27 20:10:21,325][stream_downloader][error]: FFmpeg 退出.
Click to reveal hidden text 目前biliup的解决方法是:https://biliup.me/d/158
haha252 commented 2 weeks ago

海外的话不能用国内的cdn来着,你试试用海外的机器播放一下直播看他用的哪个源呗

haha252 commented 2 weeks ago

另外提示一下,这个好像不是bug?

laomu61996 commented 2 weeks ago

你再仔细看看,那是国内的还是国外的


From: haha252 @.> Sent: Thursday, August 29, 2024 11:56:14 AM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301)

另外提示一下,这个好像不是bug?

― Reply to this email directly, view it on GitHubhttps://github.com/SmallPeaches/DanmakuRender/issues/301#issuecomment-2316664735, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34ERS6AD76SSBM75LJDZT2LV5AVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY3DINZTGU. You are receiving this because you authored the thread.Message ID: @.***>

laomu61996 commented 2 weeks ago

另外提示一下,这个好像不是bug?

另外提示一下,应该先去了解一下b站cdn的命名规则? https://rec.danmuji.org/dev/cdn-info/

haha252 commented 2 weeks ago

另外提示一下,这个好像不是bug?

另外提示一下,应该先去了解一下b站cdn的命名规则? https://rec.danmuji.org/dev/cdn-info/

唔,我看了一下好像这里面没有gotcha207嗷,用d1--ov-gotcha208.bilivideo.com试试?

haha252 commented 2 weeks ago

可能是有些节点就必须要用户登录吧,我也不是很懂

laomu61996 commented 2 weeks ago

网址最上面写有更新日期嘞宝宝,而且你看下issue第一个截图呢,另外就是208也是一样的呢


From: haha252 @.> Sent: Thursday, August 29, 2024 12:17:51 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301)

另外提示一下,这个好像不是bug?

另外提示一下,应该先去了解一下b站cdn的命名规则? https://rec.danmuji.org/dev/cdn-info/

唔,我看了一下好像这里面没有gotcha207嗷,用d1--ov-gotcha208.bilivideo.com试试?

― Reply to this email directly, view it on GitHubhttps://github.com/SmallPeaches/DanmakuRender/issues/301#issuecomment-2316682634, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34B4KUPJP3UL7FN5G4LZT2OG7AVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DENRTGQ. You are receiving this because you authored the thread.Message ID: @.***>

haha252 commented 2 weeks ago

网址最上面写有更新日期嘞宝宝,而且你看下issue第一个截图呢,另外就是208也是一样的呢 ____ From: haha252 @.> Sent: Thursday, August 29, 2024 12:17:51 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301) 另外提示一下,这个好像不是bug? 另外提示一下,应该先去了解一下b站cdn的命名规则? https://rec.danmuji.org/dev/cdn-info/ 唔,我看了一下好像这里面没有gotcha207嗷,用d1--ov-gotcha208.bilivideo.com试试? ― Reply to this email directly, view it on GitHub<#301 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34B4KUPJP3UL7FN5G4LZT2OG7AVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DENRTGQ. You are receiving this because you authored the thread.Message ID: @.***>

那我能力确实有限,看来是帮不上忙了

laomu61996 commented 2 weeks ago

看下issue中配置文件中写了登录cookies哦 日志中也写了已登录哦


From: haha252 @.> Sent: Thursday, August 29, 2024 12:20:19 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301)

可能是有些节点就必须要用户登录吧,我也不是很懂

― Reply to this email directly, view it on GitHubhttps://github.com/SmallPeaches/DanmakuRender/issues/301#issuecomment-2316684633, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34ET7MNQS5OOFVII34DZT2OQHAVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DINRTGM. You are receiving this because you authored the thread.Message ID: @.***>

haha252 commented 2 weeks ago

看下issue中配置文件中写了登录cookies哦 日志中也写了已登录哦 ____ From: haha252 @.> Sent: Thursday, August 29, 2024 12:20:19 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301) 可能是有些节点就必须要用户登录吧,我也不是很懂 ― Reply to this email directly, view it on GitHub<#301 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34ET7MNQS5OOFVII34DZT2OQHAVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DINRTGM. You are receiving this because you authored the thread.Message ID: @.***>

看到了,我帮不上忙咯qwq我机器是国内的,只是提出一两个可能的解决方案罢了

laomu61996 commented 2 weeks ago

还是谢谢你啦宝宝 QwQ


From: haha252 @.> Sent: Thursday, August 29, 2024 12:23:48 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301)

看下issue中配置文件中写了登录cookies哦 日志中也写了已登录哦 … ____ From: haha252 @.> Sent: Thursday, August 29, 2024 12:20:19 PM To: SmallPeaches/DanmakuRender @.> Cc: sora3 @.>; Author @.> Subject: Re: [SmallPeaches/DanmakuRender] 【bug反馈】B站填写cdn无法获取到流 (Issue #301https://github.com/SmallPeaches/DanmakuRender/issues/301) 可能是有些节点就必须要用户登录吧,我也不是很懂 D Reply to this email directly, view it on GitHub<#301 (comment)https://github.com/SmallPeaches/DanmakuRender/issues/301#issuecomment-2316684633>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34ET7MNQS5OOFVII34DZT2OQHAVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DINRTGM. You are receiving this because you authored the thread.Message ID: @.***>

看到了,我帮不上忙咯qwq我机器是国内的,只是提出一两个可能的解决方案罢了

― Reply to this email directly, view it on GitHubhttps://github.com/SmallPeaches/DanmakuRender/issues/301#issuecomment-2316687411, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKM34F2D2BFVGTKSFIMQVLZT2O5JAVCNFSM6AAAAABNHHFSM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGY4DONBRGE. You are receiving this because you authored the thread.Message ID: @.***>

SmallPeaches commented 1 week ago

第一个问题,你使用的是streamlink录制,streamlink是不用stream option的,直播间链接会直接传入streamlink然后由它生成流,你应该试试streamgears或者ffmpeg。 第二个问题,你可以参考它的先自行修改一下LiveAPI.douyu.get_stream_url,我网络环境是国内暂时没法修复。

laomu61996 commented 1 week ago

第一个问题,你使用的是streamlink录制,streamlink是不用stream option的,直播间链接会直接传入streamlink然后由它生成流,你应该试试streamgears或者ffmpeg。 第二个问题,你可以参考它的先自行修改一下LiveAPI.douyu.get_stream_url,我网络环境是国内暂时没法修复。

三个下载器都是如此

        "download_args": {
            "url": "https://live.bilibili.com/27351537",
            "engine": "ffmpeg",
            "output_dir": "./测试",
            "output_name": "{STREAMER.NAME}-{CTIME.YEAR}年{CTIME.MONTH:02d}月{CTIME.DAY:02d}日{CTIME.HOUR:02d}点{CTIME.MINUTE:02d}分",
            "segment": 600,
            "output_format": "mp4",
            "danmaku": true,
            "video": true,
            "stop_wait_time": 3,
            "stream_option": {
                "stream_cdn": "d1--ov-gotcha207",
                "stream_type": "hls",
                "bili_watch_cookies": ".login_info/cookieskmg.json"
[2024-09-01 09:44:45,504][engine][debug]: Task 测试 started.
[2024-09-01 09:44:45,504][engine][debug]: {'source': 'replay/测试', 'target': 'downloader', 'event': 'newtask', 'request_id': None, 'msg': '', 'dtype': None, 'data': {'dltype': 'live', 'taskname': '测试', 'config': {'url': 'https://live.bilibili.com/27351537', 'engine': 'ffmpeg', 'output_dir': './测试', 'output_name': '{STREAMER.NAME}-{CTIME.YEAR}年{CTIME.MONTH:02d}月{CTIME.DAY:02d}日{CTIME.HOUR:02d}点{CTIME.MINUTE:02d}分', 'segment': 600, 'output_format': 'mp4', 'danmaku': True, 'video': True, 'stop_wait_time': 3, 'stream_option': {'stream_cdn': 'd1--ov-gotcha207', 'stream_type': 'hls', 'bili_watch_cookies': '.login_info/cookieskmg.json'}, 'advanced_video_args': {'default_resolution': [1920, 1080], 'start_check_interval': 60, 'stop_check_interval': 30, 'ffmpeg_stream_args': ['-rw_timeout', '10000000', '-analyzeduration', '15000000', '-probesize', '50000000', '-thread_queue_size', '16'], 'ffmpeg_output_args': ['-movflags', 'faststart+frag_keyframe+empty_moov'], 'disable_lowspeed_interrupt': False, 'streamlink_extra_args': ['--twitch-disable-ads', '--twitch-disable-reruns']}, 'dm_format': 'ass', 'margin_h': 4, 'margin_w': 0.05, 'dmrate': 0.25, 'font': 'HarmonyOS Sans SC Bold', 'fontsize': 50, 'dst': 15, 'dmduration': 16, 'opacity': 0.8, 'auto_fontsize': True, 'outlinecolor': 0, 'outlinesize': 0.7, 'dm_stream_option': {'douyin_dm_cookies': None}, 'dm_filter': {'keywords': ['截图', '最强', '手柄', '零食', '抖音', '关注', '捂脸', '菜', '皇杂', 'RNG', 'fw'], 'username': None}, 'dm_template': {'danmaku': None}, 'advanced_dm_args': {'dm_delay_fixed': 6, 'dm_auto_restart': 300, 'dm_extra_inputs': []}, 'dltype': 'live'}}}
[2024-09-01 09:44:45,515][engine][info]: 下载任务 测试 已启动。
[2024-09-01 09:44:46,640][engine][debug]: {'source': 'downloader', 'target': 'replay/测试', 'event': 'livestart', 'request_id': None, 'msg': '直播开始', 'dtype': 'str', 'data': 'c40ceee8'}
[2024-09-01 09:44:46,640][liveevents][info]: 测试: 直播开始
[2024-09-01 09:44:47,092][bilibili][info]: 正在使用 .login_info/cookieskmg.json 的cookies登录B站.
[2024-09-01 09:44:47,558][bilibili][warning]: Bilibili27351537没有满足 d1--ov-gotcha207,hls 的流,将使用默认选项.
[2024-09-01 09:44:57,715][engine][debug]: {'source': 'engine', 'target': 'replay/测试', 'event': 'exit', 'request_id': None, 'msg': '', 'dtype': None, 'data': None}
[2024-09-01 09:44:57,716][engine][debug]: Task 测试 deleted.
[2024-09-01 09:44:57,716][__init__][info]: Downloader stoped.

QQ20240901-094858

SmallPeaches commented 5 days ago

你试下日志文件里面的链接,试着改cdn然后用curl请求试试,它能返回200吗?

laomu61996 commented 2 days ago

直接替换返回404,从网页抓包获取的hls流地址 可以正常播放和下载 (ps:正常播放cdn均使用d1--ov-gotcha207,网络环境相同) 207