-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
speed-transition.lua: Ignore subtitles that match a regex pattern #20
Comments
I currently have a feature similar to this in a pending pull request. It is much simpler though. It is just a table of characters that if exist at all in the subtitle, it will will ignore that line. |
@bitingsock Thanks a lot! This is great. In case it might be of use, I've converted my above regex into Lua patterns. I didn't know Lua had no regex included, since I have basically no Lua experience. I've also added two characters from your change: ignoredCharacters = "#♯♩♪♬♫🎵🎶"
-- Test strings:
s = " [ loud noise ] "
--s = " How are you doing? "
--s = " ♫ la deda ♪ "
--s = " why "
--s = " ♯🎵# "
--s = " Hey, it's just a ♪ character! "
local st = s:gsub("^%s*(.-)%s*$", "%1") -- trim string
local ign = ignoredCharacters
local isLikelyAudioSub = st:len() < 4 or st:find("^%[.*%]$") or
st:find("^[" .. ign .. "]+.*[" .. ign .. "]+$") or
st:find("^[ " .. ign .. "]+$")
print(isLikelyAudioSub) |
Cool, I'll try to implement this. |
I got the pattern match working: https://github.com/bitingsock/mpv-scripts/blob/patch-4/speed-transition.lua |
@bitingsock Thanks a lot! =) |
@bitingsock Just noticed something, and I think this was also the case previously. When using subtitles that cannot easily be converted to text (e.g. image based ones), the script doesn't work at all. I'm not sure what the cause is, but sub-stepping seems to work. You can step from one subtitle to the next. (Of course the match filter can't work without the actual text) |
Correct, it has always only worked on Text bases subs. However, there may be some way to make a way using pure sub-stepping based on properties that are already triggering the functions. I'll have to think about that. |
That would be really awesome! Not sure how useful, but one thing I've tried is to make However, it seems that with image-based subtitles both Either I'm missing something, or this is a bug in mpv. Just found this plugin of yours (which inspired the speed-transition one), and it seems like it would avoid that problem by calling a function periodically (not tried). |
First of all, thanks for the
speed-transition.lua
script! It's really useful.I don't know how easy it is to achieve, but I'd love if the script could ignore subtitles that are shorter than a certain length, since very short subtitles can be read quickly even at high speeds, and often they just contain something like
♪♫
when music is played.I think regex might be useful for that, so that one could also ignore subtitles where the whole text is enclosed in square brackets, which are often used to describe sounds.
Pattern that could be used:
The text was updated successfully, but these errors were encountered: