summaryrefslogtreecommitdiffstats
path: root/DOCS/man
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-07-15 03:20:40 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commit9cfeafa89e2e8cbd67ba60371804e817c72e701a (patch)
tree7d4b1d0edf7f21ec244146d80254f435c4ed693a /DOCS/man
parentda612acacdf41a9a72b095fa582a6b37996b0811 (diff)
downloadmpv-9cfeafa89e2e8cbd67ba60371804e817c72e701a.tar.bz2
mpv-9cfeafa89e2e8cbd67ba60371804e817c72e701a.tar.xz
video: add vf_fingerprint and a skip-logo script
skip-logo.lua is just what I wanted to have. Explanations are on the top of that file. As usual, all documentation threatens to remove this stuff all the time, since this stuff is just for me, and unlike a normal user I can afford the luxuary of hacking the shit directly into the player. vf_fingerprint is needed to support this script. It needs to scale down video frames as part of its operation. For that, it uses zimg. zimg is much faster than libswscale and generates more correct output. (The filter includes a runtime fallback, but it doesn't even work because libswscale fucks up and can't do YUV->Gray with range adjustment.) Note on the algorithm: seems almost too simple, but was suggested to me. It seems to be pretty effective, although long time experience with false positives is missing. At first I wanted to use dHash [1][2], which is also pretty simple and effective, but might actually be worse than the implemented mechanism. dHash has the advantage that the fingerprint is smaller. But exact matching is too unreliable, and you'd still need to determine the number of different bits for fuzzier comparison. So there wasn't really a reason to use it. [1] https://pypi.org/project/dhash/ [2] http://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html
Diffstat (limited to 'DOCS/man')
-rw-r--r--DOCS/man/vf.rst71
1 files changed, 71 insertions, 0 deletions
diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst
index 5c576e6bad..6465d305ff 100644
--- a/DOCS/man/vf.rst
+++ b/DOCS/man/vf.rst
@@ -546,3 +546,74 @@ Available mpv-only filters are:
which algorithm is actually selected. ``none`` always falls back. On
most if not all hardware, this option will probably do nothing, because
a video processor usually supports all modes or none.
+
+``fingerprint=...``
+ Compute video frame fingerprints and provide them as metadata. Actually, it
+ currently barely deserved to be called ``fingerprint``, because it does not
+ compute "proper" fingerprints, only tiny downscaled images (but which can be
+ used to compute image hashes or for similarity matching).
+
+ The main purpose of this filter is to support the ``skip-logo.lua`` script.
+ If this script is dropped, or mpv ever gains a way to load user-defined
+ filters (other than VapourSynth), this filter will be removed. Due to the
+ "special" nature of this filter, it will be removed without warning.
+
+ The intended way to read from the filter is using ``vf-metadata`` (also
+ see ``clear-on-query`` filter parameter). The property will return a list
+ of key/value pairs as follows:
+
+ ::
+
+ fp0.pts = 1.2345
+ fp0.hex = 1234abcdef...bcde
+ fp1.pts = 1.4567
+ fp1.hex = abcdef1234...6789
+ ...
+ fpN.pts = ...
+ fpN.hex = ...
+ type = gray-hex-16x16
+
+ Each ``fp<N>`` entry is for a frame. The ``pts`` entry specifies the
+ timestamp of the frame (within the filter chain; in simple cases this is
+ the same as the display timestamp). The ``hex`` field is the hex encoded
+ fingerprint, whose size and meaning depend on the ``type`` filter option.
+ The ``type`` field has the same value as the option the filter was created
+ with.
+
+ This returns the frames that were filtered since the last query of the
+ property. If ``clear-on-query=no`` was set, a query doesn't reset the list
+ of frames. In both cases, a maximum of 10 frames is returned. If there are
+ more frames, the oldest frames are discarded. Frames are returned in filter
+ order.
+
+ (This doesn't return a structured list for the per-frame details because the
+ internals of the ``vf-metadata`` mechanism suck. The returned format may
+ change in the future.)
+
+ This filter uses zimg for speed and profit. However, it will fallback to
+ libswscale in a number of situations: lesser pixel formats, unaligned data
+ pointers or strides, or if zimg fails to initialize for unknown reasons. In
+ these cases, the filter will use more CPU. Also, it will output different
+ fingerprints, because libswscale cannot perform the full range expansion we
+ normally request from zimg. As a consequence, the filter may be slower and
+ not work correctly in random situations.
+
+ ``type=...``
+ What fingerprint to compute. Available types are:
+
+ :gray-hex-8x8: grayscale, 8 bit, 8x8 size
+ :gray-hex-16x16: grayscale, 8 bit, 16x16 size (default)
+
+ Both types simply remove all colors, downscale the image, concatenate
+ all pixel values to a byte array, and convert the array to a hex string.
+
+ ``clear-on-query=yes|no``
+ Clear the list of frame fingerprints if the ``vf-metadata`` property for
+ this filter is queried (default: yes). This requires some care by the
+ user. Some types of accesses might query the filter multiple times,
+ which leads to lost frames.
+
+ ``print=yes|no``
+ Print computed fingerprints the the terminal (default: no). This is
+ mostly for testing and such. Scripts should use ``vf-metadata`` to
+ read information from this filter instead.