summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst41
1 files changed, 40 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index a156814..19e1269 100644
--- a/README.rst
+++ b/README.rst
@@ -122,6 +122,45 @@ Logging, Properties, Python Key Bindings, Screenshots and youtube-dl
del player
+Video overlays
+..............
+
+.. code:: python
+
+ #!/usr/bin/env python3
+ import time
+ from PIL import Image, ImageDraw, ImageFont
+ import mpv
+
+ player = mpv.MPV()
+
+ player.loop = True
+ player.play('test.webm')
+ player.wait_until_playing()
+
+ font = ImageFont.truetype('DejaVuSans.ttf', 40)
+
+ while not player.core_idle:
+
+ time.sleep(0.5)
+ overlay = player.create_image_overlay()
+
+ for pos in range(0, 500, 5):
+ ts = player.time_pos
+ if ts is None:
+ break
+
+ img = Image.new('RGBA', (400, 150), (255, 255, 255, 0))
+ d = ImageDraw.Draw(img)
+ d.text((10, 10), 'Hello World', font=font, fill=(0, 255, 255, 128))
+ d.text((10, 60), f't={ts:.3f}', font=font, fill=(255, 0, 255, 255))
+
+ overlay.update(img, pos=(2*pos, pos))
+ time.sleep(0.05)
+
+ overlay.remove()
+
+
Playlist handling
.................
@@ -187,7 +226,7 @@ called once the player is done loading the file and starts playing. An easy way
player = mpv.MPV()
player.play('test.webm')
- player.wait_for_property('core-idle', lambda idle: not idle)
+ player.wait_until_playing()
player.sub_add('test.srt')
player.wait_for_playback()