summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/mpv.py b/mpv.py
index 27af879..5348d8f 100644
--- a/mpv.py
+++ b/mpv.py
@@ -659,6 +659,17 @@ class MPV(object):
""" Mapped mpv screenshot_to_file command, see man mpv(1). """
self.command('screenshot_to_file', filename.encode(fs_enc), includes)
+ def screenshot_raw(self, includes='subtitles'):
+ """ Mapped mpv screenshot_raw command, see man mpv(1). Returns a pillow Image object."""
+ from PIL import Image
+ res = self.node_command('screenshot-raw', includes)
+ if res['format'] != 'bgr0':
+ raise ValueError('Screenshot in unknown format "{}". Currently, only bgr0 is supported.'
+ .format(res['format']))
+ img = Image.frombytes('RGBA', (res['w'], res['h']), res['data'])
+ b,g,r,a = img.split()
+ return Image.merge('RGB', (r,g,b))
+
def playlist_next(self, mode='weak'):
""" Mapped mpv seek command, see man mpv(1). """
self.command('playlist_next', mode)