Skip to content

Commit c6e4b4f

Browse files
committed
ytdl_hook: accept srv3 subtitle format if subrandr is present
This allows YouTube videos played directly from a URL to make use of subrandr's SRV3 support.
1 parent 474516f commit c6e4b4f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

player/lua/ytdl_hook.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ local codec_map = {
8787
["mp4a%..*"] = "aac",
8888
}
8989

90+
local has_subrandr = mp.get_property_native("subrandr-version") ~= nil
91+
92+
if has_subrandr then
93+
codec_map["srv3"] = "textsub/srv3"
94+
end
95+
9096
-- Codec name as reported by youtube-dl mapped to mpv internal codec names.
9197
-- Fun fact: mpv will not really use the codec, but will still try to initialize
9298
-- the codec on track selection (just to scrap it), meaning it's only a hint,
@@ -924,10 +930,15 @@ local function run_ytdl_hook(url)
924930
local allsubs = true
925931
local proxy = nil
926932
local use_playlist = false
933+
local wanted_sub_formats = "ass/srt/best"
934+
935+
if has_subrandr then
936+
wanted_sub_formats = "srv3/" .. wanted_sub_formats
937+
end
927938

928939
local command = {
929940
ytdl.path, "--no-warnings", "-J", "--flat-playlist",
930-
"--sub-format", "ass/srt/best"
941+
"--sub-format", wanted_sub_formats
931942
}
932943

933944
-- Checks if video option is "no", change format accordingly,

0 commit comments

Comments
 (0)