diff options
author | jaseg <code@jaseg.net> | 2020-07-12 13:28:38 +0200 |
---|---|---|
committer | jaseg <code@jaseg.net> | 2020-07-12 13:28:38 +0200 |
commit | 50294b7f2fe8d9125672c12bc01b4fde165a6ac2 (patch) | |
tree | e407170b8f69c31422b95009d70ab4cfe45f42a2 /README.rst | |
parent | c3eef35f595bc4aa2c2aa30345ad63ee583e98e1 (diff) | |
download | python-mpv-50294b7f2fe8d9125672c12bc01b4fde165a6ac2.tar.gz python-mpv-50294b7f2fe8d9125672c12bc01b4fde165a6ac2.tar.bz2 python-mpv-50294b7f2fe8d9125672c12bc01b4fde165a6ac2.zip |
README: Add detail on subtitle handling
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -161,24 +161,35 @@ Directly feeding mpv data from python player.play('python://foo') player.wait_for_playback() -Inserting subtitles -................... +Using external subtitles +........................ + +The easiest way to load custom subtitles from a file is to pass the ``--sub-file`` option to the ``loadfile`` call: + +.. code:: python + + #!/usr/bin/env python3 + import mpv + + player = mpv.MPV() + player.play('test.webm', sub_file='test.srt') + +Note that you can also pass many other options to ``loadfile``. See the mpv docs for details. -The "core-idle" property tells you whether video is actually playing or not -(player core is available for further commands) +If you want to add subtitle files or streams at runtime, you can use the ``sub-add`` command. ``sub-add`` can only be +called once the player is done loading the file and starts playing. An easy way to wait for this is to wait for the +``core-idle`` property. .. code:: python #!/usr/bin/env python3 import mpv - from operator import not_ - player = mpv.MPV(log_handler=print, input_default_bindings=True, input_vo_keyboard=True) - player.play(video) - player.wait_for_property('core-idle', not_) - player.sub_add(subs) + player = mpv.MPV() + player.play('test.webm') + player.wait_for_property('core-idle', lambda idle: not idle) + player.sub_add('test.srt') player.wait_for_playback() - player.terminate() Using MPV's built-in GUI ........................ |