jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
532 stars 67 forks source link

Is it possible to pass file-like object to `play()`? #199

Closed riaqn closed 2 years ago

riaqn commented 2 years ago

Currently we do have support for python://, which however would be quite slow if mpv seeks backward: the generator would have to be called from the beginning again. I wonder if we can support a file-like object with random access capability?

neinseg commented 2 years ago

Hey there!

There is no straightforward way to use a file-like object (yet). However, with MPV.register_stream_protocol it should be fairly easy to build your own. Check out the docstring behind the link above for details. This method is what sits behind the whole python:// magic, and has seeking support. Be a bit careful though, since if you return bad values e.g. from size(), libmpv will be very unhappy and take down your entire python process using abort().

jaseg commented 2 years ago

Feel free to open a new issue if you have more questions.