关于视频码率问题
Darcrandex opened this issue · comments
darcrand commented
大佬你好,感谢你的项目。目前下载视频遇到一点问题,希望可以解决一下。
问题描述:
单个视频情况下,选择指定视频清晰度后,下载下来的视频的码率不正确。
我查看了源码,其中获取视频下载地址的方法似乎不会获取最大码率的一项,如下:
videoUrl
dash.video.find((item: any) => item.id === quality) ? dash.video.find((item: any) => item.id === quality).baseUrl : dash.video[0].baseUrl
以下方数据为例
const videoInfo = {
video_codecid: 7,
data: {
bash: {
video: [
{
id: 120,
bandwidth: 3070633,
mimeType: "video/mp4",
mime_type: "video/mp4",
codecs: "hev1.1.6.L153.90",
width: 2160,
height: 3840,
frameRate: "62.500",
frame_rate: "62.500",
sar: "1:1",
startWithSap: 1,
start_with_sap: 1,
SegmentBase: { Initialization: "0-1157", indexRange: "1158-1405" },
segment_base: { initialization: "0-1157", index_range: "1158-1405" },
codecid: 12,
},
{
id: 120,
bandwidth: 11128732,
mimeType: "video/mp4",
mime_type: "video/mp4",
codecs: "avc1.640034",
width: 2160,
height: 3840,
frameRate: "62.500",
frame_rate: "62.500",
sar: "1:1",
startWithSap: 1,
start_with_sap: 1,
SegmentBase: { Initialization: "0-994", indexRange: "995-1242" },
segment_base: { initialization: "0-994", index_range: "995-1242" },
codecid: 7,
},
{
id: 120,
bandwidth: 2224746,
mimeType: "video/mp4",
mime_type: "video/mp4",
codecs: "av01.0.13M.08.0.110.01.01.01.0",
width: 2160,
height: 3840,
frameRate: "60.150",
frame_rate: "60.150",
sar: "1:1",
startWithSap: 1,
start_with_sap: 1,
SegmentBase: { Initialization: "0-1023", indexRange: "1052-1299" },
segment_base: { initialization: "0-1023", index_range: "1052-1299" },
codecid: 13,
},
],
},
},
};
按照代码的功能,会获取列表中第一个视频,但是第一个视频的码率是最低的,应该是 codecid:7
的那一项才是正确的。
所以应该是 dash.video.find((item: any) => item.id === quality && item.codecid === cid)
。
希望大佬抽时间修复一个这个 bug,再次感谢。
zqhong commented