There is no need to compare sub-start now that we don't check for exact matches with ffmpeg's timestamps. time-pos can always be used. Comparing time-pos removes the need for the workaround of sub-start of embedded subtitles being earlier than ffmpeg's timestamps, as time-pos is always slightly after sub-start. Removing this workaround also fixes a bug present since 4059d1832b, which started comparing numerical values of timestamps instead of strings to determine the preselected subtitle line, where the line after the current one is preselected when sub-start is greater than ffmpeg's timestamps because they have been rounded, e.g. sub-start 10.001 is > than ffmpeg's 10.00. This will also allow considering --sub-delay in the comparisons, as comparing sub-start - sub-delay would preselect the wrong lines.
Showing the changes to player/lua/select.lua (1 of 1 file). Show all
Unified · Split
| @@ -232,8 +232,7 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () · 231 unmodified lines | ||
| 232 | 232 | local sub_lines = {} |
| 233 | 233 | local sub_times = {} |
| 234 | 234 | local default_item |
| 235 | − local sub_start = mp.get_property_native("sub-start", | |
| 236 | − mp.get_property_native("time-pos")) | |
| 235 | + local time_pos = mp.get_property_native("time-pos") | |
| 237 | 236 | local duration = mp.get_property_native("duration", math.huge) |
| 238 | 237 | |
| 239 | 238 | -- Strip HTML and ASS tags. |
| @@ -243,19 +242,11 @@ mp.add_forced_key_binding(nil, "select-subtitle-line", function () · 3 unmodified lines | ||
| 243 | 242 | sub_lines[#sub_lines + 1] = format_time(sub_times[#sub_times], duration) .. |
| 244 | 243 | " " .. line:gsub(".*]", "", 1) |
| 245 | 244 | |
| 246 | − if sub_times[#sub_times] <= sub_start then | |
| 245 | + if sub_times[#sub_times] <= time_pos then | |
| 247 | 246 | default_item = #sub_times |
| 248 | 247 | end |
| 249 | 248 | end |
| 250 | 249 | |
| 251 | − -- Handle sub-start of embedded subs being slightly earlier than | |
| 252 | − -- ffmpeg's timestamps. | |
| 253 | − sub_start = mp.get_property_native("sub-start") | |
| 254 | − if sub_start and default_item and sub_times[default_item] < sub_start and | |
| 255 | − sub_lines[default_item + 1] then | |
| 256 | − default_item = default_item + 1 | |
| 257 | − end | |
| 258 | − | |
| 259 | 250 | input.select({ |
| 260 | 251 | prompt = "Select a line to seek to:", |
| 261 | 252 | items = sub_lines, |