iwalton3 / python-mpv-jsonipc Goto Github PK
View Code? Open in Web Editor NEWPython API to MPV using JSON IPC
License: Other
Python API to MPV using JSON IPC
License: Other
Thanks for this module!
Could you update the project on Python Package Index? The last release is from May 12, and it doesn't have the last commit that calls the quit when the connection is lost.
I'm playing around and I can create a new instance of MPV or connect to an existing one just fine, but I am not sure how to disconnect once connected.
Looking at whats available, mpv.terminate()
seems to be the right thing but now and again I get,
Socket connection died.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/python_mpv_jsonipc.py", line 168, in run
current_data = self.socket.recv(1024)
OSError: [Errno 9] Bad file descriptor
How do I disconnect without an error?
If you have multiple scripts connected to the same mpv instance they all receive keypresses
python-mpv-jsonipc/python_mpv_jsonipc.py
Line 444 in 9b16ab8
Line 26 in 0b28a6e
โ
ModuleNotFoundError: No module named 'python_mpv_jsonrpc'
Maybe it should be:
from python_mpv_jsonipc import MPV
?
The check done upon initialization of MPVProcess
fails for Windows because no file is created; as a matter of fact the named pipe is available.
vf
is both a command and a property.
Because commands are added to the MPV object after properties are, this means that mpv.vf(...)
issues a vf command and there's no mpv.vf
to get the vf
property.
In [1]: from python_mpv_jsonipc import MPV
In [2]: mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv.sock");
In [3]: mpv.vf()
---------------------------------------------------------------------------
MPVError Traceback (most recent call last)
<ipython-input-3-429ca6751f2e> in <module>
----> 1 mpv.vf()
/usr/local/lib/python3.8/site-packages/python_mpv_jsonipc.py in wrapper(*args)
594 def _get_wrapper(self, name):
595 def wrapper(*args):
--> 596 return self.command(name, *args)
597 return wrapper
598
Not sure what the most elegant solution is, but in the mean time I used this simple hack to allow me to fetch the vf
property.
from python_mpv_jsonipc import MPV
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv.sock");
mpv.get_property=mpv._get_wrapper("get_property")
mpv.get_property('vf')
Now I can just run mpv.get_property('vf')
. This doesn't already exist because get_property
is a separate JSON IPC command and not a property or input command.
Would it be reasonable to extend the MPV object with a get_property
attribute? If so, can submit a simple PR.
Cheers!
Just wondering if you might have any plans to support use of this controller via asyncio coroutines instead of threads. There's someone developing a similar interface here with asyncio support, but your interface is more full-featured with property observers and the like. Before I try to Frankenstein together the two projects, is this something you have any interest in supporting?
Hey! I love this library but am having issues with programs not exiting. Would it be possible to add an option to make the threads daemons so they don't hold everything up? I could make a PR for it.
Hi.
First, thanks a lot for this awesome project!
So, I'm playing radio via streaming on Windows, something like this:
mpv = MPV()
mpv.play('http://s1.myradiostream.com:12508/listen.mp3')
...
however, it displays the main MPV window as follow:
so, is there any option to hide this window?
TIA for any help!
Using mpv 0.33, I can disable key bindings manually by passing --no-input-default-bindings
, but using the latest release of this package, setting no_input_default_bindings
to True on an MPV instance does not have any effect.
Is it possible to support this parameter?
Should probably mention first that I am new to this (both python and mpv)
I'm trying to use this library to write some mpv scripts but I'm confused about a few things
How to return data from mpv
Where I find the properties that you can wait on with mpv.wait_for_property using mpv.io
How to connect to running instance of mpv
How to connect to running instance of mpv
Hello,
I've implemented your library and I'm getting the following error:
Socket connection died.
Traceback (most recent call last):
File "/opt/app/env/lib/python3.11/site-packages/python_mpv_jsonipc.py", line 184, in run
self.callback(json_data)
File "/opt/app/env/lib/python3.11/site-packages/python_mpv_jsonipc.py", line 310, in event_callback
self.cid_wait[data["request_id"]].set()
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 7
The odd thing is that MPV continues running just fine and I can test the socket with no issues. I think the socket is fine but the exception is causing the lib to incorrectly report the socket as being dead. I have not worked with request id's in the MPV JSON-IPC myself, so I'm not certain what the lib is doing here, but I remember seeing them mentioned in the MPV docs. I will attempt to hack at it a bit to see if I can figure it out and maybe offer a solution but I wanted to report it so that you're aware.
Running the new Debian Bookworm (Raspberry Pi OS on a Raspi 5) with a repo-installed version of MPV.
Number arguments to the MPV constructor are converted to "yes"/"no" when they should't be.
Example:
extra_args = {
"video-scale-x": 1
}
MPV(**extra_args)
MPV starts
python_mpv_jsonipc.MPVError: MPV process retry limit reached.
Change MPVProcess_mpv_fmt() to if data is True:
and elif data is False
Also: is it possible to include the mpv error in the traceback?
It seems like the socket thread holding a reference to the callback prevents del from being called, which means the thread never stops unless you manually call terminate() explicitly, and you get a thread leak.
And when you do call it explicitly, it sometimes stops with a nuisance error when the thread tries to read the closed socket. I work around that by changing the "while True" to "while self.should_run" and setting that to False to stop the loop before shutting down the socket and process.
Hi. When we package python packages for nixpkgs, we try to pull source from GitHub so that tests are included. Even though there aren't tests yet, I'd like to follow that pattern.
It's most easily followed when releases are tagged on Git too. Can you do this so I can package a released version for nixpkgs? context: NixOS/nixpkgs#77884
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.