Skip to content

Commit d5fe4c7

Browse files
committed
ytdl_hook: add srv3 to supported subtitle formats
This allows YouTube videos played directly from a URL to make use of subrandr's SRV3 support.
1 parent 38ee83e commit d5fe4c7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

player/lua/ytdl_hook.lua

+16-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ local ext_map = {
7777
["opus"] = "opus",
7878
}
7979

80+
local fullconfig = mp.get_property_native("mpv-full-configuration")
81+
local has_subrandr = false
82+
for feature in string.gmatch(fullconfig, "([^ ]+)") do
83+
has_subrandr = has_subrandr or feature == "subrandr"
84+
end
85+
8086
local codec_map = {
8187
-- src pattern = mpv codec
8288
["vtt"] = "webvtt",
@@ -87,6 +93,10 @@ local codec_map = {
8793
["mp4a%..*"] = "aac",
8894
}
8995

96+
if has_subrandr then
97+
codec_map["srv3"] = "textsub/srv3"
98+
end
99+
90100
-- Codec name as reported by youtube-dl mapped to mpv internal codec names.
91101
-- Fun fact: mpv will not really use the codec, but will still try to initialize
92102
-- the codec on track selection (just to scrap it), meaning it's only a hint,
@@ -924,10 +934,15 @@ local function run_ytdl_hook(url)
924934
local allsubs = true
925935
local proxy = nil
926936
local use_playlist = false
937+
local wanted_sub_formats = "ass/srt/best"
938+
939+
if has_subrandr then
940+
wanted_sub_formats = "srv3/" .. wanted_sub_formats
941+
end
927942

928943
local command = {
929944
ytdl.path, "--no-warnings", "-J", "--flat-playlist",
930-
"--sub-format", "ass/srt/best"
945+
"--sub-format", wanted_sub_formats
931946
}
932947

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

0 commit comments

Comments
 (0)