⚠️ 确认是否已存在类似问题
🔧 运行方式
直接运行预构建的程序
🐍 如果是使用源代码运行,请选择你的Python环境版本
None
💻 请选择你的系统环境
Windows 11
⚠️ 确认是否已经重试多次
🕹 复现步骤
1、添加虎牙直播间:https://www.huya.com/<ROOM_ID_REDACTED>。
2、使用预构建版 StreamCap v1.0.3,在 Windows 11 上运行。
3、当前相关配置如下:
video_format = TS
record_quality = OD
default_live_source = FLV
force_https_recording = true
flv_use_direct_download = false
platform_max_concurrent_requests = 3
loop_time_seconds = 180
check_live_on_browser_refresh = true
4、启动虎牙直播间监控并等待其开播。
5、观察监控状态和录制状态。
6、本轮按当前配置在 2026-05-26 21:12 重新启动程序短测:由于当前配置中虎牙条目的 monitor_status=false,本轮没有触发新的虎牙检测;程序只按配置检测了非虎牙条目。这说明严格使用当前配置时无法重新触发虎牙录制,但同一套关键录制设置在前一次虎牙监控开启时已经复现了下面的问题。
😯 问题描述
虎牙直播录制容易出现两类异常:
1、开启 FLV 直连下载时,虎牙 FLV 地址会返回 302,导致监控短暂显示“录制中”后很快变回“未开播”或录制失败。
2、关闭 FLV 直连下载后,监控状态能恢复正常并开始录制,但录制仍容易在很短时间内中断或显示“录制错误”。日志中可见:
video_format=TS 时,虎牙仍然优先使用tx.flv.huya.com/...flv作为 record_url;
force_https_recording=true 时,日志里仍出现http://tx.flv.huya.com/...和 http://tx.hls.huya.com/...;
FFmpeg 有时十几秒后退出并报 [tls] Error in the pull function;
有时 FFmpeg 以 code=0 退出,但实际直播仍在继续,随后又被重新拉起,导致录制被切成很多很短的文件。
期望行为:
关闭 flv_use_direct_download 后,虎牙不应再走直连下载器。
当 record_format/video_format 为 TS 或 FLV 拉流失败时,建议优先使用虎牙返回的 HLS/m3u8 地址,或在 FLV 失败后自动 fallback 到 HLS。
force_https_recording=true 时,实际交给 FFmpeg 的 record_url、m3u8_url、flv_url 应统一转换为 https://。
当 FFmpeg 在直播仍为 is_live=True 的情况下短时间退出,即使退出码是 0,也建议判断为异常中断并自动重试/刷新播放地址,而不是直接认为录制完成。
📜 错误信息
以下日志已脱敏:房间号、主播名、标题、保存路径、stream id、wsSecret、wsTime、fm 等鉴权参数均已替换。
1. 开启 FLV 直连下载时,虎牙 FLV 请求返回 302
2026-05-25 22:39:54 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', live_url='https://www.huya.com/<ROOM_ID_REDACTED>') 2026-05-25 22:39:54 | Use Direct Downloader to Download FLV Stream: https://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&... 2026-05-25 22:39:55 | Direct Downloading: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:39:55 | ERROR | Request Stream Failed, Status Code: 302
2. 关闭 FLV 直连下载后仍使用 FLV record_url,并短时间退出
2026-05-25 22:51:56 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', live_url='https://www.huya.com/<ROOM_ID_REDACTED>') 2026-05-25 22:51:57 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:24 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:27 | StreamData(platform='虎牙直播', is_live=True, record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 22:52:27 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:55 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED>
3. FFmpeg TLS 拉流错误
2026-05-25 22:54:04 | StreamData(platform='虎牙直播', is_live=True, record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 22:54:04 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:54:18 | Exit loop recording (normal 0 | abnormal 1): code=3753488571, https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:54:18 | ERROR | FFmpeg Stderr Output: [tls @ <ADDR_REDACTED>] Error in the pull function.
4. TS 输出时仍使用虎牙 FLV 源
2026-05-25 23:12:58 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 23:12:58 | Save Path: <SAVE_PATH_REDACTED>/<FILE_NAME_REDACTED>.ts 2026-05-25 23:12:58 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 23:16:42 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED>
修改建议
1、虎牙平台在 record_format=TS 或 video_format=TS 时优先选择 m3u8_url,不要默认继续使用flv_url作为 record_url。
2、对虎牙 FLV 录制增加失败 fallback:遇到 302、TLS 拉流错误、短时间退出时,重新获取播放地址并切换到 HLS/m3u8。
3、force_https_recording=true 时,在生成 StreamData 或启动 FFmpeg 前统一规范化 m3u8_url/flv_url/record_url。
4、FFmpeg 退出码为 0 但录制时长明显过短、且直播状态仍是is_live=True时,不应直接标记为“录制完成”,建议标记为“源中断/需重试”并自动重试。
🔧 运行方式
直接运行预构建的程序
🐍 如果是使用源代码运行,请选择你的Python环境版本
None
💻 请选择你的系统环境
Windows 11
🕹 复现步骤
1、添加虎牙直播间:
https://www.huya.com/<ROOM_ID_REDACTED>。2、使用预构建版 StreamCap v1.0.3,在 Windows 11 上运行。
3、当前相关配置如下:
video_format= TSrecord_quality= ODdefault_live_source= FLVforce_https_recording= trueflv_use_direct_download= falseplatform_max_concurrent_requests= 3loop_time_seconds= 180check_live_on_browser_refresh= true4、启动虎牙直播间监控并等待其开播。
5、观察监控状态和录制状态。
6、本轮按当前配置在 2026-05-26 21:12 重新启动程序短测:由于当前配置中虎牙条目的
monitor_status=false,本轮没有触发新的虎牙检测;程序只按配置检测了非虎牙条目。这说明严格使用当前配置时无法重新触发虎牙录制,但同一套关键录制设置在前一次虎牙监控开启时已经复现了下面的问题。😯 问题描述
虎牙直播录制容易出现两类异常:
1、开启 FLV 直连下载时,虎牙 FLV 地址会返回 302,导致监控短暂显示“录制中”后很快变回“未开播”或录制失败。
2、关闭 FLV 直连下载后,监控状态能恢复正常并开始录制,但录制仍容易在很短时间内中断或显示“录制错误”。日志中可见:
video_format=TS 时,虎牙仍然优先使用
tx.flv.huya.com/...flv作为record_url;force_https_recording=true时,日志里仍出现http://tx.flv.huya.com/...和http://tx.hls.huya.com/...;FFmpeg 有时十几秒后退出并报
[tls] Error in the pull function;有时 FFmpeg 以 code=0 退出,但实际直播仍在继续,随后又被重新拉起,导致录制被切成很多很短的文件。
期望行为:
关闭
flv_use_direct_download后,虎牙不应再走直连下载器。当
record_format/video_format为 TS 或 FLV 拉流失败时,建议优先使用虎牙返回的HLS/m3u8地址,或在 FLV 失败后自动 fallback 到 HLS。force_https_recording=true时,实际交给 FFmpeg 的record_url、m3u8_url、flv_url应统一转换为 https://。当 FFmpeg 在直播仍为
is_live=True的情况下短时间退出,即使退出码是 0,也建议判断为异常中断并自动重试/刷新播放地址,而不是直接认为录制完成。📜 错误信息
以下日志已脱敏:房间号、主播名、标题、保存路径、stream id、wsSecret、wsTime、fm 等鉴权参数均已替换。
1. 开启 FLV 直连下载时,虎牙 FLV 请求返回 302
2026-05-25 22:39:54 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', live_url='https://www.huya.com/<ROOM_ID_REDACTED>') 2026-05-25 22:39:54 | Use Direct Downloader to Download FLV Stream: https://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&... 2026-05-25 22:39:55 | Direct Downloading: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:39:55 | ERROR | Request Stream Failed, Status Code: 3022. 关闭 FLV 直连下载后仍使用 FLV record_url,并短时间退出
2026-05-25 22:51:56 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', live_url='https://www.huya.com/<ROOM_ID_REDACTED>') 2026-05-25 22:51:57 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:24 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:27 | StreamData(platform='虎牙直播', is_live=True, record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 22:52:27 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:52:55 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED>3. FFmpeg TLS 拉流错误
2026-05-25 22:54:04 | StreamData(platform='虎牙直播', is_live=True, record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 22:54:04 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:54:18 | Exit loop recording (normal 0 | abnormal 1): code=3753488571, https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 22:54:18 | ERROR | FFmpeg Stderr Output: [tls @ <ADDR_REDACTED>] Error in the pull function.4. TS 输出时仍使用虎牙 FLV 源
2026-05-25 23:12:58 | StreamData(platform='虎牙直播', is_live=True, m3u8_url='http://tx.hls.huya.com/src/<STREAM_ID_REDACTED>.m3u8?wsSecret=<REDACTED>&...', flv_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...', record_url='http://tx.flv.huya.com/src/<STREAM_ID_REDACTED>.flv?wsSecret=<REDACTED>&...') 2026-05-25 23:12:58 | Save Path: <SAVE_PATH_REDACTED>/<FILE_NAME_REDACTED>.ts 2026-05-25 23:12:58 | Recording in Progress: https://www.huya.com/<ROOM_ID_REDACTED> 2026-05-25 23:16:42 | Exit loop recording (normal 0 | abnormal 1): code=0, https://www.huya.com/<ROOM_ID_REDACTED>修改建议
1、虎牙平台在
record_format=TS或video_format=TS时优先选择m3u8_url,不要默认继续使用flv_url作为record_url。2、对虎牙 FLV 录制增加失败 fallback:遇到 302、TLS 拉流错误、短时间退出时,重新获取播放地址并切换到
HLS/m3u8。3、
force_https_recording=true时,在生成 StreamData 或启动 FFmpeg 前统一规范化m3u8_url/flv_url/record_url。4、FFmpeg 退出码为 0 但录制时长明显过短、且直播状态仍是
is_live=True时,不应直接标记为“录制完成”,建议标记为“源中断/需重试”并自动重试。