Skip to main content
mpv’s command interface is shared across all control surfaces: input.conf key bindings, the JSON IPC protocol, Lua/JavaScript scripts, and the libmpv C API all use the same commands and property names.

input.conf

The input.conf file maps keys to commands. It lives at ~/.config/mpv/input.conf.
s screenshot                     # take a screenshot with the s key
LEFT seek -15                    # left arrow seeks backward 15 seconds
RIGHT seek 15                    # right arrow seeks forward 15 seconds
ctrl+q quit                      # quit with Ctrl+Q
Default bindings are defined at https://github.com/mpv-player/mpv/blob/master/etc/input.conf. List all available key names:
mpv --input-keylist
Test key bindings interactively (shows the binding on OSD instead of executing it):
mpv --input-test --force-window --idle

Syntax

[Shift+][Ctrl+][Alt+][Meta+]<key> [{<section>}] <command> [; <command> ...]
  • Multiple commands can be chained with ;
  • # begins a comment (outside quoted strings); use SHARP to bind the # key
  • Strings with spaces or special characters must be quoted: "...", '...', or `X...X` (custom quotes)

Multiple commands on one key

a show-text "command 1" ; show-text "command 2"

Key sequences

a-b-c show-text "pressed a, then b, then c"

Key modifiers

ModifierExample
Shift+Shift+LEFT
Ctrl+ctrl+q
Alt+Alt+F4
Meta+Meta+a
For text keys, use the character produced by the key rather than adding Shift+. For example, @ instead of Shift+2 on a US keyboard. ASCII letters are an exception: Shift+a is interpreted as A.

Special key names (selected)

NameDescription
LEFT, RIGHT, UP, DOWNArrow keys
ENTER, ESC, TAB, BSControl keys
SPACESpace bar
KP*Numpad keys (e.g. KP0, KP_ENTER)
MOUSE_BTN0MOUSE_BTN19Mouse buttons
WHEEL_UP, WHEEL_DOWN, WHEEL_LEFT, WHEEL_RIGHTMouse wheel
CLOSE_WINWindow close button
GAMEPAD_*Gamepad inputs (SDL backend)
UNMAPPEDAny unmapped key
ANY_UNICODEAny key that produces text

Input command prefixes

Prefixes go between the key name and the command in input.conf. Multiple prefixes are separated by spaces.
PrefixDescription
osd-autoDefault OSD behavior for this command (default for input.conf)
no-osdSuppress OSD for this command
osd-barShow a progress bar
osd-msgShow a text OSD message
osd-msg-barShow both a message and a bar
rawDo not expand ${property} placeholders in string arguments
expand-propertiesExpand ${property} in all string arguments (default for input.conf)
repeatableForce key repeat for this command
nonrepeatableForce disable key repeat
nonscalableDisable high-resolution scaling for scalable commands
asyncRun command asynchronously if possible
syncRun command synchronously if possible
# Show OSD bar when changing volume
osd-bar add volume 5
# Seek without any OSD
no-osd seek 10

Property system

Properties allow reading and writing player state at runtime. They are used by:
  • set, add, cycle, multiply commands
  • ${property} expansion in show-text, print-text
  • Scripting APIs (mp.get_property, mp.observe_property, etc.)
  • IPC get_property / set_property commands
Most command-line options are also available as properties (strip the leading --). Properties marked (RW) can be written; others are read-only.

Key properties

Playback state

PropertyTypeDescription
pause (RW)boolPaused state
speed (RW)numberPlayback speed multiplier
time-pos (RW)numberCurrent position in seconds
playback-time (RW)numberAlias for time-pos
percent-pos (RW)numberPosition as 0–100 percent
durationnumberFile duration in seconds
time-remainingnumberRemaining time in seconds

Audio / video

PropertyTypeDescription
volume (RW)numberAudio volume (0–100+)
mute (RW)boolMute state
fullscreen (RW)boolFullscreen state
video-zoom (RW)numberVideo zoom factor
brightness (RW)numberVideo brightness (−100 to 100)
contrast (RW)numberVideo contrast
sub-delay (RW)numberSubtitle delay in seconds

File information

PropertyTypeDescription
filenamestringFilename without path
pathstringFull path of current file
media-titlestringTitle tag or filename
file-formatstringFormat name (e.g. matroska)
durationnumberTotal duration in seconds

Playlist

PropertyTypeDescription
playlist-pos (RW)integerCurrent playlist index (0-based)
playlist-countintegerNumber of playlist entries
playlistlistFull playlist as a list
loop-playlist (RW)stringLoop mode (no, inf, force)
loop-file (RW)stringFile loop (no, inf, integer)

Command reference

Playback control

Change playback position.Flags (combine with +):
FlagDescription
relative (default)Seek relative to current position; negative = backwards
absoluteSeek to exact time; negative = from end of file
absolute-percentSeek to a percentage of total duration
relative-percentSeek relative to current position in percent
keyframesFast seek to nearest keyframe
exactPrecise (slow) seek
By default keyframes is used for relative seeks and exact for absolute seeks. Combine flags:
RIGHT seek 10 relative+keyframes
END   seek 100 absolute-percent+exact
In scripts:
mp.commandv("seek", "30", "relative")
mp.commandv("seek", "50", "absolute-percent")
Undo the most recent seek. Call again to undo the revert. Works within a single file.Flags: mark (mark current position for revert), mark-permanent (always revert to this position until changed).
Advance or step back by frames. Default is 1 frame. Flags: play (default — play then pause), seek (precise seek), mute (like play but muted). Does not work with audio-only playback.
Step back exactly one frame. Equivalent to frame-step -1 seek. Does not work with audio-only playback.
Stop playback. With keep-playlist, the playlist is not cleared.
q stop

Property manipulation

Set a property or option to a value.
ctrl+m set mute yes
f       set fullscreen yes
mp.commandv("set", "volume", "80")
Add value (default: 1) to a property, clamping at min/max. Scalable: on high-precision inputs (touchpads), the value is scaled to finer steps automatically.
9 add volume 5
0 add volume -5
Multiply a property by the given numeric factor.
* multiply speed 1.1
/ multiply speed 0.9090909
Cycle a property through its valid values. Wraps around at min/max. Default direction is up.
m cycle mute
o cycle osd-level
Cycle through a specific list of values. Each invocation advances to the next value, wrapping around.
x cycle-values loop-file "inf" "no"
The !reverse argument (must come first) cycles in reverse order.
Delete a property. Most properties cannot be deleted.
Modify a list-type option. Operations include append, prepend, remove, clr, etc.
# Add a GLSL shader
F5 change-list glsl-shaders append /path/to/shader.glsl

Playlist

Load and play a file or URL.Flags:
FlagDescription
replace (default)Stop current file and play the new one
appendAdd to end of playlist
append+playAppend and start playing if idle
insert-nextInsert directly after current entry
insert-atInsert at the given index (third arg)
playCombine with append/insert-* to force playback start
The fourth argument is a comma-separated opt=value list of per-file options.
mp.commandv("loadfile", "https://example.com/video.mp4", "replace")
mp.commandv("loadfile", "/tmp/another.mkv", "append")
Load a playlist file or URL. Same flags as loadfile (replace, append, insert-next, insert-at, play).
Go to the next playlist entry. Flags: weak (default — do nothing on last entry), force (quit on last entry).
> playlist-next
Go to the previous playlist entry. Same flags as playlist-next.
< playlist-prev
Start or restart playback at the given playlist index (0-based). current replays the current entry; none stops playback.
Clear the playlist, except the currently playing file.
Remove a playlist entry by index. current removes the currently playing entry and starts the next.
Move the entry at index1 to the position of index2.
Shuffle the playlist.
Attempt to undo a previous playlist-shuffle. Works only once.

Screenshot

Take a screenshot. Flags (combine with +):
FlagDescription
subtitles (default)Video with subtitles
videoRaw video, no OSD or subtitles
scaledVideo at current display resolution
windowEntire mpv window (alias for scaled+subtitles+osd)
osdInclude OSD
each-frameScreenshot every frame (toggle; run again to stop)
s screenshot
S screenshot video
Returns a node map with filename set to the saved path.
Take a screenshot and save it to a specific file. The format is determined by the file extension. Existing files are overwritten. Property expansion is applied to filename.

OSD and text

Show text on the OSD. Properties are expanded (e.g. ${playback-time}). no-osd prefix has no effect on this command.duration is in milliseconds (default: --osd-duration). level is the minimum OSD level required to show the text.
i show-text "${filename} (${playback-time})"
mp.commandv("show-text", "Hello from Lua!", "3000")
Show the progress bar, elapsed time, and total duration on the OSD.

Scripting and messaging

Send a message to all scripts. Arguments are arbitrary strings. All scripts receive the message.
x script-message my-event arg1 arg2
In Lua, register a handler with mp.register_script_message("my-event", fn).
Like script-message, but send only to the named client. The target name is the script’s internal name (as returned by mp.get_script_name()).
x script-message-to my_script my-event arg1
Invoke a key binding registered by a script via mp.add_key_binding. Useful for remapping script bindings.
y script-binding my_script/some-action
Load a script at runtime, similar to --script. Returns a client_id field in the result.

Execution

Run an external program. Unlike the shell, arguments are passed directly without shell interpretation. The program is detached — mpv continues immediately without waiting.
# Write the playing title to a file
ctrl+t run "/bin/sh" "-c" "echo ${media-title} > /tmp/playing"
Use subprocess when you need to wait for the result or capture output.
Run an external program with full control. Uses named arguments.Key parameters:
ParameterTypeDescription
argsstring arrayCommand and arguments
playback_onlyboolKill process when playback ends (default: true)
capture_stdoutboolCapture stdout (default: false)
capture_stderrboolCapture stderr (default: false)
capture_sizeintegerMax bytes to capture per stream (default: 64 MB)
stdin_datastringData to feed to stdin
envstring arrayEnvironment variables (NAME=VALUE format)
detachboolRun detached (default: false)
local r = mp.command_native({
    name = "subprocess",
    playback_only = false,
    capture_stdout = true,
    args = {"cat", "/proc/cpuinfo"},
})
if r.status == 0 then
    mp.msg.info(r.stdout)
end
The result includes status, stdout, stderr, error_string, and killed_by_us.

Quit

CommandDescription
quit [<code>]Exit mpv with optional exit code
quit-watch-later [<code>]Exit and save playback position for resuming
q quit
Q quit-watch-later

Track manipulation

CommandDescription
sub-add <url> [<flags> [<title> [<lang>]]]Load an external subtitle file
sub-remove [<id>]Remove subtitle track (external only)
sub-reload [<id>]Reload subtitle track (external only)
sub-step <skip> [<flags>]Adjust subtitle timing by N events
sub-seek <skip> [<flags>]Seek to N-th subtitle event
audio-add <url> [<flags> [<title> [<lang>]]]Load external audio track
audio-remove [<id>]Remove audio track
audio-reload [<id>]Reload audio track
video-add <url> [<flags> [<title> [<lang>]]]Load external video track
video-remove [<id>]Remove video track

Filter commands

CommandDescription
vf <op> <value>Modify video filter chain (set, add, toggle, remove, clr)
af <op> <value>Modify audio filter chain (same ops as vf)
vf-command <label> <cmd> <arg>Send a command to a lavfi video filter
af-command <label> <cmd> <arg>Send a command to a lavfi audio filter
a vf set vflip           # flip video upside-down
b vf set ""              # remove all video filters
c vf toggle gradfun      # toggle debanding filter

Configuration commands

CommandDescription
apply-profile <name> [apply|restore]Apply or restore a named config profile
load-config-file <filename>Load an additional config file at runtime
load-input-conf <filename>Load an additional input config file at runtime
write-watch-later-configSave resume position without quitting

Miscellaneous

CommandDescription
ignoreDo nothing (use to block a key without disabling all defaults)
drop-buffersFlush audio/video/demuxer buffers and restart
ab-loopCycle A-B loop states (set A, set B, clear)
keypress <name>Simulate a key press event
keydown <name>Simulate key-down (with repeat)
keyup [<name>]Simulate key-up, stopping repeat
keybind <name> <cmd>Dynamically bind a key to a command
begin-vo-draggingBegin window dragging (if VO supports it)

Property expansion

Properties can be embedded in string arguments with ${property-name}. Use ${=property-name} for the raw (unformatted) value.
i show-text "${media-title} [${time-pos} / ${duration}]"
Disable expansion with the raw prefix or $> within the string:
x show-text "literal: $>no ${expansion} here"
Property expansion happens after argument parsing. It applies by default in input.conf commands but not in scripting API calls (use expand-properties prefix to enable it there).

Events

Events are notifications sent from the player core to scripts and IPC clients. See also: Lua scripting events.

start-file

Before a file starts loading. Fields: playlist_entry_id.

file-loaded

After a file is loaded and playback begins.

end-file

After a file is unloaded. Fields: reason (eof, stop, quit, error, redirect), playlist_entry_id.

seek

On any seek (including internal seeks).

playback-restart

Start of playback after seek or file load.

shutdown

mpv is exiting.

property-change

An observed property changed. Fields: name, data.

log-message

A log message. Fields: prefix, level, text.

video-reconfig

Video output or filter reconfigured.

audio-reconfig

Audio output or filter reconfigured.

client-message

A script-message was received. Fields: args (string array).

Hooks

Hooks block the player until all registered handlers call cont() (or return if defer() was not called). They provide synchronous control at specific points.
HookTiming
on_loadBefore opening a file
on_load_failAfter file open fails
on_preloadedAfter open, before track selection
on_loadedAfter track selection, before playback
on_unloadBefore closing a file
on_before_start_fileBefore start-file event
on_after_end_fileAfter end-file event
See Lua scripting — hooks for usage details.

Build docs developers (and LLMs) love