diff options
author | wm4 <wm4@nowhere> | 2020-02-21 11:57:21 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-02-21 11:57:21 +0100 |
commit | 76aaf74d30039df10e114c4e771bc9e3ddc779d5 (patch) | |
tree | 57942246ea9e6696f2168129762ace6701f08eb7 /player/lua/ytdl_hook.lua | |
parent | 6d09a042e6c2d47a369c7761d9e82d56ebe42140 (diff) | |
download | mpv-76aaf74d30039df10e114c4e771bc9e3ddc779d5.tar.bz2 mpv-76aaf74d30039df10e114c4e771bc9e3ddc779d5.tar.xz |
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.
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 7269f3f4b7..67eac3f4ae 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -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 |