mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +00:00
ytdl_hook.lua: delay load subtitles
Uses the infrastructure added in the previous commits. This is admittedly a bit weird (constructing EDL URLs and such). But on the other hand, adding this as "first class" mechanism directly to the sub-add command or so would increase weirdness and unexpected behavior in other places, or at least that's what I think. To reduce confusion, this goes through the effort of mapping the webvtt codec, so it's shown "properly" in the codec list. Without this it would show "null", but still work. In particular, any non-webvtt codecs should still work if libavcodec supports it. Not sure if I should remove the --all-subs hack from the code. But I guess it does no harm.
This commit is contained in:
parent
e54ebaec52
commit
29e15e6248
@ -29,6 +29,11 @@ local safe_protos = Set {
|
||||
"data"
|
||||
}
|
||||
|
||||
-- Codec name as reported by youtube-dl mapped to mpv internal codec names.
|
||||
local map_codec_to_mpv = {
|
||||
["vtt"] = "webvtt",
|
||||
}
|
||||
|
||||
local function exec(args)
|
||||
local ret = mp.command_native({name = "subprocess",
|
||||
args = args,
|
||||
@ -386,8 +391,13 @@ local function add_single_video(json)
|
||||
end
|
||||
|
||||
if not (sub == nil) then
|
||||
mp.commandv("sub-add", sub,
|
||||
"auto", sub_info.ext, lang)
|
||||
local edl = "edl://!no_clip;!delay_open,media_type=sub"
|
||||
local codec = map_codec_to_mpv[sub_info.ext]
|
||||
if codec then
|
||||
edl = edl .. ",codec=" .. codec
|
||||
end
|
||||
edl = edl .. ";" .. edl_escape(sub)
|
||||
mp.commandv("sub-add", edl, "auto", sub_info.ext, lang)
|
||||
else
|
||||
msg.verbose("No subtitle data/url for ["..lang.."]")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user