Enabling the IPC server
There are two ways to connect to the IPC interface:--input-ipc-server=<path>— mpv creates and listens on a Unix socket (Linux/macOS) or named pipe (Windows) at the given path. External programs connect to it.--input-ipc-client=<fd>— mpv connects to an already-open Unix socket or named pipe specified by its file descriptor number. The connection is established at startup.
- Linux / macOS
- Windows
Pass a socket path with You can also add it permanently to Use
--input-ipc-server:~/.config/mpv/mpv.conf:--idle to keep mpv open when no file is playing, which is useful for scripted control:Protocol
The protocol transmits UTF-8 JSON. Each message — command, reply, or event — is a single line terminated by\n. The \n character must not appear inside a message (minify JSON before sending).
Sending a command
Receiving a reply
"error": "success" means the command completed without error. data holds the command’s return value (can be null).
Using request_id
Because events can arrive at any time, it can be hard to match replies to commands. Include an integer request_id and mpv will echo it back:
request_id must be an integer in the range −2^63..2^63−1. If omitted, replies set it to 0.
Events
mpv sends events as unsolicited JSON lines:socat example (Linux/macOS)
# and empty lines are ignored. Any line whose first non-whitespace character is not { is treated as a text command.
IPC commands
In addition to the standard input commands, these commands are available exclusively through the IPC protocol:get_property
get_property
Return the value of a property as a native JSON type.
get_property_string
get_property_string
Return the value of a property always as a string.
set_property
set_property
Set a property to the given value.
set_property_string is an alias; both accept native values and strings.observe_property
observe_property
Subscribe to property changes. Whenever the property changes, a
property-change event is sent with the numeric id you specified.observe_property_string
observe_property_string
Like
observe_property, but the event data field is always a string.unobserve_property
unobserve_property
Cancel a property observation using the numeric ID from the original
observe_property call.client_name
client_name
Return the name of the IPC client connection. This is
ipc-N where N is an integer.get_time_us
get_time_us
Return the current mpv internal time in microseconds.
request_log_messages
request_log_messages
Enable delivery of mpv log messages as events. The argument is the minimum log level.Log messages arrive as
log-message events with prefix, level, and text fields. These are intended for human reading, not machine parsing.enable_event / disable_event
enable_event / disable_event
Enable or disable specific events by name. Use
"all" to affect all events at once.get_version
get_version
Return the client API version of the running mpv instance.
Asynchronous commands
Commands normally block until completion. Add"async": true to run a command asynchronously — the response arrives when the command finishes, regardless of order:
Named arguments
Instead of an array, thecommand field can be a JSON object, which passes named arguments:
get_property.
Data flow
- Replies to IPC messages are sent in sequence.
- While a command executes, the server does not process additional messages. Events that occurred during execution are queued and sent after the reply.
- You may read unrelated event messages before a command reply — they were queued before your command was processed.
- Asynchronous commands do not block IPC interaction while executing.
UTF-8 notes
All strings are normally UTF-8. In some edge cases (file tags, filenames on Unix), mpv may send invalid UTF-8. If your JSON parser is strict, filter raw bytes for invalid sequences before parsing. mpv will never construct invalid UTF-8 using\u escape sequences, including surrogate pairs.
JSON extensions
mpv accepts these non-standard extensions in JSON it receives:- Trailing commas in arrays and objects
=as an alternative to:in object entries- Unquoted object keys (if they start with
A-Za-z_and contain onlyA-Za-z0-9_) \xABbyte escapes (two hex digits)
Anonymous IPC connections via .run scripts
You can start a process that receives an IPC connection without configuring --input-ipc-server. Place a file with a .run extension in the mpv scripts directory. mpv executes it as a native process (it must have a shebang and the executable bit set).
The IPC socket file descriptor is passed via the --mpv-ipc-fd=N command-line argument. The rest of the protocol is identical to a normal --input-ipc-server connection.
Anonymous IPC connections via
.run scripts do not work on Windows.