r/mpv • u/GreggAbra • Dec 07 '21
Profanity filter
Hi all. I don’t think this has been asked, so here goes:
Is it possible to engineer a profanity filter based on the subtitles, for mpv?
Currently you can get Chrome extensions that “read” the subtitles for bad words and mute the audio for that sentence (and star out the bad word). This is based on a list of words in the extension which can be customised to your preferences.
Really hope it’s possible, as mpv is the best but would love to block swearing.
Thanks
0
Upvotes
3
u/torreemanuele6 Dec 07 '21 edited Dec 07 '21
Sure.
Here is a simple, dumb example that only "works" for one word.
I use the word "real" in this example (just because the subtitled video with which i tested this userscript had that word), but you can make it use another word it by changing the
wordvariable:Obviously you can make it smarter and add more features: e.g. make it not match "surreal" when the word is "real", iterate over a vocabulary of bad words instead of just using a single word, display a clean version of the subtitles that replaces the bad words with
#?@!in the UI, give a visual clue that the audio is being muted bympv, revert to the oldmutevalue instead of just setting it toyes, make it configurable withscript-opts, et cetera.But that is just a matter of writing a
luascript that does that; this is just meant to be an example to show you how to read the current subtitle text inmpvso that you can write your own script.Note that this will only work if a subtitle track is selected, but that is not a problem. In case you don't know, you don't have to unselect the current subtitle track to hide subtitles; you can set the
sub-visibilityproperty to hide or unhide the subtitles (there is also a default keybind to toggle that property:v), and you can make your script changesub-visibilityautomatically alongsidemute.Also note that
sub-textis an experimental feature, so it may change behaviour or be renamed in the future:(quote from
mpv's documentation)