Skip to content

直播:新接口适应性支持 - #189

Open
frostnotfall wants to merge 23 commits into
chen310:masterfrom
frostnotfall:master
Open

直播:新接口适应性支持#189
frostnotfall wants to merge 23 commits into
chen310:masterfrom
frostnotfall:master

Conversation

@frostnotfall

Copy link
Copy Markdown

直播 - 新接口适应性支持:

  1. 支持AVC, HEVC, AV1编码格式。
  2. 默认高帧率。
  3. 支持直播备份地址。
  4. 因为B站av1只在fmp4中提供,优先使用fmp4。小主播不提供fmp4,回退至ts。
    目前的小问题:
    画质选项中会出现HLS相关选项,貌似是potplayer特性。

…fmp4,回退至ts,支持直播备份地址,目前的小问题,画质选项中会出现HLS相关选项,貌似是potplayer特性。
Copilot AI lite review requested due to automatic review settings August 12, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 针对 Bilibili 直播播放解析切换到新版直播播放接口(getRoomPlayInfo),以适配更多编码/封装与备份地址输出,从而提升直播播放的兼容性与可选项。

Changes:

  • 新增直播画质映射(getLiveQuality),并在直播解析中基于新版 playurl_info 解析协议/封装/编码信息。
  • 直播流优先选择 fmp4,无 fmp4 时回退到 ts,并为主地址提供备份地址条目。
  • 直播画质列表按 codec(AVC/HEVC/AV1)分别生成对应 URL 与 itag。
Suppressed comments (1)

Media/PlayParse/MediaPlayParse - Bilibili.as:1791

  • 备份流的 itag 同样建议使用 getLiveItag(qn),保持与主流一致的排序/选择逻辑。
																						qualityItemBackup["itag"] = getItag(temp_codec["current_qn"].asInt()) * 100 + codecOffset * 10 + 1;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1602 to +1612
string getLiveQuality(int qn) {
if (qn == 30000) return "杜比";
if (qn == 20000) return "4K超高清";
if (qn == 15000) return "2K(原画)";
if (qn == 10000) return "1080p(原画)";
if (qn == 400) return "1080p(蓝光)";
if (qn == 250) return "720p(超清)";
if (qn == 150) return "480p(高清)";
if (qn == 80) return "360p(流畅)";
return "";
}
Comment on lines +1693 to +1701
string default_format_name = "";
for (int a = 0; a < formats.size(); a++) {
if (formats[a]["format_name"].asString() == "fmp4") {
default_format_name = "fmp4";
break;
} else if (formats[a]["format_name"].asString() == "ts") {
default_format_name = "ts";
}
JsonValue qyality_data = temp["data"]["durl"];
if (qyality_data.isArray()) {
qualityitem["url"] = qyality_data[0]["url"].asString();
if (qyality_data.size() > 1) {
qualityitem2["url"] = qyality_data[1]["url"].asString();
}
Comment on lines +1721 to +1729
int best_qn = 0;
for (int i = 0; i < accept_qnArray.size(); i++) {
int accept_qn = accept_qnArray[i];
if (best_qn < accept_qn) {
best_qn = accept_qn;
}
}

if (@QualityList !is null) {
Comment on lines +1730 to +1734
for (int i = 0; i < accept_qnArray.size(); i++) {
int accept_qn = accept_qnArray[i];
string quality_res = post("https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=" + room_id
+ "&qn=" + accept_qn + "&codec=0,1,2&format=0,1,2&mask=0&no_playurl=0&platform=web&protocol=0,1");
JsonValue temp;
Comment on lines +1735 to +1742
if (Reader.parse(quality_res, temp) && temp.isObject()) {
if (temp["code"].asInt() != 0) {
continue;
}
}
JsonValue temp_streams = temp["data"]["playurl_info"]["playurl"]["stream"];
for (int ts = 0; ts < temp_streams.size(); ts++) {
string temp_protocol_name = temp_streams[ts]["protocol_name"].asString();
Comment on lines +1777 to +1779
if ( best_qn == temp_codec["current_qn"].asInt() ) {
url = temp_codec["url_info"][0]["host"].asString() + temp_codec["base_url"].asString() + temp_codec["url_info"][0]["extra"].asString();
}
qualityItemMain["url"] = temp_codec["url_info"][0]["host"].asString() + temp_codec["base_url"].asString() + temp_codec["url_info"][0]["extra"].asString();
qualityItemMain["quality"] = getLiveQuality(temp_codec["current_qn"].asInt()) + codec_suffix;
qualityItemMain["qualityDetail"] = qualityItemMain["quality"];
qualityItemMain["itag"] = getItag(temp_codec["current_qn"].asInt()) * 100 + codecOffset * 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants