mirror of https://github.com/mpv-player/mpv
ytdl_hook: use tbr for all tracks if vbr/abr not available
vbr and abr are the video and audio bitrates. Sometimes there is a weird mix of any of them available, but in these cases, it's not good to fall back to tbr if a specific track has no vbr/abr. For example, the alphabetic site provides tbr only for the muxed fallback stream, but using tbr would make the primitive mpv hls_bitrate selection pick the compatibility stream for audio, because it appears to have a higher bitrate than the other audio-only streams (because the bitrate includes video). So we must not use tbr in this case. On the other hand, formats coming from youtube-dl HLS master playlist use will only have tbr set. So as a heuristic, use the tbr only if it's the only bitrate available in any track entry.
This commit is contained in:
parent
6d09a042e6
commit
76aaf74d30
|
@ -344,6 +344,12 @@ local function formats_to_edl(json, formats, use_all_formats)
|
|||
local single_url = nil
|
||||
local streams = {}
|
||||
|
||||
local tbr_only = true
|
||||
for index, track in ipairs(formats) do
|
||||
tbr_only = tbr_only and track["tbr"] and
|
||||
(not track["abr"]) and (not track["vbr"])
|
||||
end
|
||||
|
||||
for index, track in ipairs(formats) do
|
||||
local edl_track = nil
|
||||
edl_track = edl_track_joined(track.fragments,
|
||||
|
@ -392,6 +398,9 @@ local function formats_to_edl(json, formats, use_all_formats)
|
|||
if #tracks > 1 then
|
||||
rates = {({video = "vbr", audio = "abr"})[sub.media_type]}
|
||||
end
|
||||
if tbr_only then
|
||||
rates = {"tbr"}
|
||||
end
|
||||
for _, f in ipairs(rates) do
|
||||
local br = as_integer(track[f])
|
||||
if br > 0 then
|
||||
|
|
Loading…
Reference in New Issue