summaryrefslogtreecommitdiffstats
path: root/player/lua/ytdl_hook.lua
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-20 12:22:47 +0100
committerwm4 <wm4@nowhere>2020-02-20 12:25:45 +0100
commitf5c1d71639ee3a462028bd07481b147c07206d99 (patch)
tree1cb37a3fe385b89555ff6b5e1562453ad42a00ff /player/lua/ytdl_hook.lua
parenteaa10a25c70d43a124e152210b46aeb234f22d92 (diff)
downloadmpv-f5c1d71639ee3a462028bd07481b147c07206d99.tar.bz2
mpv-f5c1d71639ee3a462028bd07481b147c07206d99.tar.xz
ytdl_hook: try to skip interleaved streams with all_formats
If a "format" has both audio and video codec set, it might contain both audio and video. all_format assumes that each format is just a quality variant containing a single track. This seems to happen with sites that provide a HLS master URL. youtube-dl tends to "butcher" it, and the result isn't very ideal. I guess HLS "renditions" simply don't map well to youtube-dl's output format and what mpv expects. Playing master HLS directly is also less than ideal, because of libavformat's stupid probing. Fix this by not using the delay-opening mechanism if it appears like we detected such a case. Add a metadata override to set the track titles to "muxed-N", to indicate that they form a single unit. (Mostly helpful for testing.)
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r--player/lua/ytdl_hook.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index 3d89d034f5..3332f3658a 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -374,10 +374,17 @@ local function add_single_video(json)
end
local media_type = nil
local codec = nil
+ local interlaved_streams = false
if track.vcodec and track.vcodec ~= "none" then
media_type = "video"
codec = track.vcodec
- elseif track.vcodec == "none" then
+ end
+ -- Tries to follow the strange logic that vcodec unset means it's
+ -- an audio stream, even if acodec is (supposedly) sometimes unset.
+ if (not codec) or (track.acodec and track.acodec ~= "none") then
+ if codec then
+ interlaved_streams = true
+ end
media_type = "audio"
codec = track.acodec
end
@@ -386,7 +393,7 @@ local function add_single_video(json)
end
local url = edl_track or track.url
local hdr = {"!new_stream", "!no_clip", "!no_chapters"}
- if use_all_formats then
+ if use_all_formats and not interlaved_streams then
local codec = map_codec_to_mpv(codec)
hdr[#hdr + 1] = "!delay_open,media_type=" .. media_type ..
",codec=" .. (codec or "null") .. ",w=" ..
@@ -399,6 +406,8 @@ local function add_single_video(json)
hdr[#hdr + 1] = "!track_meta,title=" ..
edl_escape(track.format_note or "") ..
",byterate=" .. byterate
+ elseif interlaved_streams then
+ hdr[#hdr + 1] = "!track_meta,title=muxed-" .. index
end
hdr[#hdr + 1] = edl_escape(url)
streams[#streams + 1] = table.concat(hdr, ";")