summaryrefslogtreecommitdiffstats
path: root/DOCS
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-16 02:03:36 +0100
committerwm4 <wm4@nowhere>2020-02-16 02:07:24 +0100
commita4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d (patch)
treefa028721887a4bc984a20c946c4ee95295677b7a /DOCS
parent0b35b4c91796fb020e13d955efd450021eb5eedb (diff)
downloadmpv-a4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d.tar.bz2
mpv-a4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d.tar.xz
sub: add an option to filter subtitles by regex
Works as ad-filter. I had some more plans, for example replacing matching text with different text, but for now it's dropping matches only. There's a big warning in the manpage that I might change semantics. For example, I might turn it into a primitive sed. In a sane world, you'd probably write a simple script that processes downloaded subtitles before giving them to mpv, and avoid all this complexity. But we don't live in a sane world, and the sooner you learn this, the happier you will be. (But I also want to run this on muxed subtitles.) This is pretty straightforward. We use POSIX regexes, which are readily available without additional pain or dependencies. This also means it's (apparently) not available on win32 (MinGW). The regex list is because I hate big monolithic regexes, and this makes it slightly better. Very superficially tested.
Diffstat (limited to 'DOCS')
-rw-r--r--DOCS/man/options.rst41
1 files changed, 41 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 0572b66816..5ffc16cf89 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2571,6 +2571,47 @@ Subtitles
Default: ``no``.
+``--sub-filter-regex-...=...``
+ Set a list of regular expressions to match on text subtitles, and remove any
+ lines that match (default: empty). This is a string list option. See
+ `List Options`_ for details. Normally, you should use
+ ``--sub-filter-regex-append=<regex>``, where each option use will append a
+ new regular expression, without having to fight escaping problems.
+
+ List items are matched in order. If a regular expression matches, the
+ process is stopped, and the subtitle line is discarded. The text matched
+ against is, currently, always the ``Text`` field of ASS events (if the
+ subtitle format is different, it is always converted). This may include
+ formatting tags. Matching is case-insensitive, but how this is done depends
+ on the libc, and most likely works in ASCII only. It does not work on
+ bitmap/image subtitles. Unavailable on inferior OSes (requires POSIX regex
+ support).
+
+ .. admonition:: Example
+
+ ``--sub-filter-regex-append=opensubtitles\.org`` filters some ads.
+
+ Technically, using a list for matching is redundant, since you could just
+ use a single combined regular expression. But it helps with diagnosis,
+ ease of use, and temporarily disabling or enabling individual filters.
+
+ .. warning::
+
+ This is experimental. The semantics most likely will change, and if you
+ use this, you should be prepared to update the option later. Ideas
+ include replacing the regexes with a very primitive and small subset of
+ sed, or some method to control case-sensitivity.
+
+``--sub-filter-regex-warn=<yes|no>``
+ Log dropped lines with warning log level, instead of verbose (default: no).
+ Helpful for testing.
+
+``--sub-filter-regex-enable=<yes|no>``
+ Whether to enable regex filtering (default: yes). Note that if no regexes
+ are added to the ``--sub-filter-regex`` list, setting this option to ``yes``
+ has no default. It's meant to easily disable or enable filtering
+ temporarily.
+
``--sub-create-cc-track=<yes|no>``
For every video stream, create a closed captions track (default: no). The
only purpose is to make the track available for selection at the start of