summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-04-17 22:36:13 +0200
committerjaseg <git@jaseg.de>2022-04-17 22:36:13 +0200
commitb0d34af527ef687afc1dbcc5501707f2ff28586a (patch)
tree78343b66731312e3986238f92cd6b62dc565aaf2 /README.rst
parent850bfcbd2fcd8d2d6e0942e6110583c667dce443 (diff)
downloadpython-mpv-b0d34af527ef687afc1dbcc5501707f2ff28586a.tar.gz
python-mpv-b0d34af527ef687afc1dbcc5501707f2ff28586a.tar.bz2
python-mpv-b0d34af527ef687afc1dbcc5501707f2ff28586a.zip
README: Add skip silence example
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index a6088af..198352d 100644
--- a/README.rst
+++ b/README.rst
@@ -122,6 +122,36 @@ Logging, Properties, Python Key Bindings, Screenshots and youtube-dl
del player
+Skipping silence using libav filters
+....................................
+
+The following code uses the libav silencedetect filter to skip silence at the beginning of a file. It works by loading
+the filter, then parsing its output from mpv's log. Thanks to Sean DeNigris on github (#202) for the original code!
+
+.. code:: python
+
+ #!/usr/bin/env python3
+ import sys
+ import mpv
+
+ p = mpv.MPV()
+ p.play(sys.argv[1])
+
+ def skip_silence():
+ p.set_loglevel('debug')
+ p.af = 'lavfi=[silencedetect=n=-20dB:d=1]'
+ p.speed = 100
+ def check(evt):
+ toks = evt['event']['text'].split()
+ if 'silence_end:' in toks:
+ return float(toks[2])
+ p.time_pos = p.wait_for_event('log_message', cond=check)
+ p.speed = 1
+ p.af = ''
+
+ skip_silence()
+ p.wait_for_playback()
+
Video overlays
..............