Skip to main content

Python MPV JSONIPC

This implements an interface similar to python-mpv, but it uses the JSON IPC protocol instead of the C API. This means you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt instead of needing libmpv1. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't directly communicating with MPV via the C API the performance will be worse.

Please note that this only implements the subset of python-mpv that is used by plex-mpv-shim and jellyfin-mpv-shim. Other functionality has not been implemented.

Installation

sudo pip3 install python-mpv-jsonipc

Basic usage

Create an instance of MPV. You can use an already running MPV or have the library start a managed copy of MPV. Command arguments can be specified when initializing MPV if you are starting a managed copy of MPV.

Please also see the API Documentation.

from python_mpv_jsonipc import MPV

# Uses MPV that is in the PATH.
mpv = MPV()

# Use MPV that is running and connected to /tmp/mpv-socket.
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")

# Uses MPV that is found at /path/to/mpv.
mpv = MPV(mpv_location="/path/to/mpv")

# After you have an MPV, you can read and set (if applicable) properties.
mpv.volume # 100.0 by default
mpv.volume = 20 

# You can also send commands.
mpv.command_name(arg1, arg2)

# Or send one without waiting for it. Returns a concurrent.futures.Future.
mpv.command_async("sub-add", "https://example.com/slow.srt",
                  callback=lambda error, result: print(error or "loaded"))

# Bind to key press events with a decorator
@mpv.on_key_press("space")
def space_handler():
    pass

# You can also observe and wait for properties.
@mpv.property_observer("eof-reached")
def handle_eof(name, value):
    pass

# Or simply wait for the value to change once.
mpv.wait_for_property("duration")

Metadata

Release files for python-mpv-jsonipc 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-mpv-jsonipc 1.5.0
File Size Uploaded Provenance
python_mpv_jsonipc-1.5.0.tar.gz 44.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-mpv-jsonipc 1.5.0
File Interpreter ABI Platform
python_mpv_jsonipc-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.6 kB

Release files / python_mpv_jsonipc-1.5.0.tar.gz

Download URL python_mpv_jsonipc-1.5.0.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bfcedc88f58c9a4e9631cde4ae56efbcbe09127850ce36ea76db31a15665bfc6
BLAKE2b-256 checksum
How to use checksums
d16585a18ffaaf8990dc54dbefa05fd34443e2a5791ea10171bb85225a4fbb79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / python_mpv_jsonipc-1.5.0-py3-none-any.whl

Download URL python_mpv_jsonipc-1.5.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ce720a07a005c6e37b3eacccffe220ad73cf5d5b0aa9dd77dbe8578be4f249
BLAKE2b-256 checksum
How to use checksums
16d2a84078ecdde229251284c290109e93c00ddc5f0a0831284ada6bd6cb04d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for python-mpv-jsonipc 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page