Copyright: | GPLv2+ |
---|---|
Manual section: | 1 |
Manual group: | multimedia |
Table of Contents
mpv is a media player based on MPlayer and mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. Special input URL types are available to read input from a variety of sources other than disk files. Depending on platform, a variety of different video and audio output methods are supported.
Usage examples to get you started quickly can be found at the end of this man page.
mpv has a fully configurable, command-driven control layer which allows you to control mpv using keyboard, mouse, or remote control (there is no LIRC support - configure remotes as input devices instead).
See the --input- options for ways to customize it.
The following listings are not necessarily complete. See etc/input.conf for a list of default bindings. User input.conf files and Lua scripts can define additional key bindings.
(The following keys are valid only when using a video output that supports the corresponding adjustment.)
(The following keys are valid if you have a keyboard with multimedia keys.)
If you miss some older key bindings, look at etc/restore-old-bindings.conf in the mpv git repository.
Command line arguments starting with - are interpreted as options, everything else as filenames or URLs. All options except flag options (or choice options which include yes) require a parameter in the form --option=value.
One exception is the lone - (without anything else), which means media data will be read from stdin. Also, -- (without anything else) will make the player interpret all following arguments as filenames, even if they start with -. (To play a file named -, you need to use ./-.)
Every flag option has a no-flag counterpart, e.g. the opposite of the --fs option is --no-fs. --fs=yes is same as --fs, --fs=no is the same as --no-fs.
If an option is marked as (XXX only), it will only work in combination with the XXX option or if XXX is compiled in.
The --option=value syntax is not strictly enforced, and the alternative legacy syntax -option value and -option=value will also work. This is mostly for compatibility with MPlayer. Using these should be avoided. Their semantics can change any time in the future.
For example, the alternative syntax will consider an argument following the option a filename. mpv -fs no will attempt to play a file named no, because --fs is a flag option that requires no parameter. If an option changes and its parameter becomes optional, then a command line using the alternative syntax will break.
Until mpv 0.31.0, there was no difference whether an option started with -- or a single -. Newer mpv releases strictly expect that you pass the option value after a =. For example, before mpv --log-file f.txt would write a log to f.txt, but now this command line fails, as --log-file expects an option value, and f.txt is simply considered a normal file to be played (as in mpv f.txt).
The future plan is that -option value will not work anymore, and options with a single - behave the same as -- options.
Keep in mind that the shell will partially parse and mangle the arguments you pass to mpv. For example, you might need to quote or escape options and filenames:
mpv "filename with spaces.mkv" --title="window title"
It gets more complicated if the suboption parser is involved. The suboption parser puts several options into a single string, and passes them to a component at once, instead of using multiple options on the level of the command line.
The suboption parser can quote strings with " and [...]. Additionally, there is a special form of quoting with %n% described below.
For example, assume the hypothetical foo filter can take multiple options:
mpv test.mkv --vf=foo:option1=value1:option2:option3=value3,bar
This passes option1 and option3 to the foo filter, with option2 as flag (implicitly option2=yes), and adds a bar filter after that. If an option contains spaces or characters like , or :, you need to quote them:
mpv '--vf=foo:option1="option value with spaces",bar'
Shells may actually strip some quotes from the string passed to the commandline, so the example quotes the string twice, ensuring that mpv receives the " quotes.
The [...] form of quotes wraps everything between [ and ]. It's useful with shells that don't interpret these characters in the middle of an argument (like bash). These quotes are balanced (since mpv 0.9.0): the [ and ] nest, and the quote terminates on the last ] that has no matching [ within the string. (For example, [a[b]c] results in a[b]c.)
The fixed-length quoting syntax is intended for use with external scripts and programs.
It is started with % and has the following format:
%n%string_of_length_n
Examples
mpv '--vf=foo:option1=%11%quoted text' test.avi
Or in a script:
mpv --vf=foo:option1=%`expr length "$NAME"`%"$NAME" test.avi
Suboptions passed to the client API are also subject to escaping. Using mpv_set_option_string() is exactly like passing --name=data to the command line (but without shell processing of the string). Some options support passing values in a more structured way instead of flat strings, and can avoid the suboption parsing mess. For example, --vf supports MPV_FORMAT_NODE, which lets you pass suboptions as a nested data structure of maps and arrays.
Some care must be taken when passing arbitrary paths and filenames to mpv. For example, paths starting with - will be interpreted as options. Likewise, if a path contains the sequence ://, the string before that might be interpreted as protocol prefix, even though :// can be part of a legal UNIX path. To avoid problems with arbitrary paths, you should be sure that absolute paths passed to mpv start with /, and prefix relative paths with ./.
Using the file:// pseudo-protocol is discouraged, because it involves strange URL unescaping rules.
The name - itself is interpreted as stdin, and will cause mpv to disable console controls. (Which makes it suitable for playing data piped to stdin.)
The special argument -- can be used to stop mpv from interpreting the following arguments as options.
When using the client API, you should strictly avoid using mpv_command_string for invoking the loadfile command, and instead prefer e.g. mpv_command to avoid the need for filename escaping.
For paths passed to suboptions, the situation is further complicated by the need to escape special characters. To work this around, the path can be additionally wrapped in the fixed-length syntax, e.g. %n%string_of_length_n (see above).
Some mpv options interpret paths starting with ~. Currently, the prefix ~~/ expands to the mpv configuration directory (usually ~/.config/mpv/). ~/ expands to the user's home directory. (The trailing / is always required.) There are the following paths as well:
Name | Meaning |
---|---|
~~home/ | same as ~~/ |
~~global/ | the global config path, if available (not on win32) |
~~osxbundle/ | the OSX bundle resource path (OSX only) |
~~desktop/ | the path to the desktop (win32, OSX) |
When playing multiple files, any option given on the command line usually affects all files. Example:
mpv --a file1.mkv --b file2.mkv --c
File | Active options |
---|---|
file1.mkv | --a --b --c |
file2.mkv | --a --b --c |
(This is different from MPlayer and mplayer2.)
Also, if any option is changed at runtime (via input commands), they are not reset when a new file is played.
Sometimes, it is useful to change options per-file. This can be achieved by adding the special per-file markers --{ and --}. (Note that you must escape these on some shells.) Example:
mpv --a file1.mkv --b --\{ --c file2.mkv --d file3.mkv --e --\} file4.mkv --f
File | Active options |
---|---|
file1.mkv | --a --b --f |
file2.mkv | --a --b --f --c --d --e |
file3.mkv | --a --b --f --c --d --e |
file4.mkv | --a --b --f |
Additionally, any file-local option changed at runtime is reset when the current file stops playing. If option --c is changed during playback of file2.mkv, it is reset when advancing to file3.mkv. This only affects file-local options. The option --a is never reset here.
Some options which store lists of option values can have action suffixes. For example, the --display-tags option takes a ,-separated list of tags, but the option also allows you to append a single tag with --display-tags-append, and the tag name can for example contain a literal , without the need for escaping.
String lists are separated by ,. The strings are not parsed or interpreted by the option system itself. However, most
Path or file list options use : (Unix) or ; (Windows) as separator, instead of ,.
They support the following operations:
Suffix | Meaning |
---|---|
-set | Set a list of items (using the list separator, interprets escapes) |
-append | Append single item (does not interpret escapes) |
-add | Append 1 or more items (same syntax as -set) |
-pre | Prepend 1 or more items (same syntax as -set) |
-clr | Clear the option (remove all items) |
-remove | Delete item if present (does not interpret escapes) |
-del | Delete 1 or more items by integer index (deprecated) |
-toggle | Append an item, or remove if if it already exists (no escapes) |
-append is meant as a simple way to append a single item without having to escape the argument (you may still need to escape on the shell level).
A key/value list is a list of key/value string pairs. In programming languages, this type of data structure is often called a map or a dictionary. The order normally does not matter, although in some cases the order might matter.
They support the following operations:
Suffix | Meaning |
---|---|
-set | Set a list of items (using , as separator) |
-append | Append a single item (escapes for the key, no escapes for the value) |
-add | Append 1 or more items (same syntax as -set) |
-remove | Delete item by key if present (does not interpret escapes) |
Keys are unique within the list. If an already present key is set, the existing key is removed before the new value is appended.
This is a very complex option type for the --af and --vf options only. They often require complicated escaping. See VIDEO FILTERS for details. They support the following operations:
Suffix | Meaning |
---|---|
-set | Set a list of filters (using , as separator) |
-append | Append single filter |
-add | Append 1 or more filters (same syntax as -set) |
-pre | Prepend 1 or more filters (same syntax as -set) |
-clr | Clear the option (remove all filters) |
-remove | Delete filter if present |
-del | Delete 1 or more filters by integer index or filter label (deprecated) |
-toggle | Append a filter, or remove if if it already exists |
-help | Pseudo operation that prints a help text to the terminal |
Without suffix, the operation used is normally -set.
Although some operations allow specifying multiple items, using this is strongly discouraged and deprecated, except for -set. There is a chance that operations like -add and -pre will work like -append and accept a single, unescaped item only (so the , separator will not be interpreted and is passed on as part of the value).
Some options (like --sub-file, --audio-file, --glsl-shader) are aliases for the proper option with -append action. For example, --sub-file is an alias for --sub-files-append.
Options of this type can be changed at runtime using the change-list command, which takes the suffix (without the -) as separate operation parameter.
You can put all of the options in configuration files which will be read every time mpv is run. The system-wide configuration file 'mpv.conf' is in your configuration directory (e.g. /etc/mpv or /usr/local/etc/mpv), the user-specific one is ~/.config/mpv/mpv.conf. For details and platform specifics (in particular Windows paths) see the FILES section.
User-specific options override system-wide options and options given on the command line override either. The syntax of the configuration files is option=value. Everything after a # is considered a comment. Options that work without values can be enabled by setting them to yes and disabled by setting them to no. Even suboptions can be specified in this way.
Example configuration file
# Use GPU-accelerated video output by default. vo=gpu # Use quotes for text that can contain spaces: status-msg="Time: ${time-pos}"
This is done like with command line options. The shell is not involved here, but option values still need to be quoted as a whole if it contains certain characters like spaces. A config entry can be quoted with ", as well as with the fixed-length syntax (%n%) mentioned before. This is like passing the exact contents of the quoted string as command line option. C-style escapes are currently _not_ interpreted on this level, although some options do this manually. (This is a mess and should probably be changed at some point.)
Almost all command line options can be put into the configuration file. Here is a small guide:
Option | Configuration file entry |
---|---|
--flag | flag |
-opt val | opt=val |
--opt=val | opt=val |
-opt "has spaces" | opt="has spaces" |
You can also write file-specific configuration files. If you wish to have a configuration file for a file called 'video.avi', create a file named 'video.avi.conf' with the file-specific options in it and put it in ~/.config/mpv/. You can also put the configuration file in the same directory as the file to be played. Both require you to set the --use-filedir-conf option (either on the command line or in your global config file). If a file-specific configuration file is found in the same directory, no file-specific configuration is loaded from ~/.config/mpv. In addition, the --use-filedir-conf option enables directory-specific configuration files. For this, mpv first tries to load a mpv.conf from the same directory as the file played and then tries to load any file-specific configuration.
To ease working with different configurations, profiles can be defined in the configuration files. A profile starts with its name in square brackets, e.g. [my-profile]. All following options will be part of the profile. A description (shown by --profile=help) can be defined with the profile-desc option. To end the profile, start another one or use the profile name default to continue with normal options.
You can list profiles with --profile=help, and show the contents of a profile with --show-profile=<name> (replace <name> with the profile name). You can apply profiles on start with the --profile=<name> option, or at runtime with the apply-profile <name> command.
Example mpv config file with profiles
# normal top-level option fullscreen=yes # a profile that can be enabled with --profile=big-cache [big-cache] cache=yes demuxer-max-bytes=123400KiB demuxer-readahead-secs=20 [slow] profile-desc="some profile name" # reference a builtin profile profile=gpu-hq [fast] vo=vdpau # using a profile again extends it [slow] framedrop=no # you can also include other profiles profile=big-cache
Some profiles are loaded automatically. The following example demonstrates this:
Auto profile loading
[extension.mkv] profile-desc="profile for .mkv files" vf=flip
The profile name follows the schema type.name, where type can be protocol for the input/output protocol in use (see --list-protocols), and extension for the extension of the path of the currently played file (not the file format).
This feature is very limited, and there are no other auto profiles.
There are three choices for using mpv from other programs or scripts:
Calling it as UNIX process. If you do this, do not parse terminal output. The terminal output is intended for humans, and may change any time. In addition, terminal behavior itself may change any time. Compatibility cannot be guaranteed.
Your code should work even if you pass --no-terminal. Do not attempt to simulate user input by sending terminal control codes to mpv's stdin. If you need interactive control, using --input-ipc-server is recommended. This gives you access to the JSON IPC over unix domain sockets (or named pipes on Windows).
Depending on what you do, passing --no-config or --config-dir may be a good idea to avoid conflicts with the normal mpv user configuration intended for CLI playback.
Using --input-ipc-server is also suitable for purposes like remote control (however, the IPC protocol itself is not "secure" and not intended to be so).
Using libmpv. This is generally recommended when mpv is used as playback backend for a completely different application. The provided C API is very close to CLI mechanisms and the scripting API.
Note that even though libmpv has different defaults, it can be configured to work exactly like the CLI player (except command line parsing is unavailable).
As a user script (LUA SCRIPTING, JAVASCRIPT, C PLUGINS). This is recommended when the goal is to "enhance" the CLI player. Scripts get access to the entire client API of mpv.
This is the standard way to create third-party extensions for the player.
All these access the client API, which is the sum of the various mechanisms provided by the player core, as documented here: OPTIONS, List of Input Commands, Properties, List of events (also see C API), Hooks.
Screenshots of the currently played file can be taken using the 'screenshot' input mode command, which is by default bound to the s key. Files named mpv-shotNNNN.jpg will be saved in the working directory, using the first available number - no files will be overwritten. In pseudo-GUI mode, the screenshot will be saved somewhere else. See PSEUDO GUI MODE.
A screenshot will usually contain the unscaled video contents at the end of the video filter chain and subtitles. By default, S takes screenshots without subtitles, while s includes subtitles.
Unlike with MPlayer, the screenshot video filter is not required. This filter was never required in mpv, and has been removed.
During playback, mpv shows the playback status on the terminal. It looks like something like this:
AV: 00:03:12 / 00:24:25 (13%) A-V: -0.000
The status line can be overridden with the --term-status-msg option.
The following is a list of things that can show up in the status line. Input properties, that can be used to get the same information manually, are also listed.
mpv is optimized for normal video playback, meaning it actually tries to buffer as much data as it seems to make sense. This will increase latency. Reducing latency is possible only by specifically disabling features which increase latency.
The builtin low-latency profile tries to apply some of the options which can reduce latency. You can use --profile=low-latency to apply all of them. You can list the contents with --show-profile=low-latency (some of the options are quite obscure, and may change every mpv release).
Be aware that some of the options can reduce playback quality.
Most latency is actually caused by inconvenient timing behavior. You can disable this with --untimed, but it will likely break, unless the stream has no audio, and the input feeds data to the player at a constant rate.
Another common problem is with MJPEG streams. These do not signal the correct framerate. Using --untimed or --no-correct-pts --fps=60 might help.
For livestreams, data can build up due to pausing the stream, due to slightly lower playback rate, or "buffering" pauses. If the demuxer cache is enabled, these can be skipped manually. The experimental drop-buffers command can be used to discard any buffered data, though it's very disruptive.
In some cases, manually tuning TCP buffer sizes and such can help to reduce latency.
Additional options that can be tried:
http://..., https://, ...
Many network protocols are supported, but the protocol prefix must always be specified. mpv will never attempt to guess whether a filename is actually a network address. A protocol prefix is always required.
Note that not all prefixes are documented here. Undocumented prefixes are either aliases to documented protocols, or are just redirections to protocols implemented and documented in FFmpeg.
data: is supported in FFmpeg (not in Libav), but needs to be in the format data://. This is done to avoid ambiguity with filenames. You can also prefix it with lavf:// or ffmpeg://.
ytdl://...
By default, the youtube-dl hook script only looks at http(s) URLs. Prefixing an URL with ytdl:// forces it to be always processed by the script. This can also be used to invoke special youtube-dl functionality like playing a video by ID or invoking search.
Keep in mind that you can't pass youtube-dl command line options by this, and you have to use --ytdl-raw-options instead.
-
Play data from stdin.
smb://PATH
Play a path from Samba share.
bd://[title][/device] --bluray-device=PATH
Play a Blu-ray disc. Since libbluray 1.0.1, you can read from ISO files by passing them to --bluray-device.
title can be: longest or first (selects the default playlist); mpls/<number> (selects <number>.mpls playlist); <number> (select playlist with the same index). mpv will list the available playlists on loading.
bluray:// is an alias.
dvd://[title][/device] --dvd-device=PATH
Play a DVD. DVD menus are not supported. If no title is given, the longest title is auto-selected. Without --dvd-device, it will probably try to open an actual optical drive, if available and implemented for the OS.
dvdnav:// is an old alias for dvd:// and does exactly the same thing.
dvb://[cardnumber@]channel --dvbin-...
Digital TV via DVB. (Linux only.)
mf://[filemask|@listfile] --mf-...
Play a series of images as video.
cdda://[device] --cdrom-device=PATH --cdda-...
Play CD.
lavf://...
Access any FFmpeg/Libav libavformat protocol. Basically, this passed the string after the // directly to libavformat.
av://type:options
This is intended for using libavdevice inputs. type is the libavdevice demuxer name, and options is the (pseudo-)filename passed to the demuxer.
Example
mpv av://v4l2:/dev/video0 --profile=low-latency --untimedThis plays video from the first v4l input with nearly the lowest latency possible. It's a good replacement for the removed tv:// input. Using --untimed is a hack to output a captured frame immediately, instead of respecting the input framerate. (There may be better ways to handle this in the future.)
avdevice:// is an alias.
file://PATH
A local path as URL. Might be useful in some special use-cases. Note that PATH itself should start with a third / to make the path an absolute path.
appending://PATH
Play a local file, but assume it's being appended to. This is useful for example for files that are currently being downloaded to disk. This will block playback, and stop playback only if no new data was appended after a timeout of about 2 seconds.
Using this is still a bit of a bad idea, because there is no way to detect if a file is actually being appended, or if it's still written. If you're trying to play the output of some program, consider using a pipe (something | mpv -). If it really has to be a file on disk, use tail to make it wait forever, e.g. tail -f -c +0 file.mkv | mpv -.
fd://123
Read data from the given file descriptor (for example 123). This is similar to piping data to stdin via -, but can use an arbitrary file descriptor. mpv may modify some file descriptor properties when the stream layer "opens" it.
fdclose://123
Like fd://, but the file descriptor is closed after use. When using this you need to ensure that the same fd URL will only be used once.
edl://[edl specification as in edl-mpv.rst]
Stitch together parts of multiple files and play them.
null://
Simulate an empty file. If opened for writing, it will discard all data. The null demuxer will specifically pass autoprobing if this protocol is used (while it's not automatically invoked for empty files).
memory://data
Use the data part as source data.
hex://data
Like memory://, but the string is interpreted as hexdump.
mpv has no official GUI, other than the OSC (ON SCREEN CONTROLLER), which is not a full GUI and is not meant to be. However, to compensate for the lack of expected GUI behavior, mpv will in some cases start with some settings changed to behave slightly more like a GUI mode.
Currently this happens only in the following cases:
This mode applies options from the builtin profile builtin-pseudo-gui, but only if these haven't been set in the user's config file or on the command line. Also, for compatibility with the old pseudo-gui behavior, the options in the pseudo-gui profile are applied unconditionally. In addition, the profile makes sure to enable the pseudo-GUI mode, so that --profile=pseudo-gui works like in older mpv releases. The profiles are currently defined as follows:
[builtin-pseudo-gui] terminal=no force-window=yes idle=once screenshot-directory=~~desktop/ [pseudo-gui] player-operation-mode=pseudo-gui
Warning
Currently, you can extend the pseudo-gui profile in the config file the normal way. This is deprecated. In future mpv releases, the behavior might change, and not apply your additional settings, and/or use a different profile name.
Specify a priority list of audio languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two-letter language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter language codes, while OGM uses a free-form identifier. See also --aid.
This is a string list option. See List Options for details.
Examples
Specify a priority list of subtitle languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two letter language codes, Matroska uses ISO 639-2 three letter language codes while OGM uses a free-form identifier. See also --sid.
This is a string list option. See List Options for details.
Examples
Equivalent to --alang and --slang, for video tracks.
This is a string list option. See List Options for details.
Select audio track. auto selects the default, no disables audio. See also --alang. mpv normally prints available audio tracks on the terminal when starting playback of a file.
--audio is an alias for --aid.
--aid=no or --audio=no or --no-audio disables audio playback. (The latter variant does not work with the client API.)
Display the subtitle stream specified by <ID>. auto selects the default, no disables subtitles.
--sub is an alias for --sid.
--sid=no or --sub=no or --no-sub disables subtitle decoding. (The latter variant does not work with the client API.)
Select video channel. auto selects the default, no disables video.
--video is an alias for --vid.
--vid=no or --video=no or --no-video disables video playback. (The latter variant does not work with the client API.)
If video is disabled, mpv will try to download the audio only if media is streamed with youtube-dl, because it saves bandwidth. This is done by setting the ytdl_format to "bestaudio/best" in the ytdl_hook.lua script.
Enable the default track auto-selection (default: yes). Enabling this will make the player select streams according to --aid, --alang, and others. If it is disabled, no tracks are selected. In addition, the player will not exit if no tracks are selected, and wait instead (this wait mode is similar to pausing, but the pause option is not set).
This is useful with --lavfi-complex: you can start playback in this mode, and then set select tracks at runtime by setting the filter graph. Note that if --lavfi-complex is set before playback is started, the referenced tracks are always selected.
Seek to given time position.
The general format for times is [+|-][[hh:]mm:]ss[.ms]. If the time is prefixed with -, the time is considered relative from the end of the file (as signaled by the demuxer/the file). A + is usually ignored (but see below).
The following alternative time specifications are recognized:
pp% seeks to percent position pp (0-100).
#c seeks to chapter number c. (Chapters start from 1.)
none resets any previously set option (useful for libmpv).
If --rebase-start-time=no is given, then prefixing times with + makes the time relative to the start of the file. A timestamp without prefix is considered an absolute time, i.e. should seek to a frame with a timestamp as the file contains it. As a bug, but also a hidden feature, putting 1 or more spaces before the + or - always interprets the time as absolute, which can be used to seek to negative timestamps (useful for debugging at most).
Examples
Stop after a given time relative to the start time. See --start for valid option values and examples.
If both --end and --length are provided, playback will stop when it reaches either of the two endpoints.
Obscurity note: this does not work correctly if --rebase-start-time=no, and the specified time is not an "absolute" time, as defined in the --start option description.
Slow down or speed up playback by the factor given as parameter.
If --audio-pitch-correction (on by default) is used, playing with a speed higher than normal automatically inserts the scaletempo audio filter.
Set which file on the internal playlist to start playback with. The index is an integer, with 0 meaning the first file. The value auto means that the selection of the entry to play is left to the playback resume mechanism (default). If an entry with the given index doesn't exist, the behavior is unspecified and might change in future mpv versions. The same applies if the playlist contains further playlists (don't expect any reasonable behavior). Passing a playlist file to mpv should work with this option, though. E.g. mpv playlist.m3u --playlist-start=123 will work as expected, as long as playlist.m3u does not link to further playlists.
The value no is a deprecated alias for auto.
Play files according to a playlist file (Supports some common formats. If no format is detected, it will be treated as list of files, separated by newline characters. Note that XML playlist formats are not supported.)
You can play playlists directly and without this option, however, this option disables any security mechanisms that might be in place. You may also need this option to load plaintext files as playlist.
Warning
The way mpv uses playlist files via --playlist is not safe against maliciously constructed files. Such files may trigger harmful actions. This has been the case for all mpv and MPlayer versions, but unfortunately this fact was not well documented earlier, and some people have even misguidedly recommended use of --playlist with untrusted sources. Do NOT use --playlist with random internet sources or files you do not trust!
Playlist can contain entries using other protocols, such as local files, or (most severely), special protocols like avdevice://, which are inherently unsafe.
Select when to use precise seeks that are not limited to keyframes. Such seeks require decoding video from the previous keyframe up to the target position and so can take some time depending on decoding performance. For some video formats, precise seeks are disabled. This option selects the default choice to use for seeks; it is possible to explicitly override that default in the definition of key bindings and in input commands.
no: | Never use precise seeks. |
---|---|
absolute: | Use precise seeks if the seek is to an absolute position in the file, such as a chapter seek, but not for relative seeks like the default behavior of arrow keys (default). |
yes: | Use precise seeks whenever possible. |
always: | Same as yes (for compatibility). |
Allow the video decoder to drop frames during seek, if these frames are before the seek target. If this is enabled, precise seeking can be faster, but if you're using video filters which modify timestamps or add new frames, it can lead to precise seeking skipping the target frame. This e.g. can break frame backstepping when deinterlacing is enabled.
Default: yes
Controls how to seek in files. Note that if the index is missing from a file, it will be built on the fly by default, so you don't need to change this. But it might help with some broken files.
default: | use an index if the file has one, or build it if missing |
---|---|
recreate: | don't read or use the file's index |
Note
This option only works if the underlying media supports seeking (i.e. not with stdin, pipe, etc).
Load URLs from playlists which are considered unsafe (default: no). This includes special protocols and anything that doesn't refer to normal files. Local files and HTTP links on the other hand are always considered safe.
In addition, if a playlist is loaded while this is set, the added playlist entries are not marked as originating from network or potentially unsafe location. (Instead, the behavior is as if the playlist entries were provided directly to mpv command line or loadfile command.)
Note that --playlist always loads all entries, so you use that instead if you really have the need for this functionality.
Follow any references in the file being opened (default: yes). Disabling this is helpful if the file is automatically scanned (e.g. thumbnail generation). If the thumbnail scanner for example encounters a playlist file, which contains network URLs, and the scanner should not open these, enabling this option will prevent it. This option also disables ordered chapters, mov reference files, opening of archives, and a number of other features.
On older FFmpeg versions, this will not work in some cases. Some FFmpeg demuxers might not respect this option.
This option does not prevent opening of paired subtitle files and such. Use --autoload-files=no to prevent this.
This option does not always work if you open non-files (for example using dvd://directory would open a whole bunch of files in the given directory). Prefixing the filename with ./ if it doesn't start with a / will avoid this.
Loops playback N times. A value of 1 plays it one time (default), 2 two times, etc. inf means forever. no is the same as 1 and disables looping. If several files are specified on command line, the entire playlist is looped. --loop-playlist is the same as --loop-playlist=inf.
The force mode is like inf, but does not skip playlist entries which have been marked as failing. This means the player might waste CPU time trying to loop a file that doesn't exist. But it might be useful for playing webradios under very bad network conditions.
Loop a single file N times. inf means forever, no means normal playback. For compatibility, --loop-file and --loop-file=yes are also accepted, and are the same as --loop-file=inf.
The difference to --loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file.
--loop is an alias for this option.
Set loop points. If playback passes the b timestamp, it will seek to the a timestamp. Seeking past the b point doesn't loop (this is intentional).
If a is after b, the behavior is as if the points were given in the right order, and the player will seek to b after crossing through a. This is different from old behavior, where looping was disabled (and as a bug, looped back to a on the end of the file).
If either options are set to no (or unset), looping is disabled. This is different from old behavior, where an unset a implied the start of the file, and an unset b the end of the file.
The loop-points can be adjusted at runtime with the corresponding properties. See also ab-loop command.
Loads the given file as playlist, and tries to use the files contained in it as reference files when opening a Matroska file that uses ordered chapters. This overrides the normal mechanism for loading referenced files by scanning the same directory the main file is located in.
Useful for loading ordered chapter files that are not located on the local filesystem, or if the referenced files are in different directories.
Note: a playlist can be as simple as a text file containing filenames separated by newlines.
Load chapters from this file, instead of using the chapter metadata found in the main file.
This accepts a media file (like mkv) or even a pseudo-format like ffmetadata and uses its chapters to replace the current file's chapters. This doesn't work with OGM or XML chapters directly.
Skip <sec> seconds after every frame.
Note
Without --hr-seek, skipping will snap to keyframes.
Control the playback direction (default: forward). Setting backward will attempt to play the file in reverse direction, with decreasing playback time. If this is set on playback starts, playback will start from the end of the file. If this is changed at during playback, a hr-seek will be issued to change the direction.
+ and - are aliases for forward and backward.
The rest of this option description pertains to the backward mode.
Note
Backward playback is extremely fragile. It may not always work, is much slower than forward playback, and breaks certain other features. How well it works depends mainly on the file being played. Generally, it will show good results (or results at all) only if the stars align.
mpv, as well as most media formats, were designed for forward playback only. Backward playback is bolted on top of mpv, and tries to make a medium effort to make backward playback work. Depending on your use-case, another tool may work much better.
Backward playback is not exactly a 1st class feature. Implementation tradeoffs were made, that are bad for backward playback, but in turn do not cause disadvantages for normal playback. Various possible optimizations are not implemented in order to keep the complexity down. Normally, a media player is highly pipelined (future data is prepared in separate threads, so it is available in realtime when the next stage needs it), but backward playback will essentially stall the pipeline at various random points.
For example, for intra-only codecs are trivially backward playable, and tools built around them may make efficient use of them (consider video editors or camera viewers). mpv won't be efficient in this case, because it uses its generic backward playback algorithm, that on top of it is not very optimized.
If you just want to quickly go backward through the video and just show "keyframes", just use forward playback, and hold down the left cursor key (which on CLI with default config sends many small relative seek commands).
The implementation consists of mostly 3 parts:
Known problems:
Tuning:
For backward decoding. Backward decoding decodes forward in steps, and then reverses the decoder output. These options control the approximate maximum amount of bytes that can be buffered. The main use of this is to avoid unbounded resource usage; during normal backward playback, it's not supposed to hit the limit, and if it does, it will drop frames and complain about it.
Use this option if you get reversal queue overflow errors during backward playback. Increase the size until the warning disappears. Usually, the video buffer will overflow first, especially if it's high resolution video.
This does not work correctly if video hardware decoding is used. The video frame size will not include the referenced GPU and driver memory. Some hardware decoders may also be limited by --hwdec-extra-frames.
How large the queue size needs to be depends entirely on the way the media was encoded. Audio typically requires a very small buffer, while video can require excessively large buffers.
(Technically, this allows the last frame to exceed the limit. Also, this does not account for other buffered frames, such as inside the decoder or the video output.)
This does not affect demuxer cache behavior at all.
See --list-options for defaults and value range. <bytesize> options accept suffixes such as KiB and MiB.
Number of overlapping keyframe ranges to use for backward decoding (default: auto) ("keyframe" to be understood as in the mpv/ffmpeg specific meaning). Backward decoding works by forward decoding in small steps. Some codecs cannot restart decoding from any packet (even if it's marked as seek point), which becomes noticeable with backward decoding (in theory this is a problem with seeking too, but --hr-seek-demuxer-offset can fix it for seeking). In particular, MDCT based audio codecs are affected.
The solution is to feed a previous packet to the decoder each time, and then discard the output. This option controls how many packets to feed. The auto choice is currently hardcoded to 0 for video, and uses 1 for lossy audio, 0 for lossless audio. For some specific lossy audio codecs, this is set to 2.
--video-backward-overlap can potentially handle intra-refresh video, depending on the exact conditions. You may have to use the --vd-lavc-show-all option as well.
Number of keyframe ranges to decode at once when backward decoding (default: 1 for video, 10 for audio). Another pointless tuning parameter nobody should use. This should affect performance only. In theory, setting a number higher than 1 for audio will reduce overhead due to less frequent backstep operations and less redundant decoding work due to fewer decoded overlap frames (see --audio-backward-overlap). On the other hand, it requires a larger reversal buffer, and could make playback less smooth due to breaking pipelining (e.g. by decoding a lot, and then doing nothing for a while).
It probably never makes sense to set --video-backward-batch. But in theory, it could help with intra-only video codecs by reducing backstep operations.
Number of seconds the demuxer should seek back to get new packets during backward playback (default: 60). This is useful for tuning backward playback, see --play-dir for details.
Setting this to a very low value or 0 may make the player think seeking is broken, or may make it perform multiple seeks.
Setting this to a high value may lead to quadratic runtime behavior.
Show short summary of options.
You can also pass a string to this option, which will list all top-level options which contain the string in the name, e.g. --h=scale for all options that contain the word scale. The special string * lists all top-level options.
Do not load default configuration files. This prevents loading of both the user-level and system-wide mpv.conf and input.conf files. Other configuration files are blocked as well, such as resume playback files.
Note
Files explicitly requested by command line options, like --include or --use-filedir-conf, will still be loaded.
See also: --config-dir.
Force a different configuration directory. If this is set, the given directory is used to load configuration files, and all other configuration directories are ignored. This means the global mpv configuration directory as well as per-user directories are ignored, and overrides through environment variables (MPV_HOME) are also ignored.
Note that the --no-config option takes precedence over this option.
Always save the current playback position on quit. When this file is played again later, the player will seek to the old playback position on start. This does not happen if playback of a file is stopped in any other way than quitting. For example, going to the next file in the playlist will not save the position, and start playback at beginning the next time the file is played.
This behavior is disabled by default, but is always available when quitting the player with Shift+Q.
The directory in which to store the "watch later" temporary files.
The default is a subdirectory named "watch_later" underneath the config directory (usually ~/.config/mpv/).
Write certain statistics to the given file. The file is truncated on opening. The file will contain raw samples, each with a timestamp. To make this file into a readable, the script TOOLS/stats-conv.py can be used (which currently displays it as a graph).
This option is useful for debugging only.
Makes mpv wait idly instead of quitting when there is no file to play. Mostly useful in input mode, where mpv can be controlled through input commands. (Default: no)
once will only idle at start and let the player close once the first playlist has finished playing back.
Load a Lua script. The second option allows you to load multiple scripts by separating them with the path separator (: on Unix, ; on Windows).
--scripts is a path list option. See List Options for details.
Set options for scripts. A script can query an option by key. If an option is used and what semantics the option value has depends entirely on the loaded scripts. Values not claimed by any scripts are ignored.
This is a key/value list option. See List Options for details.
Normally, mpv will try to keep all settings when playing the next file on the playlist, even if they were changed by the user during playback. (This behavior is the opposite of MPlayer's, which tries to reset all settings when starting next file.)
Default: Do not reset anything.
This can be changed with this option. It accepts a list of options, and mpv will reset the value of these options on playback start to the initial value. The initial value is either the default value, or as set by the config file or command line.
In some cases, this might not work as expected. For example, --volume will only be reset if it is explicitly set in the config file or the command line.
The special name all resets as many options as possible.
This is a string list option. See List Options for details.
Examples
Prepend the watch later config files with the name of the file they refer to. This is simply written as comment on the top of the file.
Warning
This option may expose privacy-sensitive information and is thus disabled by default.
Look for a file-specific configuration file in the same directory as the file that is being played. See File-specific Configuration Files.
Warning
May be dangerous if playing from untrusted media.
Enable the youtube-dl hook-script. It will look at the input URL, and will play the video located on the website. This works with many streaming sites, not just the one that the script is named after. This requires a recent version of youtube-dl to be installed on the system. (Enabled by default.)
If the script can't do anything with an URL, it will do nothing.
The try_ytdl_first script option accepts a boolean 'yes' or 'no', and if 'yes' will try parsing the URL with youtube-dl first, instead of the default where it's only after mpv failed to open it. This mostly depends on whether most of your URLs need youtube-dl parsing.
The exclude script option accepts a |-separated list of URL patterns which mpv should not use with youtube-dl. The patterns are matched after the http(s):// part of the URL.
^ matches the beginning of the URL, $ matches its end, and you should use % before any of the characters ^$()%|,.[]*+-? to match that character.
Examples
See more lua patterns here: https://www.lua.org/manual/5.1/manual.html#5.4.1
The use_manifests script option makes mpv use the master manifest URL for formats like HLS and DASH, if available, allowing for video/audio selection in runtime. It's disabled ("no") by default for performance reasons.
Pass arbitrary options to youtube-dl. Parameter and argument should be passed as a key-value pair. Options without argument must include =.
There is no sanity checking so it's possible to break things (i.e. passing invalid parameters to youtube-dl).
A proxy URL can be passed for youtube-dl to use it in parsing the website. This is useful for geo-restricted URLs. After youtube-dl parsing, some URLs also require a proxy for playback, so this can pass that proxy information to mpv. Take note that SOCKS proxies aren't supported and https URLs also bypass the proxy. This is a limitation in FFmpeg.
This is a key/value list option. See List Options for details.
Example
Specify a priority list of video decoders to be used, according to their family and name. See --ad for further details. Both of these options use the same syntax and semantics; the only difference is that they operate on different codec lists.
Note
See --vd=help for a full list of available decoders.
Skip displaying some frames to maintain A/V sync on slow systems, or playing high framerate video on video outputs that have an upper framerate limit.
The argument selects the drop methods, and can be one of the following:
Drop late frames on video output (default). This still decodes and filters all frames, but doesn't render them on the VO. Drops are indicated in the terminal status line as Dropped: field.
In audio sync. mode, this drops frames that are outdated at the time of display. If the decoder is too slow, in theory all frames would have to be dropped (because all frames are too late) - to avoid this, frame dropping stops if the effective framerate is below 10 FPS.
In display-sync. modes (see --video-sync), this affects only how A/V drops or repeats frames. If this mode is disabled, A/V desync will in theory not affect video scheduling anymore (much like the display-resample-desync mode). However, even if disabled, frames will still be skipped (i.e. dropped) according to the ratio between video and display frequencies.
This is the recommended mode, and the default.
Old, decoder-based framedrop mode. (This is the same as --framedrop=yes in mpv 0.5.x and before.) This tells the decoder to skip frames (unless they are needed to decode future frames). May help with slow systems, but can produce unwatchable choppy output, or even freeze the display completely.
This uses a heuristic which may not make sense, and in general cannot achieve good results, because the decoder's frame dropping cannot be controlled in a predictable manner. Not recommended.
Even if you want to use this, prefer decoder+vo for better results.
The --vd-lavc-framedrop option controls what frames to drop.
Note
--vo=vdpau has its own code for the vo framedrop mode. Slight differences to other VOs are possible.
Enable some things which tend to reduce video latency by 1 or 2 frames (default: no). Note that this option might be removed without notice once the player's timing code does not inherently need to do these things anymore.
This does:
Set the display FPS used with the --video-sync=display-* modes. By default, a detected value is used. Keep in mind that setting an incorrect value (even if slightly incorrect) can ruin video playback. On multi-monitor systems, there is a chance that the detected value is from the wrong monitor.
Set this option only if you have reason to believe the automatically determined value is wrong.
Specify the hardware video decoding API that should be used if possible. Whether hardware decoding is actually done depends on the video codec. If hardware decoding is not possible, mpv will fall back on software decoding.
Hardware decoding is not enabled by default, because it is typically an additional source of errors. It is worth using only if your CPU is too slow to decode a specific video.
Note
Use the Ctrl+h shortcut to toggle hardware decoding at runtime. It toggles this option between auto and no.
Always enabling HW decoding by putting it into the config file is discouraged. If you use the Ubuntu package, delete /etc/mpv/mpv.conf, as the package tries to enable HW decoding by default by setting hwdec=vaapi (which is less than ideal, and may even cause sub-optimal wrappers to be used). Or at least change it to hwdec=auto-safe.
Use one of the auto modes if you want to enable hardware decoding. Explicitly selecting the mode is mostly meant for testing and debugging. It's a bad idea to put explicit selection into the config file if you want thing to just keep working after updates and so on.
Note
Even if enabled, hardware decoding is still only white-listed for some codecs. See --hwdec-codecs to enable hardware decoding in more cases.
Which method to choose?
<api> can be one of the following:
no: | always use software decoding (default) |
---|---|
auto: | forcibly enable any hw decoder found (see below) |
yes: | exactly the same as auto |
auto-safe: | enable any whitelisted hw decoder (see below) |
auto-copy: | enable best hw decoder with copy-back (see below) |
vdpau: | requires --vo=gpu with X11, or --vo=vdpau (Linux only) |
vdpau-copy: | copies video back into system RAM (Linux with some GPUs only) |
vaapi: | requires --vo=gpu or --vo=vaapi (Linux only) |
vaapi-copy: | copies video back into system RAM (Linux with some GPUs only) |
videotoolbox: | requires --vo=gpu (OS X 10.8 and up), or --vo=libmpv (iOS 9.0 and up) |
videotoolbox-copy: | |
copies video back into system RAM (OS X 10.8 or iOS 9.0 and up) | |
dxva2: | requires --vo=gpu with --gpu-context=d3d11, --gpu-context=angle or --gpu-context=dxinterop (Windows only) |
dxva2-copy: | copies video back to system RAM (Windows only) |
d3d11va: | requires --vo=gpu with --gpu-context=d3d11 or --gpu-context=angle (Windows 8+ only) |
d3d11va-copy: | copies video back to system RAM (Windows 8+ only) |
mediacodec: | requires --vo=mediacodec_embed (Android only) |
mediacodec-copy: | |
copies video back to system RAM (Android only) | |
mmal: | requires --vo=gpu (Raspberry Pi only - default if available) |
mmal-copy: | copies video back to system RAM (Raspberry Pi only) |
nvdec: | requires --vo=gpu (Any platform CUDA is available) |
nvdec-copy: | copies video back to system RAM (Any platform CUDA is available) |
cuda: | requires --vo=gpu (Any platform CUDA is available) |
cuda-copy: | copies video back to system RAM (Any platform CUDA is available) |
crystalhd: | copies video back to system RAM (Any platform supported by hardware) |
rkmpp: | requires --vo=gpu (some RockChip devices only) |
auto tries to automatically enable hardware decoding using the first available method. This still depends what VO you are using. For example, if you are not using --vo=gpu or --vo=vdpau, vdpau decoding will never be enabled. Also note that if the first found method doesn't actually work, it will always fall back to software decoding, instead of trying the next method (might matter on some Linux systems).
auto-safe is similar to auto, but allows only whitelisted methods that are considered "safe". This is supposed to be a reasonable way to enable hardware decdoding by default in a config file (even though you shouldn't do that anyway; prefer runtime enabling with Ctrl+h). Unlike auto, this will not try to enable unknown or known-to-be-bad methods. In addition, this may disable hardware decoding in other situations when it's known to cause problems, but currently this mechanism is quite primitive. (As an example for something that still causes problems: certain combinations of HEVC and Intel chips on Windows tend to cause mpv to crash, most likely due to driver bugs.)
auto-copy-safe selects the union of methods selected with auto-safe and auto-copy.
auto-copy selects only modes that copy the video data back to system memory after decoding. This selects modes like vaapi-copy (and so on). If none of these work, hardware decoding is disabled. This mode is usually guaranteed to incur no additional quality loss compared to software decoding (assuming modern codecs and an error free video stream), and will allow CPU processing with video filters. This mode works with all video filters and VOs.
Because these copy the decoded video back to system RAM, they're often less efficient than the direct modes, and may not help too much over software decoding.
Note
Most non-copy methods only work with the OpenGL GPU backend. Currently, only the vaapi, nvdec and cuda methods work with Vulkan.
The vaapi mode, if used with --vo=gpu, requires Mesa 11, and most likely works with Intel and AMD GPUs only. It also requires the opengl EGL backend.
nvdec and nvdec-copy are the newest, and recommended method to do hardware decoding on Nvidia GPUs.
cuda and cuda-copy are an older implementation of hardware decoding on Nvidia GPUs that uses Nvidia's bitstream parsers rather than FFmpeg's. This can lead to feature deficiencies, such as incorrect playback of HDR content, and nvdec/nvdec-copy should always be preferred unless you specifically need Nvidia's deinterlacing algorithms. To use this deinterlacing you must pass the option: vd-lavc-o=deint=[weave|bob|adaptive]. Pass weave (or leave the option unset) to not attempt any deinterlacing.
Quality reduction with hardware decoding
In theory, hardware decoding does not reduce video quality (at least for the codecs h264 and HEVC). However, due to restrictions in video output APIs, as well as bugs in the actual hardware decoders, there can be some loss, or even blatantly incorrect results.
In some cases, RGB conversion is forced, which means the RGB conversion is performed by the hardware decoding API, instead of the shaders used by --vo=gpu. This means certain colorspaces may not display correctly, and certain filtering (such as debanding) cannot be applied in an ideal way. This will also usually force the use of low quality chroma scalers instead of the one specified by --cscale. In other cases, hardware decoding can also reduce the bit depth of the decoded image, which can introduce banding or precision loss for 10-bit files.
vdpau always does RGB conversion in hardware, which does not support newer colorspaces like BT.2020 correctly. However, vdpau doesn't support 10 bit or HDR encodings, so these limitations are unlikely to be relevant.
vaapi and d3d11va are safe. Enabling deinterlacing (or simply their respective post-processing filters) will possibly at least reduce color quality by converting the output to a 8 bit format.
dxva2 is not safe. It appears to always use BT.601 for forced RGB conversion, but actual behavior depends on the GPU drivers. Some drivers appear to convert to limited range RGB, which gives a faded appearance. In addition to driver-specific behavior, global system settings might affect this additionally. This can give incorrect results even with completely ordinary video sources.
rpi always uses the hardware overlay renderer, even with --vo=gpu.
cuda should usually be safe, but depending on how a file/stream has been mixed, it has been reported to corrupt the timestamps causing glitched, flashing frames. It can also sometimes cause massive framedrops for unknown reasons. Caution is advised, and nvdec should always be preferred.
crystalhd is not safe. It always converts to 4:2:2 YUV, which may be lossy, depending on how chroma sub-sampling is done during conversion. It also discards the top left pixel of each frame for some reason.
All other methods, in particular the copy-back methods (like dxva2-copy etc.) should hopefully be safe, although they can still cause random decoding issues. At the very least, they shouldn't affect the colors of the image.
In particular, auto-copy will only select "safe" modes (although potentially slower than other methods), but there's still no guarantee the chosen hardware decoder will actually work correctly.
In general, it's very strongly advised to avoid hardware decoding unless absolutely necessary, i.e. if your CPU is insufficient to decode the file in questions. If you run into any weird decoding issues, frame glitches or discoloration, and you have --hwdec turned on, the first thing you should try is disabling it.
This option is for troubleshooting hwdec interop issues. Since it's a debugging option, its semantics may change at any time.
This is useful for the gpu and libmpv VOs for selecting which hwdec interop context to use exactly. Effectively it also can be used to block loading of certain backends.
If set to auto (default), the behavior depends on the VO: for gpu, it does nothing, and the interop context is loaded on demand (when the decoder probes for --hwdec support). For libmpv, which has has no on-demand loading, this is equivalent to all.
The empty string is equivalent to auto.
If set to all, it attempts to load all interop contexts at GL context creation time.
Other than that, a specific backend can be set, and the list of them can be queried with help (mpv CLI only).
Runtime changes to this are ignored (the current option value is used whenever the renderer is created).
The old aliases --opengl-hwdec-interop and --hwdec-preload are barely related to this anymore, but will be somewhat compatible in some cases.
Number of GPU frames hardware decoding should preallocate (default: see --list-options output). If this is too low, frame allocation may fail during decoding, and video frames might get dropped and/or corrupted. Setting it too high simply wastes GPU memory and has no advantages.
This value is used only for hardware decoding APIs which require preallocating surfaces (known examples include d3d11va and vaapi). For other APIs, frames are allocated as needed. The details depend on the libavcodec implementations of the hardware decoders.
The required number of surfaces depends on dynamic runtime situations. The default is a fixed value that is thought to be sufficient for most uses. But in certain situations, it may not be enough.
Set the internal pixel format used by hardware decoding via --hwdec (default no). The special value no selects an implementation specific standard format. Most decoder implementations support only one format, and will fail to initialize if the format is not supported.
Some implementations might support multiple formats. In particular, videotoolbox is known to require uyvy422 for good performance on some older hardware. d3d11va can always use yuv420p, which uses an opaque format, with likely no advantages.
Choose the GPU device used for decoding when using the cuda or nvdec hwdecs with the OpenGL GPU backend, and with the cuda-copy or nvdec-copy hwdecs in all cases.
For the OpenGL GPU backend, the default device used for decoding is the one being used to provide gpu output (and in the vast majority of cases, only one GPU will be present).
For the copy hwdecs, the default device will be the first device enumerated by the CUDA libraries - however that is done.
For the Vulkan GPU backend, decoding must always happen on the display device, and this option has no effect.
Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9 video to make it fit a 4:3 display without black bands). The range controls how much of the image is cropped. May not work with all video output drivers.
This option has no effect if --video-unscaled option is used.
Override video aspect ratio, in case aspect information is incorrect or missing in the file being played.
These values have special meaning:
0: | disable aspect ratio handling, pretend the video has square pixels |
---|---|
no: | same as 0 |
-1: | use the video stream or container aspect (default) |
But note that handling of these special values might change in the future.
Examples
This sets the default video aspect determination method (if the aspect is _not_ overridden by the user with --video-aspect-override or others).
container: | Strictly prefer the container aspect ratio. This is apparently the default behavior with VLC, at least with Matroska. Note that if the container has no aspect ratio set, the behavior is the same as with bitstream. |
---|---|
bitstream: | Strictly prefer the bitstream aspect ratio, unless the bitstream aspect ratio is not set. This is apparently the default behavior with XBMC/kodi, at least with Matroska. |
The current default for mpv is container.
Normally you should not set this. Try the various choices if you encounter video that has the wrong aspect ratio in mpv, but seems to be correct in other players.
Disable scaling of the video. If the window is larger than the video, black bars are added. Otherwise, the video is cropped, unless the option is set to downscale-big, in which case the video is fit to window. The video still can be influenced by the other --video-... options. This option disables the effect of --panscan.
Note that the scaler algorithm may still be used, even if the video isn't scaled. For example, this can influence chroma conversion. The video will also still be scaled in one dimension if the source uses non-square pixels (e.g. anamorphic widescreen DVDs).
This option is disabled if the --no-keepaspect option is used.
Moves the displayed video rectangle by the given value in the X or Y direction. The unit is in fractions of the size of the scaled video (the full size, even if parts of the video are not visible due to panscan or other options).
For example, displaying a 1280x720 video fullscreen on a 1680x1050 screen with --video-pan-x=-0.1 would move the video 168 pixels to the left (making 128 pixels of the source video invisible).
This option is disabled if the --no-keepaspect option is used.
Adjust the video display scale factor by the given value. The parameter is given log 2. For example, --video-zoom=0 is unscaled, --video-zoom=1 is twice the size, --video-zoom=-2 is one fourth of the size, and so on.
This option is disabled if the --no-keepaspect option is used.
Moves the video rectangle within the black borders, which are usually added to pad the video to screen if video and screen aspect ratios are different. --video-align-y=-1 would move the video to the top of the screen (leaving a border only on the bottom), a value of 0 centers it (default), and a value of 1 would put the video at the bottom of the screen.
If video and screen aspect match perfectly, these options do nothing.
This option is disabled if the --no-keepaspect option is used.
Set extra video margins on each border (default: 0). Each value is a ratio of the window size, using a range 0.0-1.0. For example, setting the option --video-margin-ratio-right=0.2 at a window size of 1000 pixels will add a 200 pixels border on the right side of the window.
The video is "boxed" by these margins. The window size is not changed. In particular it does not enlarge the window, and the margins will cause the video to be downscaled by default. This may or may not change in the future.
The margins are applied after 90° video rotation, but before any other video transformations.
This option is disabled if the --no-keepaspect option is used.
Subtitles still may use the margins, depending on --sub-use-margins and similar options.
These options were created for the OSC. Some odd decisions, such as making the margin values a ratio (instead of pixels), were made for the sake of the OSC. It's possible that these options may be replaced by ones that are more generally useful. The behavior of these options may change to fit OSC requirements better, too.
Override video framerate. Useful if the original value is wrong or missing.
Note
Works in --no-correct-pts mode only.
Enable or disable interlacing (default: no). Interlaced video shows ugly comb-like artifacts, which are visible on fast movement. Enabling this typically inserts the yadif video filter in order to deinterlace the video, or lets the video output apply deinterlacing if supported.
This behaves exactly like the deinterlace input property (usually mapped to d).
Keep in mind that this will conflict with manually inserted deinterlacing filters, unless you take care. (Since mpv 0.27.0, even the hardware deinterlace filters will conflict. Also since that version, --deinterlace=auto was removed, which used to mean that the default interlacing option of possibly inserted video filters was used.)
Note that this will make video look worse if it's not actually interlaced.
Play/convert only first <number> video frames, then quit.
--frames=0 loads the file, but immediately quits before initializing playback. (Might be useful for scripts which just want to determine some file properties.)
For audio-only playback, any value greater than 0 will quit playback immediately after initialization. The value 0 works as with video.
RGB color levels used with YUV to RGB conversion. Normally, output devices such as PC monitors use full range color levels. However, some TVs and video monitors expect studio RGB levels. Providing full range output to a device expecting studio level input results in crushed blacks and whites, the reverse in dim gray blacks and dim whites.
Not all VOs support this option. Some will silently ignore it.
Available color ranges are:
auto: | automatic selection (equals to full range) (default) |
---|---|
limited: | limited range (16-235 per component), studio levels |
full: | full range (0-255 per component), PC levels |
Note
It is advisable to use your graphics driver's color range option instead, if available.
Allow hardware decoding for a given list of codecs only. The special value all always allows all codecs.
You can get the list of allowed codecs with mpv --vd=help. Remove the prefix, e.g. instead of lavc:h264 use h264.
By default, this is set to h264,vc1,hevc,vp9. Note that the hardware acceleration special codecs like h264_vdpau are not relevant anymore, and in fact have been removed from Libav in this form.
This is usually only needed with broken GPUs, where a codec is reported as supported, but decoding causes more problems than it solves.
Example
Fallback to software decoding if the hardware-accelerated decoder fails (default: 3). If this is a number, then fallback will be triggered if N frames fail to decode in a row. 1 is equivalent to yes.
Setting this to a higher number might break the playback start fallback: if a fallback happens, parts of the file will be skipped, approximately by to the number of packets that could not be decoded. Values below an unspecified count will not have this problem, because mpv retains the packets.
Enable direct rendering (default: yes). If this is set to yes, the video will be decoded directly to GPU video memory (or staging buffers). This can speed up video upload, and may help with large resolutions or slow hardware. This works only with the following VOs:
- gpu: requires at least OpenGL 4.4 or Vulkan.
(In particular, this can't be made work with opengl-cb, but the libmpv render API has optional support.)
Using video filters of any kind that write to the image data (or output newly allocated frames) will silently disable the DR code path.
Pass AVOptions to libavcodec decoder. Note, a patch to make the o= unneeded and pass all unknown options through the AVOption system is welcome. A full list of AVOptions can be found in the FFmpeg manual.
Some options which used to be direct options can be set with this mechanism, like bug, gray, idct, ec, vismv, skip_top (was st), skip_bottom (was sb), debug.
This is a key/value list option. See List Options for details.
Example
--vd-lavc-o=debug=pict
Skips the loop filter (AKA deblocking) during H.264 decoding. Since the filtered frame is supposed to be used as reference for decoding dependent frames, this has a worse effect on quality than not doing deblocking on e.g. MPEG-2 video. But at least for high bitrate HDTV, this provides a big speedup with little visible quality loss.
<skipvalue> can be one of the following:
none: | Never skip. |
---|---|
default: | Skip useless processing steps (e.g. 0 size packets in AVI). |
nonref: | Skip frames that are not referenced (i.e. not used for decoding other frames, the error cannot "build up"). |
bidir: | Skip B-Frames. |
nonkey: | Skip all frames except keyframes. |
all: | Skip all frames. |
Use the given audio device. This consists of the audio output name, e.g. alsa, followed by /, followed by the audio output specific device name. The default value for this option is auto, which tries every audio output in preference order with the default device.
You can list audio devices with --audio-device=help. This outputs the device name in quotes, followed by a description. The device name is what you have to pass to the --audio-device option. The list of audio devices can be retrieved by API by using the audio-device-list property.
While the option normally takes one of the strings as indicated by the methods above, you can also force the device for most AOs by building it manually. For example name/foobar forces the AO name to use the device foobar. However, the --ao option will strictly force a specific AO. To avoid confusion, don't use --ao and --audio-device together.
Example for ALSA
MPlayer and mplayer2 required you to replace any ',' with '.' and any ':' with '=' in the ALSA device name. For example, to use the device named dmix:default, you had to do:
-ao alsa:device=dmix=default
In mpv you could instead use:
--audio-device=alsa/dmix:default
Enable exclusive output mode. In this mode, the system is usually locked out, and only mpv will be able to output audio.
This only works for some audio outputs, such as wasapi and coreaudio. Other audio outputs silently ignore this options. They either have no concept of exclusive mode, or the mpv side of the implementation is missing.
List of codecs for which compressed audio passthrough should be used. This works for both classic S/PDIF and HDMI.
Possible codecs are ac3, dts, dts-hd, eac3, truehd. Multiple codecs can be specified by separating them with ,. dts refers to low bitrate DTS core, while dts-hd refers to DTS MA (receiver and OS support varies). If both dts and dts-hd are specified, it behaves equivalent to specifying dts-hd only.
In earlier mpv versions you could use --ad to force the spdif wrapper. This does not work anymore.
Warning
There is not much reason to use this. HDMI supports uncompressed multichannel PCM, and mpv supports lossless DTS-HD decoding via FFmpeg's new DCA decoder (based on libdcadec).
Specify a priority list of audio decoders to be used, according to their decoder name. When determining which decoder to use, the first decoder that matches the audio format is selected. If that is unavailable, the next decoder is used. Finally, it tries all other decoders that are not explicitly selected or rejected by the option.
- at the end of the list suppresses fallback on other available decoders not on the --ad list. + in front of an entry forces the decoder. Both of these should not normally be used, because they break normal decoder auto-selection! Both of these methods are deprecated.
Examples
Warning
Enabling compressed audio passthrough (AC3 and DTS via SPDIF/HDMI) with this option is not possible. Use --audio-spdif instead.
Set the startup volume. 0 means silence, 100 means no volume reduction or amplification. Negative values can be passed for compatibility, but are treated as 0.
Since mpv 0.18.1, this always controls the internal mixer (aka "softvol").
Set startup audio mute status (default: no).
auto is a deprecated possible value that is equivalent to no.
See also: --volume.
Deprecated/unfunctional. Before mpv 0.18.1, this used to control whether to use the volume controls of the audio output driver or the internal mpv volume filter.
The current behavior is that softvol is always enabled, i.e. as if this option is set to yes. The other behaviors are not available anymore, although auto almost matches current behavior in most cases.
The no behavior is still partially available through the ao-volume and ao-mute properties. But there are no options to reset these.
Select the Dynamic Range Compression level for AC-3 audio streams. <level> is a float value ranging from 0 to 1, where 0 means no compression (which is the default) and 1 means full compression (make loud passages more silent and vice versa). Values up to 6 are also accepted, but are purely experimental. This option only shows an effect if the AC-3 stream contains the required range compression information.
The standard mandates that DRC is enabled by default, but mpv (and some other players) ignore this for the sake of better audio quality.
Pass AVOptions to libavcodec decoder. Note, a patch to make the o= unneeded and pass all unknown options through the AVOption system is welcome. A full list of AVOptions can be found in the FFmpeg manual.
This is a key/value list option. See List Options for details.
If DTS is passed through, use DTS-HD.
Warning
This and enabling passthrough via --ad are deprecated in favor of using --audio-spdif=dts-hd.
Control which audio channels are output (e.g. surround vs. stereo). There are the following possibilities:
Use the system's preferred channel layout. If there is none (such as when accessing a hardware device instead of the system mixer), force stereo. Some audio outputs might simply accept any layout and do downmixing on their own.
This is the default.
Send the audio device whatever it accepts, preferring the audio's original channel layout. Can cause issues with HDMI (see the warning below).
List of ,-separated channel layouts which should be allowed. Technically, this only adjusts the filter chain output to the best matching layout in the list, and passes the result to the audio API. It's possible that the audio API will select a different channel layout.
Using this mode is recommended for direct hardware output, especially over HDMI (see HDMI warning below).
Force a plain stereo downmix. This is a special-case of the previous item. (See paragraphs below for implications.)
If a list of layouts is given, each item can be either an explicit channel layout name (like 5.1), or a channel number. Channel numbers refer to default layouts, e.g. 2 channels refer to stereo, 6 refers to 5.1.
See --audio-channels=help output for defined default layouts. This also lists speaker names, which can be used to express arbitrary channel layouts (e.g. fl-fr-lfe is 2.1).
If the list of channel layouts has only 1 item, the decoder is asked to produce according output. This sometimes triggers decoder-downmix, which might be different from the normal mpv downmix. (Only some decoders support remixing audio, like AC-3, AAC or DTS. You can use --ad-lavc-downmix=no to make the decoder always output its native layout.) One consequence is that --audio-channels=stereo triggers decoder downmix, while auto or auto-safe never will, even if they end up selecting stereo. This happens because the decision whether to use decoder downmix happens long before the audio device is opened.
If the channel layout of the media file (i.e. the decoder) and the AO's channel layout don't match, mpv will attempt to insert a conversion filter. You may need to change the channel layout of the system mixer to achieve your desired output as mpv does not have control over it. Another work-around for this on some AOs is to use --audio-exclusive=yes to circumvent the system mixer entirely.
Warning
Using auto can cause issues when using audio over HDMI. The OS will typically report all channel layouts that _can_ go over HDMI, even if the receiver does not support them. If a receiver gets an unsupported channel layout, random things can happen, such as dropping the additional channels, or adding noise.
You are recommended to set an explicit whitelist of the layouts you want. For example, most A/V receivers connected via HDMI and that can do 7.1 would be served by: --audio-channels=7.1,5.1,stereo
Setting this option to attachment (default) will display image attachments (e.g. album cover art) when playing audio files. It will display the first image found, and additional images are available as video tracks.
Setting this option to no disables display of video entirely when playing audio files.
This option has no influence on files with normal video tracks.
Play audio from an external file while viewing a video.
This is a path list option. See List Options for details.
Try to play consecutive audio files with no silence or disruption at the point of file change. Default: weak.
no: | Disable gapless audio. |
---|---|
yes: | The audio device is opened using parameters chosen for the first file played and is then kept open for gapless playback. This means that if the first file for example has a low sample rate, then the following files may get resampled to the same low sample rate, resulting in reduced sound quality. If you play files with different parameters, consider using options such as --audio-samplerate and --audio-format to explicitly select what the shared output format will be. |
weak: | Normally, the audio device is kept open (using the format it was first initialized with). If the audio format the decoder output changes, the audio device is closed and reopened. This means that you will normally get gapless audio with files that were encoded using the same settings, but might not be gapless in other cases. The exact conditions under which the audio device is kept open is an implementation detail, and can change from version to version. Currently, the device is kept even if the sample format changes, but the sample formats are convertible. If video is still going on when there is still audio, trying to use gapless is also explicitly given up. |
Note
This feature is implemented in a simple manner and relies on audio output device buffering to continue playback while moving from one file to another. If playback of the new file starts slowly, for example because it is played from a remote network location or because you have specified cache settings that require time for the initial cache fill, then the buffered audio may run out before playback of the new file can start.
Set the maximum amplification level in percent (default: 130). A value of 130 will allow you to adjust the volume up to about double the normal level.
--softvol-max is a deprecated alias and should not be used.
Load additional audio files matching the video filename. The parameter specifies how external audio files are matched.
no: | Don't automatically load external audio files (default). |
---|---|
exact: | Load the media filename with audio file extension. |
fuzzy: | Load all audio files containing media filename. |
all: | Load all audio files in the current and --audio-file-paths directories. |
Equivalent to --sub-file-paths option, but for auto-loaded audio files.
This is a path list option. See List Options for details.
Set the audio output minimum buffer. The audio device might actually create a larger buffer if it pleases. If the device creates a smaller buffer, additional audio is buffered in an additional software buffer.
Making this larger will make soft-volume and other filters react slower, introduce additional issues on playback speed change, and block the player on audio format changes. A smaller buffer might lead to audio dropouts.
This option should be used for testing only. If a non-default value helps significantly, the mpv developers should be contacted.
Default: 0.2 (200 ms).
Cash-grab consumer audio hardware (such as A/V receivers) often ignore initial audio sent over HDMI. This can happen every time audio over HDMI is stopped and resumed. In order to compensate for this, you can enable this option to not to stop and restart audio on seeks, and fill the gaps with silence. Likewise, when pausing playback, audio is not stopped, and silence is played while paused. Note that if no audio track is selected, the audio device will still be closed immediately.
Not all AOs support this.
Note
Changing styling and position does not work with all subtitles. Image-based subtitles (DVD, Bluray/PGS, DVB) cannot changed for fundamental reasons. Subtitles in ASS format are normally not changed intentionally, but overriding them can be controlled with --sub-ass-override.
Previously some options working on text subtitles were called --sub-text-*, they are now named --sub-*, and those specifically for ASS have been renamed from --ass-* to --sub-ass-*. They are now all in this section.
Add a subtitle file to the list of external subtitles.
If you use --sub-file only once, this subtitle file is displayed by default.
If --sub-file is used multiple times, the subtitle to use can be switched at runtime by cycling subtitle tracks. It's possible to show two subtitles at once: use --sid to select the first subtitle index, and --secondary-sid to select the second index. (The index is printed on the terminal output after the --sid= in the list of streams.)
--sub-files is a path list option (see List Options for details), and can take multiple file names separated by : (Unix) or ; (Windows), while --sub-file takes a single filename, but can be used multiple times to add multiple files. Technically, --sub-file is a CLI/config file only alias for --sub-files-append.
Select a secondary subtitle stream. This is similar to --sid. If a secondary subtitle is selected, it will be rendered as toptitle (i.e. on the top of the screen) alongside the normal subtitle, and provides a way to render two subtitles at once.
There are some caveats associated with this feature. For example, bitmap subtitles will always be rendered in their usual position, so selecting a bitmap subtitle as secondary subtitle will result in overlapping subtitles. Secondary subtitles are never shown on the terminal if video is disabled.
Note
Styling and interpretation of any formatting tags is disabled for the secondary subtitle. Internally, the same mechanism as --no-sub-ass is used to strip the styling.
Note
If the main subtitle stream contains formatting tags which display the subtitle at the top of the screen, it will overlap with the secondary subtitle. To prevent this, you could use --no-sub-ass to disable styling in the main subtitle stream.
Factor for the text subtitle font size (default: 1).
Note
This affects ASS subtitles as well, and may lead to incorrect subtitle rendering. Use with care, or use --sub-font-size instead.
Whether to scale subtitles with the window size (default: yes). If this is disabled, changing the window size won't change the subtitle font size.
Like --sub-scale, this can break ASS subtitles.
Make the subtitle font size relative to the window, instead of the video. This is useful if you always want the same font size, even if the video doesn't cover the window fully, e.g. because screen aspect and window aspect mismatch (and the player adds black bars).
Default: yes.
This option is misnamed. The difference to the confusingly similar sounding option --sub-scale-by-window is that --sub-scale-with-window still scales with the approximate window size, while the other option disables this scaling.
Affects plain text subtitles only (or ASS if --sub-ass-override is set high enough).
Like --sub-scale-with-window, but affects subtitles in ASS format only. Like --sub-scale, this can break ASS subtitles.
Default: no.
Specify the position of subtitles on the screen. The value is the vertical position of the subtitle in % of the screen height.
Note
This affects ASS subtitles as well, and may lead to incorrect subtitle rendering. Use with care, or use --sub-margin-y instead.
Multiply the subtitle event timestamps with the given value. Can be used to fix the playback speed for frame-based subtitle formats. Affects text subtitles only.
Example
--sub-speed=25/23.976 plays frame based subtitles which have been loaded assuming a framerate of 23.976 at 25 FPS.
Override some style or script info parameters.
This is a string list option. See List Options for details.
Examples
Note
Using this option may lead to incorrect subtitle rendering.
Set font hinting type. <type> can be:
none: | no hinting (default) |
---|---|
light: | FreeType autohinter, light mode |
normal: | FreeType autohinter, normal mode |
native: | font native hinter |
Warning
Enabling hinting can lead to mispositioned text (in situations it's supposed to match up video background), or reduce the smoothness of animations with some badly authored ASS scripts. It is recommended to not use this option, unless really needed.
Set the text layout engine used by libass.
simple: | uses Fribidi only, fast, doesn't render some languages correctly |
---|---|
complex: | uses HarfBuzz, slower, wider language support |
complex is the default. If libass hasn't been compiled against HarfBuzz, libass silently reverts to simple.
Load all SSA/ASS styles found in the specified file and use them for rendering text subtitles. The syntax of the file is exactly like the [V4 Styles] / [V4+ Styles] section of SSA/ASS.
Note
Using this option may lead to incorrect subtitle rendering.
Control whether user style overrides should be applied. Note that all of these overrides try to be somewhat smart about figuring out whether or not a subtitle is considered a "sign".
no: | Render subtitles as specified by the subtitle scripts, without overrides. |
---|---|
yes: | Apply all the --sub-ass-* style override options. Changing the default for any of these options can lead to incorrect subtitle rendering (default). |
force: | Like yes, but also force all --sub-* options. Can break rendering easily. |
scale: | Like yes, but also apply --sub-scale. |
strip: | Radically strip all ASS tags and styles from the subtitle. This is equivalent to the old --no-ass / --no-sub-ass options. |
This also controls some bitmap subtitle overrides, as well as HTML tags in formats like SRT, despite the name of the option.
Enables placing toptitles and subtitles in black borders when they are available, if the subtitles are in the ASS format.
Default: no.
Enables placing toptitles and subtitles in black borders when they are available, if the subtitles are in a plain text format (or ASS if --sub-ass-override is set high enough).
Default: yes.
Renamed from --sub-ass-use-margins. To place ASS subtitles in the borders too (like the old option did), also add --sub-ass-force-margins.
Stretch SSA/ASS subtitles when playing anamorphic videos for compatibility with traditional VSFilter behavior. This switch has no effect when the video is stored with square pixels.
The renderer historically most commonly used for the SSA/ASS subtitle formats, VSFilter, had questionable behavior that resulted in subtitles being stretched too if the video was stored in anamorphic format that required scaling for display. This behavior is usually undesirable and newer VSFilter versions may behave differently. However, many existing scripts compensate for the stretching by modifying things in the opposite direction. Thus, if such scripts are displayed "correctly", they will not appear as intended. This switch enables emulation of the old VSFilter behavior (undesirable but expected by many existing scripts).
Enabled by default.
Scale \blur tags by video resolution instead of script resolution (enabled by default). This is bug in VSFilter, which according to some, can't be fixed anymore in the name of compatibility.
Note that this uses the actual video resolution for calculating the offset scale factor, not what the video filter chain or the video output use.
Mangle colors like (xy-)vsfilter do (default: basic). Historically, VSFilter was not color space aware. This was no problem as long as the color space used for SD video (BT.601) was used. But when everything switched to HD (BT.709), VSFilter was still converting RGB colors to BT.601, rendered them into the video frame, and handled the frame to the video output, which would use BT.709 for conversion to RGB. The result were mangled subtitle colors. Later on, bad hacks were added on top of the ASS format to control how colors are to be mangled.
basic: | Handle only BT.601->BT.709 mangling, if the subtitles seem to indicate that this is required (default). |
---|---|
full: | Handle the full YCbCr Matrix header with all video color spaces supported by libass and mpv. This might lead to bad breakages in corner cases and is not strictly needed for compatibility (hopefully), which is why this is not default. |
force-601: | Force BT.601->BT.709 mangling, regardless of subtitle headers or video color space. |
no: | Disable color mangling completely. All colors are RGB. |
Choosing anything other than no will make the subtitle color depend on the video color space, and it's for example in theory not possible to reuse a subtitle script with another video file. The --sub-ass-override option doesn't affect how this option is interpreted.
Stretch DVD subtitles when playing anamorphic videos for better looking fonts on badly mastered DVDs. This switch has no effect when the video is stored with square pixels - which for DVD input cannot be the case though.
Many studios tend to use bitmap fonts designed for square pixels when authoring DVDs, causing the fonts to look stretched on playback on DVD players. This option fixes them, however at the price of possibly misaligning some subtitles (e.g. sign translations).
Disabled by default.
Stretch DVD and other image subtitles to the screen, ignoring the video margins. This has a similar effect as --sub-use-margins for text subtitles, except that the text itself will be stretched, not only just repositioned. (At least in general it is unavoidable, as an image bitmap can in theory consist of a single bitmap covering the whole screen, and the player won't know where exactly the text parts are located.)
This option does not display subtitles correctly. Use with care.
Disabled by default.
Render ASS subtitles natively (enabled by default).
Note
This has been deprecated by --sub-ass-override=strip. You also may need --embeddedfonts=no to get the same behavior. Also, using --sub-ass-override=style should give better results without breaking subtitles too much.
If --no-sub-ass is specified, all tags and style declarations are stripped and ignored on display. The subtitle renderer uses the font style as specified by the --sub- options instead.
Note
Using --no-sub-ass may lead to incorrect or completely broken rendering of ASS/SSA subtitles. It can sometimes be useful to forcibly override the styling of ASS subtitles, but should be avoided in general.
Load additional subtitle files matching the video filename. The parameter specifies how external subtitle files are matched. exact is enabled by default.
no: | Don't automatically load external subtitle files. |
---|---|
exact: | Load the media filename with subtitle file extension (default). |
fuzzy: | Load all subs containing media filename. |
all: | Load all subs in the current and --sub-file-paths directories. |
You can use this option to specify the subtitle codepage. uchardet will be used to guess the charset. (If mpv was not compiled with uchardet, then utf-8 is the effective default.)
The default value for this option is auto, which enables autodetection.
The following steps are taken to determine the final codepage, in order:
Examples
The pseudo codepage UTF-8-BROKEN is used internally. If it's set, subtitles are interpreted as UTF-8 with "Latin 1" as fallback for bytes which are not valid UTF-8 sequences. iconv is never involved in this mode.
This option changed in mpv 0.23.0. Support for the old syntax was fully removed in mpv 0.24.0.
Specify the framerate of the subtitle file (default: video fps). Affects text subtitles only.
Note
<rate> > video fps speeds the subtitles up for frame-based subtitle files and slows them down for time-based ones.
See also: --sub-speed.
Apply Gaussian blur to image subtitles (default: 0). This can help to make pixelated DVD/Vobsubs look nicer. A value other than 0 also switches to software subtitle scaling. Might be slow.
Note
Never applied to text subtitles.
Convert image subtitles to grayscale. Can help to make yellow DVD/Vobsubs look nicer.
Note
Never applied to text subtitles.
Specify extra directories to search for subtitles matching the video. Multiple directories can be separated by ":" (";" on Windows). Paths can be relative or absolute. Relative paths are interpreted relative to video file directory. If the file is a URL, only absolute paths and sub configuration subdirectory will be scanned.
Example
Assuming that /path/to/video/video.avi is played and --sub-file-paths=sub:subtitles is specified, mpv searches for subtitle files in these directories:
This is a path list option. See List Options for details.
Specify font to use for subtitles that do not themselves specify a particular font. The default is sans-serif.
Examples
Note
The --sub-font option (and many other style related --sub- options) are ignored when ASS-subtitles are rendered, unless the --no-sub-ass option is specified.
This used to support fontconfig patterns. Starting with libass 0.13.0, this stopped working.
Specify the sub font size. The unit is the size in scaled pixels at a window height of 720. The actual pixel size is scaled with the window height: if the window height is larger or smaller than 720, the actual size of the text increases or decreases as well.
Default: 55.
See --sub-color. Color used for the sub font border.
Note
ignored when --sub-back-color is specified (or more exactly: when that option is not set to completely transparent).
Size of the sub font border in scaled pixels (see --sub-font-size for details). A value of 0 disables borders.
Default: 3.
Specify the color used for unstyled text subtitles.
The color is specified in the form r/g/b, where each color component is specified as number in the range 0.0 to 1.0. It's also possible to specify the transparency by using r/g/b/a, where the alpha value 0 means fully transparent, and 1.0 means opaque. If the alpha component is not given, the color is 100% opaque.
Passing a single number to the option sets the sub to gray, and the form gray/a lets you specify alpha additionally.
Examples
Alternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value in the range 0 (00) to 255 (FF). For example, #FF0000 is red. This is similar to web colors. Alpha is given with #AARRGGBB.
Examples
Left and right screen margin for the subs in scaled pixels (see --sub-font-size for details).
This option specifies the distance of the sub to the left, as well as at which distance from the right border long sub text will be broken.
Default: 25.
Top and bottom screen margin for the subs in scaled pixels (see --sub-font-size for details).
This option specifies the vertical margins of unstyled text subtitles. If you just want to raise the vertical subtitle position, use --sub-pos.
Default: 22.
Control to which corner of the screen text subtitles should be aligned to (default: center).
Never applied to ASS subtitles, except in --no-sub-ass mode. Likewise, this does not apply to image subtitles.
Displacement of the sub text shadow in scaled pixels (see --sub-font-size for details). A value of 0 disables shadows.
Default: 0.
Horizontal sub font spacing in scaled pixels (see --sub-font-size for details). This value is added to the normal letter spacing. Negative values are allowed.
Default: 0.
Applies filter removing subtitle additions for the deaf or hard-of-hearing (SDH). This is intended for English, but may in part work for other languages too. The intention is that it can be always enabled so may not remove all parts added. It removes speaker labels (like MAN:), upper case text in parentheses and any text in brackets.
Default: no.
Do harder SDH filtering (if enabled by --sub-filter-sdh). Will also remove speaker labels and text within parentheses using both lower and upper case letters.
Default: no.
For every video stream, create a closed captions track (default: no). The only purpose is to make the track available for selection at the start of playback, instead of creating it lazily. This applies only to ATSC A53 Part 4 Closed Captions (displayed by mpv as subtitle tracks using the codec eia_608). The CC track is marked "default" and selected according to the normal subtitle track selection rules. You can then use --sid to explicitly select the correct track too.
If the video stream contains no closed captions, or if no video is being decoded, the CC track will remain empty and will not show any text.
Which libass font provider backend to use (default: auto). auto will attempt to use the native font provider: fontconfig on Linux, CoreText on OSX, DirectWrite on Windows. fontconfig forces fontconfig, if libass was built with support (if not, it behaves like none).
The none font provider effectively disables system fonts. It will still attempt to use embedded fonts (unless --embeddedfonts=no is set; this is the same behavior as with all other font providers), subfont.ttf if provided, and fonts in the fonts sub-directory if provided. (The fallback is more strict than that of other font providers, and if a font name does not match, it may prefer not to render any text that uses the missing font.)
Set the window title. This is used for the video window, and if possible, also sets the audio stream title.
Properties are expanded. (See Property Expansion.)
Warning
There is a danger of this causing significant CPU usage, depending on the properties used. Changing the window title is often a slow operation, and if the title changes every frame, playback can be ruined.
In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on.
Note (X11)
This option does not work properly with all window managers. In these cases, you can try to use --geometry to position the window explicitly. It's also possible that the window manager provides native features to control which screens application windows should use.
See also --fs-screen.
In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to go fullscreen to. If current is used mpv will fallback on what the user provided with the screen option.
Note (X11)
This option works properly only with window managers which understand the EWMH _NET_WM_FULLSCREEN_MONITORS hint.
Note (OS X)
all does not work on OS X and will behave like current.
See also --screen.
Do not terminate when playing or seeking beyond the end of the file, and there is not next file to be played (and --loop is not used). Instead, pause the player. When trying to seek beyond end of the file, the player will attempt to seek to the last frame.
Normally, this will act like set pause yes on EOF, unless the --keep-open-pause=no option is set.
The following arguments can be given:
no: | If the current file ends, go to the next file or terminate. (Default.) |
---|---|
yes: | Don't terminate if the current file is the last playlist entry. Equivalent to --keep-open without arguments. |
always: | Like yes, but also applies to files before the last playlist entry. This means playback will never automatically advance to the next file. |
Note
This option is not respected when using --frames. Explicitly skipping to the next file if the binding uses force will terminate playback as well.
Also, if errors or unusual circumstances happen, the player can quit anyway.
Since mpv 0.6.0, this doesn't pause if there is a next file in the playlist, or the playlist is looped. Approximately, this will pause when the player would normally exit, but in practice there are corner cases in which this is not the case (e.g. mpv --keep-open file.mkv /dev/null will play file.mkv normally, then fail to open /dev/null, then exit). (In mpv 0.8.0, always was introduced, which restores the old behavior.)
If the current file is an image, play the image for the given amount of seconds (default: 1). inf means the file is kept open forever (until the user stops playback manually).
Unlike --keep-open, the player is not paused, but simply continues playback until the time has elapsed. (It should not use any resources during "playback".)
This affects image files, which are defined as having only 1 video frame and no audio. The player may recognize certain non-images as images, for example if --length is used to reduce the length to 1 frame, or if you seek to the last frame.
This option does not affect the framerate used for mf:// or --merge-files. For that, use --mf-fps instead.
Setting --image-display-duration hides the OSC and does not track playback time on the command-line output, and also does not duplicate the image frame when encoding. To force the player into "dumb mode" and actually count out seconds, or to duplicate the image when encoding, you need to use --demuxer=lavf --demuxer-lavf-o=loop=1, and use --length or --frames to stop after a particular time.
Create a video output window even if there is no video. This can be useful when pretending that mpv is a GUI application. Currently, the window always has the size 640x480, and is subject to --geometry, --autofit, and similar options.
Warning
The window is created only after initialization (to make sure default window placement still works if the video size is different from the --force-window default window size). This can be a problem if initialization doesn't work perfectly, such as when opening URLs with bad network connection, or opening broken video files. The immediate mode can be used to create the window always on program start, but this may cause other issues.
(Windows only) Enable/disable playback progress rendering in taskbar (Windows 7 and above).
Enabled by default.
Makes the player window stay on top of other windows.
On Windows, if combined with fullscreen mode, this causes mpv to be treated as exclusive fullscreen window that bypasses the Desktop Window Manager.
(OS X only) Sets the level of an ontop window (default: window).
window: | On top of all other windows. |
---|---|
system: | On top of system elements like Taskbar, Menubar and Dock. |
level: | A level as integer. |
Adjust the initial window position or size. W and H set the window size in pixels. x and y set the window position, measured in pixels from the top-left corner of the screen to the top-left corner of the image being displayed. If a percentage sign (%) is given after the argument, it turns the value into a percentage of the screen size in that direction. Positions are specified similar to the standard X11 --geometry option format, in which e.g. +10-50 means "place 10 pixels from the left border and 50 pixels from the lower border" and "--20+-10" means "place 20 pixels beyond the right and 10 pixels beyond the top border".
If an external window is specified using the --wid option, this option is ignored.
The coordinates are relative to the screen given with --screen for the video output drivers that fully support --screen.
Note
Generally only supported by GUI VOs. Ignored for encoding.
Note (X11)
This option does not work properly with all window managers.
Examples
See also --autofit and --autofit-larger for fitting the window into a given size without changing aspect ratio.
Set the initial window size to a maximum size specified by WxH, without changing the window's aspect ratio. The size is measured in pixels, or if a number is followed by a percentage sign (%), in percents of the screen size.
This option never changes the aspect ratio of the window. If the aspect ratio mismatches, the window's size is reduced until it fits into the specified size.
Window position is not taken into account, nor is it modified by this option (the window manager still may place the window differently depending on size). Use --geometry to change the window position. Its effects are applied after this option.
See --geometry for details how this is handled with multi-monitor setups.
Use --autofit-larger instead if you just want to limit the maximum size of the window, rather than always forcing a window size.
Use --geometry if you want to force both window width and height to a specific size.
Note
Generally only supported by GUI VOs. Ignored for encoding.
Examples
This option behaves exactly like --autofit, except the window size is only changed if the window would be larger than the specified size.
Example
This option behaves exactly like --autofit, except that it sets the minimum size of the window (just as --autofit-larger sets the maximum).
Example
Resize the video window to a multiple (or fraction) of the video size. This option is applied before --autofit and other options are applied (so they override this option).
For example, --window-scale=0.5 would show the window at half the video size.
Whether the video window is minimized or not. Setting this will minimize, or unminimze, the video window if the current VO supports it. Note that some VOs may support minimization while not supporting unminimization (eg: Wayland).
Whether this option and --window-maximized work on program start or at runtime, and whether they're (at runtime) updated to reflect the actual window state, heavily depends on the VO and the windowing system. Some VOs simply do not implement them or parts of them, while other VOs may be restricted by the windowing systems (especially Wayland).
Set the aspect ratio of your monitor or TV screen. A value of 0 disables a previous setting (e.g. in the config file). Overrides the --monitorpixelaspect setting if enabled.
See also --monitorpixelaspect and --video-aspect-override.
Examples
Turns off the screensaver (or screen blanker and similar mechanisms) at startup and turns it on again on exit (default: yes). The screensaver is always re-enabled when the player is paused.
This is not supported on all video outputs or platforms. Sometimes it is implemented, but does not work (especially with Linux "desktops").
This tells mpv to attach to an existing window. If a VO is selected that supports this option, it will use that window for video output. mpv will scale the video to the size of this window, and will add black bars to compensate if the aspect ratio of the video is different.
On X11, the ID is interpreted as a Window on X11. Unlike MPlayer/mplayer2, mpv always creates its own window, and sets the wid window as parent. The window will always be resized to cover the parent window fully. The value 0 is interpreted specially, and mpv will draw directly on the root window.
On win32, the ID is interpreted as HWND. Pass it as value cast to intptr_t. mpv will create its own window, and set the wid window as parent, like with X11.
On OSX/Cocoa, the ID is interpreted as NSView*. Pass it as value cast to intptr_t. mpv will create its own sub-view. Because OSX does not support window embedding of foreign processes, this works only with libmpv, and will crash when used from the command line.
On Android, the ID is interpreted as android.view.Surface. Pass it as a value cast to intptr_t. Use with --vo=mediacodec_embed and --hwdec=mediacodec for direct rendering using MediaCodec, or with --vo=gpu --gpu-context=android (with or without --hwdec=mediacodec-copy).
(X11 only) Control the use of NetWM protocol features.
This may or may not help with broken window managers. This provides some functionality that was implemented by the now removed --fstype option. Actually, it is not known to the developers to which degree this option was needed, so feedback is welcome.
Specifically, yes will force use of NetWM fullscreen support, even if not advertised by the WM. This can be useful for WMs that are broken on purpose, like XMonad. (XMonad supposedly doesn't advertise fullscreen support, because Flash uses it. Apparently, applications which want to use fullscreen anyway are supposed to either ignore the NetWM support hints, or provide a workaround. Shame on XMonad for deliberately breaking X protocols (as if X isn't bad enough already).
By default, NetWM support is autodetected (auto).
This option might be removed in the future.
If set to yes, then ask the compositor to unredirect the mpv window (default: fs-only). This uses the _NET_WM_BYPASS_COMPOSITOR hint.
fs-only asks the window manager to disable the compositor only in fullscreen mode.
no sets _NET_WM_BYPASS_COMPOSITOR to 0, which is the default value as declared by the EWMH specification, i.e. no change is done.
never asks the window manager to never disable the compositor.
Specify the DVD device or .iso filename (default: /dev/dvd). You can also specify a directory that contains files previously copied directly from a DVD (with e.g. vobcopy).
Example
mpv dvd:// --dvd-device=/path/to/dvd/
(Blu-ray only) Specify the Blu-ray disc location. Must be a directory with Blu-ray structure.
Example
mpv bd:// --bluray-device=/path/to/bd/
Set paranoia level. Values other than 0 seem to break playback of anything but the first track.
0: | disable checking (default) |
---|---|
1: | overlap checking only |
2: | full data correction and verification |
Try to limit DVD speed (default: 0, no change). DVD base speed is 1385 kB/s, so an 8x drive can read at speeds up to 11080 kB/s. Slower speeds make the drive more quiet. For watching DVDs, 2700 kB/s should be quiet and fast enough. mpv resets the speed to the drive default value on close. Values of at least 100 mean speed in kB/s. Values less than 100 mean multiples of 1385 kB/s, i.e. --dvd-speed=8 selects 11080 kB/s.
Note
You need write access to the DVD device to change the speed.
Whether to probe stream information (default: auto). Technically, this controls whether libavformat's avformat_find_stream_info() function is called. Usually it's safer to call it, but it can also make startup slower.
The auto choice (the default) tries to skip this for a few know-safe whitelisted formats, while calling it for everything else.
The nostreams choice only calls it if and only if the file seems to contain no streams after opening (helpful in cases when calling the function is needed to detect streams at all, such as with FLV files).
Allow deriving the format from the HTTP MIME type (default: yes). Set this to no in case playing things from HTTP mysteriously fails, even though the same files work from local disk.
This is default in order to reduce latency when opening HTTP streams.
Pass AVOptions to libavformat demuxer.
Note, a patch to make the o= unneeded and pass all unknown options through the AVOption system is welcome. A full list of AVOptions can be found in the FFmpeg manual. Note that some options may conflict with mpv options.
This is a key/value list option. See List Options for details.
Example
--demuxer-lavf-o=fflags=+ignidx
Attempt to linearize timestamp resets in demuxed streams (default: auto). This was tested only for single audio streams. It's unknown whether it works correctly for video (but likely won't). Note that the implementation is slightly incorrect either way, and will introduce a discontinuity by about 1 codec frame size.
The auto mode enables this for OGG audio stream. This covers the common and annoying case of OGG web radio streams. Some of these will reset timestamps to 0 every time a new song begins. This breaks the mpv seekable cache, which can't deal with timestamp resets. Note that FFmpeg/libavformat's seeking API can't deal with this either; it's likely that if this option breaks this even more, while if it's disabled, you can at least seek within the first song in the stream. Well, you won't get anything useful either way if the seek is outside of mpv's cache.
Propagate FFmpeg-level options to recursively opened connections (default: yes). This is needed because FFmpeg will apply these settings to nested AVIO contexts automatically. On the other hand, this could break in certain situations - it's the FFmpeg API, you just can't win.
This affects in particular the --timeout option and anything passed with --demuxer-lavf-o.
If this option is deemed unnecessary at some point in the future, it will be removed without notice.
Try harder to show embedded soft subtitles when seeking somewhere. Normally, it can happen that the subtitle at the seek target is not shown due to how some container file formats are designed. The subtitles appear only if seeking before or exactly to the position a subtitle first appears. To make this worse, subtitles are often timed to appear a very small amount before the associated video frame, so that seeking to the video frame typically does not demux the subtitle at that position.
Enabling this option makes the demuxer start reading data a bit before the seek target, so that subtitles appear correctly. Note that this makes seeking slower, and is not guaranteed to always work. It only works if the subtitle is close enough to the seek target.
Works with the internal Matroska demuxer only. Always enabled for absolute and hr-seeks, and this option changes behavior with relative or imprecise seeks only.
You can use the --demuxer-mkv-subtitle-preroll-secs option to specify how much data the demuxer should pre-read at most in order to find subtitle packets that may overlap. Setting this to 0 will effectively disable this preroll mechanism. Setting a very large value can make seeking very slow, and an extremely large value would completely reread the entire file from start to seek target on every seek - seeking can become slower towards the end of the file. The details are messy, and the value is actually rounded down to the cluster with the previous video keyframe.
Some files, especially files muxed with newer mkvmerge versions, have information embedded that can be used to determine what subtitle packets overlap with a seek target. In these cases, mpv will reduce the amount of data read to a minimum. (Although it will still read all data between the cluster that contains the first wanted subtitle packet, and the seek target.) If the index choice (which is the default) is specified, then prerolling will be done only if this information is actually available. If this method is used, the maximum amount of data to skip can be additionally controlled by --demuxer-mkv-subtitle-preroll-secs-index (it still uses the value of the option without -index if that is higher).
See also --hr-seek-demuxer-offset option. This option can achieve a similar effect, but only if hr-seek is active. It works with any demuxer, but makes seeking much slower, as it has to decode audio and video data instead of just skipping over it.
--mkv-subtitle-preroll is a deprecated alias.
When opening the file, seek to the end of it, and check what timestamp the last video packet has, and report that as file duration. This is strictly for compatibility with Haali only. In this mode, it's possible that opening will be slower (especially when playing over http), or that behavior with broken files is much worse. So don't use this option.
The yes mode merely uses the index and reads a small number of blocks from the end of the file. The full mode actually traverses the entire file and can make a reliable estimate even without an index present (such as partial files).
Image dimension in pixels for --demuxer=rawvideo.
Example
Play a raw YUV sample:
mpv sample-720x576.yuv --demuxer=rawvideo \ --demuxer-rawvideo-w=720 --demuxer-rawvideo-h=576
This controls how much the demuxer is allowed to buffer ahead. The demuxer will normally try to read ahead as much as necessary, or as much is requested with --demuxer-readahead-secs. The option can be used to restrict the maximum readahead. This limits excessive readahead in case of broken files or desynced playback. The demuxer will stop reading additional packets as soon as one of the limits is reached. (The limits still can be slightly overstepped due to technical reasons.)
Set these limits higher if you get a packet queue overflow warning, and you think normal playback would be possible with a larger packet queue.
See --list-options for defaults and value range. <bytesize> options accept suffixes such as KiB and MiB.
This controls how much past data the demuxer is allowed to preserve. This is useful only if the --demuxer-seekable-cache option is enabled. Unlike the forward cache, there is no control how many seconds are actually cached - it will simply use as much memory this option allows. Setting this option to 0 will strictly disable any back buffer, but this will lead to the situation that the forward seek range starts after the current playback position (as it removes past packets that are seek points).
If the end of the file is reached, the remaining unused forward buffer space is "donated" to the backbuffer (unless the backbuffer size is set to 0). This still limits the total cache usage to the sum of the forward and backward cache, and effectively makes better use of the total allowed memory budget. (The opposite does not happen: free backward buffer is never "donated" to the forward buffer.)
Keep in mind that other buffers in the player (like decoders) will cause the demuxer to cache "future" frames in the back buffer, which can skew the impression about how much data the backbuffer contains.
See --list-options for defaults and value range.
This controls whether seeking can use the demuxer cache (default: auto). If enabled, short seek offsets will not trigger a low level demuxer seek (which means for example that slow network round trips or FFmpeg seek bugs can be avoided). If a seek cannot happen within the cached range, a low level seek will be triggered. Seeking outside of the cache will start a new cached range, but can discard the old cache range if the demuxer exhibits certain unsupported behavior.
Keep in mind that some events can flush the cache or force a low level seek anyway, such as switching tracks, or attempting to seek before the start or after the end of the file.
The special value auto means yes in the same situation as --cache-secs is used (i.e. when the stream appears to be a network stream or the stream cache is enabled).
Run the demuxer in a separate thread, and let it prefetch a certain amount of packets (default: yes). Having this enabled leads to smoother playback, enables features like prefetching, and prevents that stuck network freezes the player. On the other hand, it can add overhead, or the background prefetching can hog CPU resources.
Disabling this option is not recommended. Use it for debugging only.
Number of seconds the player should wait to shutdown the demuxer (default: 0.1). The player will wait up to this much time before it closes the stream layer forcefully. Forceful closing usually means the network I/O is given no chance to close its connections gracefully (of course the OS can still close TCP connections properly), and might result in annoying messages being logged, and in some cases, confused remote servers.
This timeout is usually only applied when loading has finished properly. If loading is aborted by the user, or in some corner cases like removing external tracks sourced from network during playback, forceful closing is always used.
If --demuxer-thread is enabled, this controls how much the demuxer should buffer ahead in seconds (default: 1). As long as no packet has a timestamp difference higher than the readahead amount relative to the last packet returned to the decoder, the demuxer keeps reading.
Note that the --cache-secs option will override this value if a cache is enabled, and the value is larger.
(This value tends to be fuzzy, because many file formats don't store linear timestamps.)
Prefetch next playlist entry while playback of the current entry is ending (default: no). This merely opens the URL of the next playlist entry as soon as the current URL is fully read.
This does not work with URLs resolved by the youtube-dl wrapper, and it won't.
This does not affect HLS (.m3u8 URLs) - HLS prefetching depends on the demuxer cache settings and is on by default.
This can give subtly wrong results if per-file options are used, or if options are changed in the time window between prefetching start and next file played.
This can occasionally make wrong prefetching decisions. For example, it can't predict whether you go backwards in the playlist, and assumes you won't edit the playlist.
Highly experimental.
When opening multi-volume rar files, open all volumes to create a full list of contained files (default: no). If disabled, only the archive entries whose headers are located within the first volume are listed (and thus played when opening a .rar file with mpv). Doing so speeds up opening, and the typical idiotic use-case of playing uncompressed multi-volume rar files that contain a single media file is made faster.
Opening is still slow, because for unknown, idiotic, and unnecessary reasons libarchive opens all volumes anyway when playing the main file, even though mpv iterated no archive entries yet.
Deprecated. Use --input-ipc-server.
Read commands from the given file. Mostly useful with a FIFO. Since mpv 0.7.0 also understands JSON commands (see JSON IPC), but you can't get replies or events. Use --input-ipc-server for something bi-directional. On MS Windows, JSON commands are not available.
This can also specify a direct file descriptor with fd://N (UNIX only). In this case, JSON replies will be written if the FD is writable.
Note
When the given file is a FIFO mpv opens both ends, so you can do several echo "seek 10" > mp_pipe and the pipe will stay valid.
Enable the IPC support and create the listening socket at the given path.
On Linux and Unix, the given path is a regular filesystem path. On Windows, named pipes are used, so the path refers to the pipe namespace (\\.\pipe\<name>). If the \\.\pipe\ prefix is missing, mpv will add it automatically before creating the pipe, so --input-ipc-server=/tmp/mpv-socket and --input-ipc-server=\\.\pipe\tmp\mpv-socket are equivalent for IPC on Windows.
See JSON IPC for details.
Disable all keyboard input on for VOs which can't participate in proper keyboard input dispatching. May not affect all VOs. Generally useful for embedding only.
On X11, a sub-window with input enabled grabs all keyboard input as long as it is 1. a child of a focused window, and 2. the mouse is inside of the sub-window. It can steal away all keyboard input from the application embedding the mpv window, and on the other hand, the mpv window will receive no input if the mouse is outside of the mpv window, even though mpv has focus. Modern toolkits work around this weird X11 behavior, but naively embedding foreign windows breaks it.
The only way to handle this reasonably is using the XEmbed protocol, which was designed to solve these problems. GTK provides GtkSocket, which supports XEmbed. Qt doesn't seem to provide anything working in newer versions.
If the embedder supports XEmbed, input should work with default settings and with this option disabled. Note that input-default-bindings is disabled by default in libmpv as well - it should be enabled if you want the mpv default key bindings.
(This option was renamed from --input-x11-keyboard.)
Disable display of the OSD bar.
You can configure this on a per-command basis in input.conf using osd- prefixes, see Input Command Prefixes. If you want to disable the OSD completely, use --osd-level=0.
Set what is displayed on the OSD during seeks. The default is bar.
You can configure this on a per-command basis in input.conf using osd- prefixes, see Input Command Prefixes.
Specify font to use for OSD. The default is sans-serif.
Examples
Specify the OSD font size. See --sub-font-size for details.
Default: 55.
Similar to --osd-msg1, but for OSD level 3. If this is an empty string (default), then the playback time, duration, and some more information is shown.
This is used for the show-progress command (by default mapped to P), and when seeking if enabled with --osd-on-seek or by osd- prefixes in input.conf (see Input Command Prefixes).
--osd-status-msg is a legacy equivalent (but with a minor difference).
Show a custom string during playback instead of the standard status text. This overrides the status text used for --osd-level=3, when using the show-progress command (by default mapped to P), and when seeking if enabled with --osd-on-seek or osd- prefixes in input.conf (see Input Command Prefixes). Expands properties. See Property Expansion.
This option has been replaced with --osd-msg3. The only difference is that this option implicitly includes ${osd-sym-cc}. This option is ignored if --osd-msg3 is not empty.
Show a message on OSD when playback starts. The string is expanded for properties, e.g. --osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename.
See Property Expansion.
See --osd-color. Color used for the OSD font border.
Note
ignored when --osd-back-color is specified (or more exactly: when that option is not set to completely transparent).
Size of the OSD font border in scaled pixels (see --sub-font-size for details). A value of 0 disables borders.
Default: 3.
Specifies which mode the OSD should start in.
0: | OSD completely disabled (subtitles only) |
---|---|
1: | enabled (shows up only on user interaction) |
2: | enabled + current time visible by default |
3: | enabled + --osd-status-msg (current time and status by default) |
Left and right screen margin for the OSD in scaled pixels (see --sub-font-size for details).
This option specifies the distance of the OSD to the left, as well as at which distance from the right border long OSD text will be broken.
Default: 25.
Top and bottom screen margin for the OSD in scaled pixels (see --sub-font-size for details).
This option specifies the vertical margins of the OSD.
Default: 22.
Displacement of the OSD shadow in scaled pixels (see --sub-font-size for details). A value of 0 disables shadows.
Default: 0.
Horizontal OSD/sub font spacing in scaled pixels (see --sub-font-size for details). This value is added to the normal letter spacing. Negative values are allowed.
Default: 0.
Enabled OSD rendering on the video window (default: yes). This can be used in situations where terminal OSD is preferred. If you just want to disable all OSD rendering, use --osd-level=0.
It does not affect subtitles or overlays created by scripts (in particular, the OSC needs to be disabled with --no-osc).
This option is somewhat experimental and could be replaced by another mechanism in the future.
Set the image file type used for saving screenshots.
Available choices:
png: | PNG |
---|---|
jpg: | JPEG (default) |
jpeg: | JPEG (alias for jpg) |
webp: | WebP |
Tag screenshots with the appropriate colorspace.
Note that not all formats are supported.
Default: no.
Specify the filename template used to save screenshots. The template specifies the filename without file extension, and can contain format specifiers, which will be substituted when taking a screenshot. By default, the template is mpv-shot%n, which results in filenames like mpv-shot0012.png for example.
The template can start with a relative or absolute path, in order to specify a directory location where screenshots should be saved.
If the final screenshot filename points to an already existing file, the file will not be overwritten. The screenshot will either not be saved, or if the template contains %n, saved using different, newly generated filename.
Allowed format specifiers:
Similar to %p, but extended with the playback time in milliseconds. It is formatted as "HH:MM:SS.mmm", with "mmm" being the millisecond part of the playback time.
Note
This is a simple way for getting unique per-frame timestamps. (Frame numbers would be more intuitive, but are not easily implementable because container formats usually use time stamps for identifying frames.)
Specify the current playback time using the format string X. %p is like %wH:%wM:%wS, and %P is like %wH:%wM:%wS.%wT.
Store screenshots in this directory. This path is joined with the filename generated by --screenshot-template. If the template filename is already absolute, the directory is ignored.
If the directory does not exist, it is created on the first screenshot. If it is not a directory, an error is generated when trying to write a screenshot.
This option is not set by default, and thus will write screenshots to the directory from which mpv was started. In pseudo-gui mode (see PSEUDO GUI MODE), this is set to the desktop.
Specify the software scaler algorithm to be used with --vf=scale. This also affects video output drivers which lack hardware acceleration, e.g. x11. See also --vf=scale.
To get a list of available scalers, run --sws-scaler=help.
Default: bicubic.
Allow optimizations that help with performance, but reduce quality (default: no).
VOs like drm and x11 will benefit a lot from using --sws-fast. You may need to set other options, like --sws-scaler. The builtin sws-fast profile sets this option and some others to gain performance for reduced quality.
Allow using zimg (if the component using the internal swscale wrapper explicitly allows so). In this case, zimg may be used, if the internal zimg wrapper supports the input and output formats. It will silently fall back to libswscale if one of these conditions does not apply.
If zimg is used, the other --sws- options are ignored, and the --zimg- options are used instead.
If the internal component using the swscale wrapper hooks up logging correctly, a verbose priority log message will indicate whether zimg is being used.
Most things which need software conversion can make use of this.
Set scaler parameters. By default, these are set to the special string default, which maps to a scaler-specific default value. Ignored if the scaler is not tunable.
This controls the default options of any resampling done by mpv (but not within libavfilter, within the system audio API resampler, or any other places).
It also sets the defaults for the lavrresample audio filter.
Enable/disable normalization if surround audio is downmixed to stereo (default: no). If this is disabled, downmix can cause clipping. If it's enabled, the output might be too quiet. It depends on the source audio.
Technically, this changes the normalize suboption of the lavrresample audio filter, which performs the downmixing.
If downmix happens outside of mpv for some reason, or in the decoder (decoder downmixing), or in the audio output (system mixer), this has no effect.
Limit maximum size of audio frames filtered at once, in ms (default: 40). The output size size is limited in order to make resample speed changes react faster. This is necessary especially if decoders or filters output very large frame sizes (like some lossless codecs or some DRC filters). This option does not affect the resampling algorithm in any way.
For testing/debugging only. Can be removed or changed any time.
Set AVOptions on the SwrContext or AVAudioResampleContext. These should be documented by FFmpeg or Libav.
This is a key/value list option. See List Options for details.
Make console output less verbose; in particular, prevents the status line (i.e. AV: 3.4 (00:00:03.37) / 5320.6 ...) from being displayed. Particularly useful on slow terminals or broken ones which do not properly handle carriage return (i.e. \r).
See also: --really-quiet and --msg-level.
Disable any use of the terminal and stdin/stdout/stderr. This completely silences any message output.
Unlike --really-quiet, this disables input and terminal initialization as well.
Control verbosity directly for each module. The all module changes the verbosity of all the modules. The verbosity changes from this option are applied in order from left to right, and each item can override a previous one.
Run mpv with --msg-level=all=trace to see all messages mpv outputs. You can use the module names printed in the output (prefixed to each line in [...]) to limit the output to interesting modules.
This also affects --log-file, and in certain cases libmpv API logging.
Note
Some messages are printed before the command line is parsed and are therefore not affected by --msg-level. To control these messages, you have to use the MPV_VERBOSE environment variable; see ENVIRONMENT VARIABLES for details.
Available levels:
no: complete silence fatal: fatal messages only error: error messages warn: warning messages info: informational messages status: status messages (default) v: verbose messages debug: debug messages trace: very noisy debug messages
Example
mpv --msg-level=ao/sndio=no
Completely silences the output of ao_sndio, which uses the log prefix [ao/sndio].
mpv --msg-level=all=warn,ao/alsa=error
Only show warnings or worse, and let the ao_alsa output show errors only.
Control whether OSD messages are shown on the console when no video output is available (default: auto).
auto: | use terminal OSD if no video output active |
---|---|
no: | disable terminal OSD |
force: | use terminal OSD even if video output active |
The auto mode also enables terminal OSD if --video-osd=no was set.
Customize the --term-osd-bar feature. The string is expected to consist of 5 characters (start, left space, position indicator, right space, end). You can use Unicode characters, but note that double- width characters will not be treated correctly.
Default: [-+-].
Print out a string after starting playback. The string is expanded for properties, e.g. --term-playing-msg='file: ${filename}' will print the string file: followed by a space and the currently played filename.
See Property Expansion.
Decide whether to use network cache settings (default: auto).
If enabled, use up to --cache-secs for the cache size (but still limited to --demuxer-max-bytes). --demuxer-seekable-cache=auto behaves as if it was set to yes. If disabled, --cache-pause and related are implicitly disabled.
The auto choice enables this depending on whether the stream is thought to involve network accesses or other slow media (this is an imperfect heuristic).
Before mpv 0.30.0, this used to accept a number, which specified the size of the cache in kilobytes. Use e.g. --cache --demuxer-max-bytes=123k instead.
Write packet data to a temporary file, instead of keeping them in memory. This makes sense only with --cache. If the normal cache is disabled, this option is ignored.
You need to set --cache-dir to use this.
The cache file is append-only. Even if the player appears to prune data, the file space freed by it is not reused. The cache file is deleted when playback is closed.
Note that packet metadata is still kept in memory. --demuxer-max-bytes and related options are applied to metadata only. The size of this metadata varies, but 50 MB per hour of media is typical. The cache statistics will report this metadats size, instead of the size of the cache file. If the metadata hits the size limits, the metadata is pruned (but not the cache file).
When the media is closed, the cache file is deleted. A cache file is generally worthless after the media is closed, and it's hard to retrieve any media data from it (it's not supported by design).
If the option is enabled at runtime, the cache file is created, but old data will remain in the memory cache. If the option is disabled at runtime, old data remains in the disk cache, and the cache file is not closed until the media is closed. If the option is disabled and enabled again, it will continue to use the cache file that was opened first.
Directory where to create temporary files (default: none).
Currently, this is used for --cache-on-disk only.
Enter "buffering" mode before starting playback (default: no). This can be used to ensure playback starts smoothly, in exchange for waiting some time to prefetch network data (as controlled by --cache-pause-wait). For example, some common behavior is that playback starts, but network caches immediately underrun when trying to decode more data as playback progresses.
Another thing that can happen is that the network prefetching is so CPU demanding (due to demuxing in the background) that playback drops frames at first. In these cases, it helps enabling this option, and setting --cache-secs and --cache-pause-wait to roughly the same value.
This option also triggers when playback is restarted after seeking.
Whether or when to unlink cache files (default: immediate). This affects cache files which are inherently temporary, and which make no sense to remain on disk after the player terminates. This is a debugging option.
Currently, this is used for --cache-on-disk only.
Size of the low level stream byte buffer (default: 128KB). This is used as buffer between demuxer and low level I/O (e.g. sockets). Generally, this can be very small, and the main purpose is similar to the internal buffer FILE in the C standard library will have.
Half of the buffer is always used for guaranteed seek back, which is important for unseekable input.
There are known cases where this can help performance to set a large buffer:
- mp4 files. libavformat may trigger many small seeks in both directions, depending on how the file was muxed.
- Certain network filesystems, which do not have a cache, and where small reads can be inefficient.
In other cases, setting this to a large value can reduce performance.
Usually, read accesses are at half the buffer size, but it may happen that accesses are done alternating with smaller and larger sizes (this is due to the internal ring buffer wrap-around).
See --list-options for defaults and value range. <bytesize> options accept suffixes such as KiB and MiB.
Set custom HTTP fields when accessing HTTP stream.
This is a string list option. See List Options for details.
Example
mpv --http-header-fields='Field1: value1','Field2: value2' \ http://localhost:1234
Will generate HTTP request:
GET / HTTP/1.0 Host: localhost:1234 User-Agent: MPlayer Icy-MetaData: 1 Field1: value1 Field2: value2 Connection: close
Specify the network timeout in seconds (default: 60 seconds). This affects at least HTTP. The special value 0 uses the FFmpeg/Libav defaults. If a protocol is used which does not support timeouts, this option is silently ignored.
Warning
This breaks the RTSP protocol, because of inconsistent FFmpeg API regarding its internal timeout option. Not only does the RTSP timeout option accept different units (seconds instead of microseconds, causing mpv to pass it huge values), it will also overflow FFmpeg internal calculations. The worst is that merely setting the option will put RTSP into listening mode, which breaks any client uses. At time of this writing, the fix was not made effective yet. For this reason, this option is ignored (or should be ignored) on RTSP URLs. You can still set the timeout option directly with --demuxer-lavf-o.
If HLS streams are played, this option controls what streams are selected by default. The option allows the following parameters:
no: | Don't do anything special. Typically, this will simply pick the first audio/video streams it can find. |
---|---|
min: | Pick the streams with the lowest bitrate. |
max: | Same, but highest bitrate. (Default.) |
Additionally, if the option is a number, the stream with the highest rate equal or below the option value is selected.
The bitrate as used is sent by the server, and there's no guarantee it's actually meaningful.
Apply no filters on program PIDs, only tune to frequency and pass full transponder to demuxer. The player frontend selects the streams from the full TS in this case, so the program which is shown initially may not match the chosen channel. Switching between the programs is possible by cycling the program property. This is useful to record multiple programs on a single transponder, or to work around issues in the channels.conf. It is also recommended to use this for channels which switch PIDs on-the-fly, e.g. for regional news.
Default: no
This value is not meant for setting via configuration, but used in channel switching. An input.conf can cycle this value up and down to perform channel switching. This number effectively gives the offset to the initially tuned to channel in the channel list.
An example input.conf could contain: H cycle dvbin-channel-switch-offset up, K cycle dvbin-channel-switch-offset down
Set the requested buffer time in microseconds. A value of 0 skips requesting anything from the ALSA API. This and the --alsa-periods option uses the ALSA near functions to set the requested parameters. If doing so results in an empty configuration set, setting these parameters is skipped.
Both options control the buffer size. A low buffer size can lead to higher CPU usage and audio dropouts, while a high buffer size can lead to higher latency in volume changes and other filtering.
The following video options are currently all specific to --vo=gpu and --vo=libmpv only, which are the only VOs that implement them.
The filter function to use when upscaling video.
Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged.
(This filter is an alias for sinc-windowed sinc)
Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing.
(This filter is an alias for jinc-windowed jinc)
There are some more filters, but most are not as useful. For a complete list, pass help as value, e.g.:
mpv --scale=help
The filter used for interpolating the temporal axis (frames). This is only used if --interpolation is enabled. The only valid choices for --tscale are separable convolution filters (use --tscale=help to get a list). The default is mitchell.
Common --tscale choices include oversample, linear, catmull_rom, mitchell, gaussian, or bicubic. These are listed in increasing order of smoothness/blurriness, with bicubic being the smoothest/blurriest and oversample being the sharpest/least smooth.
Set filter parameters. By default, these are set to the special string default, which maps to a scaler-specific default value. Ignored if the filter is not tunable. Currently, this affects the following filter parameters:
Set radius for tunable filters, must be a float number between 0.5 and 16.0. Defaults to the filter's preferred radius if not specified. Doesn't work for every scaler and VO combination.
Note that depending on filter implementation details and video scaling ratio, the radius that actually being used might be different (most likely being increased a bit).
Set the antiringing strength. This tries to eliminate ringing, but can introduce other artifacts in the process. Must be a float number between 0.0 and 1.0. The default value of 0.0 disables antiringing entirely.
Note that this doesn't affect the special filters bilinear and bicubic_fast, nor does it affect any polar (EWA) scalers.
(Advanced users only) Configure the parameter for the window function given by --scale-window etc. By default, these are set to the special string default, which maps to a window-specific default value. Ignored if the window is not tunable. Currently, this affects the following window parameters:
Set the size of the lookup texture for scaler kernels (default: 6). The actual size of the texture is 2^N for an option value of N. So the lookup texture with the default setting uses 64 samples.
All weights are linearly interpolated from those samples, so increasing the size of lookup table might improve the accuracy of scaler.
When using convolution based filters, extend the filter size when downscaling. Increases quality, but reduces performance while downscaling.
This will perform slightly sub-optimally for anamorphic video (but still better than without it) since it will extend the size to match only the milder of the scale factors between the axes.
Reduce stuttering caused by mismatches in the video fps and display refresh rate (also known as judder).
Warning
This requires setting the --video-sync option to one of the display- modes, or it will be silently disabled. This was not required before mpv 0.14.0.
This essentially attempts to interpolate the missing frames by convoluting the video along the temporal axis. The filter used can be controlled using the --tscale setting.
Threshold below which frame ratio interpolation gets disabled (default: 0.0001). This is calculated as abs(disphz/vfps - 1) < threshold, where vfps is the speed-adjusted video FPS, and disphz the display refresh rate. (The speed-adjusted video FPS is roughly equal to the normal video FPS, but with slowdown and speedup applied. This matters if you use --video-sync=display-resample to make video run synchronously to the display FPS, or if you change the speed property.)
The default is intended to almost always enable interpolation if the playback rate is even slightly different from the display refresh rate. But note that if you use e.g. --video-sync=display-vdrop, small deviations in the rate can disable interpolation and introduce a discontinuity every other minute.
Set this to -1 to disable this logic.
Set dither target depth to N. Default: no.
Note that the depth of the connected video display device cannot be detected. Often, LCD panels will do dithering on their own, which conflicts with this option and leads to ugly output.
Set the size of the dither matrix (default: 6). The actual size of the matrix is (2^N) x (2^N) for an option value of N, so a value of 6 gives a size of 64x64. The matrix is generated at startup time, and a large matrix can take rather long to compute (seconds).
Used in --dither=fruit mode only.
Select dithering algorithm (default: fruit). (Normally, the --dither-depth option controls whether dithering is enabled.)
The error-diffusion option requires compute shader support. It also requires large amount of shared memory to run, the size of which depends on both the kernel (see --error-diffusion option below) and the height of video window. It will fallback to fruit dithering if there is no enough shared memory to run the shader.
The error diffusion kernel to use when --dither=error-diffusion is set.
There are other kernels (use --error-diffusion=help to list) but most of them are much slower and demanding even larger amount of shared memory. Among these kernels, burkes achieves a good balance between performance and quality, and probably is the one you want to try first.
Interval in displayed frames between two buffer swaps. 1 is equivalent to enable VSYNC, 0 to disable VSYNC. Defaults to 1 if not specified.
Note that this depends on proper OpenGL vsync support. On some platforms and drivers, this only works reliably when in fullscreen mode. It may also require driver-specific hacks if using multiple monitors, to ensure mpv syncs to the right one. Compositing window managers can also lead to bad results, as can missing or incorrect display FPS information (see --override-display-fps).
Controls the presentation mode of the vulkan swapchain. This is similar to the --opengl-swapinterval option.
Select a specific D3D11 adapter to utilize for D3D11 rendering. Will pick the default adapter if unset. Alternatives are listed when the name "help" is given.
Checks for matches based on the start of the string, case insensitive. Thus, if the description of the adapter starts with the vendor name, that can be utilized as the selection parameter.
Hardware decoders utilizing the D3D11 rendering abstraction's helper functionality to receive a device, such as D3D11VA or DXVA2's DXGI mode, will be affected by this choice.
Select a specific D3D11 output format to utilize for D3D11 rendering. "auto" is the default, which will pick either rgba8 or rgb10_a2 depending on the configured desktop bit depth. rgba16f and bgra8 are left out of the autodetection logic, and are available for manual testing.
Note
Desktop bit depth querying is only available from an API available from Windows 10. Thus on older systems it will only automatically utilize the rgba8 output format.
Select a specific D3D11 output color space to utilize for D3D11 rendering. "auto" is the default, which will select the color space of the desktop on which the swap chain is located.
Values other than "srgb" and "pq" have had issues in testing, so they are mostly available for manual testing.
Note
Swap chain color space configuration is only available from an API available from Windows 10. Thus on older systems it will not work.
By default, when using hardware decoding with --gpu-api=d3d11, the video image will be copied (GPU-to-GPU) from the decoder surface to a shader resource. Set this option to avoid that copy by sampling directly from the decoder image. This may increase performance and reduce power usage, but can cause the image to be sampled incorrectly on the bottom and right edges due to padding, and may invoke driver bugs, since Direct3D 11 technically does not allow sampling from a decoder surface (though most drivers support it.)
Currently only relevant for --gpu-api=d3d11.
Controls which compiler is used to translate GLSL to SPIR-V. This is (currently) only relevant for --gpu-api=vulkan and --gpu-api=d3d11. The possible choices are currently only:
Note
This option is deprecated, since there is only one reasonable value. It may be removed in the future.
Custom GLSL hooks. These are a flexible way to add custom fragment shaders, which can be injected at almost arbitrary points in the rendering pipeline, and access all previous intermediate textures.
Each use of the --glsl-shader option will add another file to the internal list of shaders, while --glsl-shaders takes a list of files, and overwrites the internal list with it. The latter is a path list option (see List Options for details).
Warning
The syntax is not stable yet and may change any time.
The general syntax of a user shader looks like this:
//!METADATA ARGS... //!METADATA ARGS... vec4 hook() { ... return something; } //!METADATA ARGS... //!METADATA ARGS... ...
Each section of metadata, along with the non-metadata lines after it, defines a single block. There are currently two types of blocks, HOOKs and TEXTUREs.
A TEXTURE block can set the following options:
The texture format for the samples. Supported texture formats are listed in debug logging when the gpu VO is initialized (look for Texture formats:). Usually, this follows OpenGL naming conventions. For example, rgb16 provides 3 channels with normalized 16 bit components. One oddity are float formats: for example, rgba16f has 16 bit internal precision, but the texture data is provided as 32 bit floats, and the driver converts the data on texture upload.
Although format names follow a common naming convention, not all of them are available on all hardware, drivers, GL versions, and so on.
Following the metadata is a string of bytes in hexadecimal notation that define the raw texture data, corresponding to the format specified by FORMAT, on a single line with no extra whitespace.
A HOOK block can set the following options:
Indicates a pixel shift (offset) introduced by this pass. These pixel offsets will be accumulated and corrected during the next scaling pass (cscale or scale). The default values are 0 0 which correspond to no shift. Note that offsets are ignored when not overwriting the hooked texture.
A special value of ALIGN will attempt to fix existing offset of HOOKED by align it with reference. It requires HOOKED to be resizable (see below). It works transparently with fragment shader. For compute shader, the predefined texmap macro is required to handle coordinate mapping.
Specifies that this shader should be treated as a compute shader, with the block size bw and bh. The compute shader will be dispatched with however many blocks are necessary to completely tile over the output. Within each block, there will bw tw*th threads, forming a single work group. In other words: tw and th specify the work group size, which can be different from the block size. So for example, a compute shader with bw, bh = 32 and tw, th = 8 running on a 500x500 texture would dispatch 16x16 blocks (rounded up), each with 8x8 threads.
Compute shaders in mpv are treated a bit different from fragment shaders. Instead of defining a vec4 hook that produces an output sample, you directly define void hook which writes to a fixed writeonly image unit named out_image (this is bound by mpv) using imageStore. To help translate texture coordinates in the absence of vertices, mpv provides a special function NAME_map(id) to map from the texel space of the output image to the texture coordinates for all bound textures. In particular, NAME_pos is equivalent to NAME_map(gl_GlobalInvocationID), although using this only really makes sense if (tw,th) == (bw,bh).
Each bound mpv texture (via BIND) will make available the following definitions to that shader pass, where NAME is the name of the bound texture:
Normally, users should use either NAME_tex or NAME_texOff to read from the texture. For some shaders however , it can be better for performance to do custom sampling from NAME_raw, in which case care needs to be taken to respect NAME_mul and NAME_rot.
In addition to these parameters, the following uniforms are also globally available:
Internally, vo_gpu may generate any number of the following textures. Whenever a texture is rendered and saved by vo_gpu, all of the passes that have hooked into it will run, in the order they were added by the user. This is a list of the legal hook points:
Only the textures labelled with resizable may be transformed by the pass. When overwriting a texture marked fixed, the WIDTH, HEIGHT and OFFSET must be left at their default values.
The debanding filter's initial radius. The radius increases linearly for each iteration. A higher radius will find more gradients, but a lower radius will smooth more aggressively. (Default 16)
If you increase the --deband-iterations, you should probably decrease this to compensate.
Call glXWaitVideoSyncSGI after each buffer swap (default: disabled). This may or may not help with video timing accuracy and frame drop. It's possible that this makes video output slower, or has no effect at all.
X11/GLX only.
Calls DwmFlush after swapping buffers on Windows (default: auto). It also sets SwapInterval(0) to ignore the OpenGL timing. Values are: no (disabled), windowed (only in windowed mode), yes (also in full screen).
The value auto will try to determine whether the compositor is active, and calls DwmFlush only if it seems to be.
This may help to get more consistent frame intervals, especially with high-fps clips - which might also reduce dropped frames. Typically, a value of windowed should be enough, since full screen may bypass the DWM.
Windows only.
Selects a specific feature level when using the ANGLE backend with D3D11. By default, the highest available feature level is used. This option can be used to select a lower feature level, which is mainly useful for debugging. Note that OpenGL ES 3.0 is only supported at feature level 10_1 or higher. Most extended OpenGL features will not work at lower feature levels (similar to --gpu-dumb-mode).
Windows with ANGLE only.
Use WARP (Windows Advanced Rasterization Platform) when using the ANGLE backend with D3D11 (default: auto). This is a high performance software renderer. By default, it is used when the Direct3D hardware does not support Direct3D 11 feature level 9_3. While the extended OpenGL features will work with WARP, they can be very slow.
Windows with ANGLE only.
Use ANGLE's built in EGL windowing functions to create a swap chain (default: auto). If this is set to no and the D3D11 renderer is in use, ANGLE's built in swap chain will not be used and a custom swap chain that is optimized for video rendering will be created instead. If set to auto, a custom swap chain will be used for D3D11 and the built in swap chain will be used for D3D9. This option is mainly for debugging purposes, in case the custom swap chain has poor performance or does not work.
If set to yes, the --angle-max-frame-latency, --angle-swapchain-length and --angle-flip options will have no effect.
Windows with ANGLE only.
Enable flip-model presentation, which avoids unnecessarily copying the backbuffer by sharing surfaces with the DWM (default: yes). This may cause performance issues with older drivers. If flip-model presentation is not supported (for example, on Windows 7 without the platform update), mpv will automatically fall back to the older bitblt presentation model.
If set to no, the --angle-swapchain-length option will have no effect.
Windows with ANGLE only.
Forces a specific renderer when using the ANGLE backend (default: auto). In auto mode this will pick D3D11 for systems that support Direct3D 11 feature level 9_3 or higher, and D3D9 otherwise. This option is mainly for debugging purposes. Normally there is no reason to force a specific renderer, though --angle-renderer=d3d9 may give slightly better performance on old hardware. Note that the D3D9 renderer only supports OpenGL ES 2.0, so most extended OpenGL features will not work if this renderer is selected (similar to --gpu-dumb-mode).
Windows with ANGLE only.
Deactivates the automatic graphics switching and forces the dedicated GPU. (default: no)
OS X only.
Use the Apple Software Renderer when using cocoa-cb (default: auto). If set to no the software renderer is never used and instead fails when a the usual pixel format could not be created, yes will always only use the software renderer, and auto only falls back to the software renderer when the usual pixel format couldn't be created.
OS X only.
Creates a 10bit capable pixel format for the context creation (default: yes). Instead of 8bit integer framebuffer a 16bit half-float framebuffer is requested.
OS X only.
Sets the appearance of the title bar (default: auto). Not all combinations of appearances and --macos-title-bar-material materials make sense or are unique. Appearances that are not supported by you current macOS version fall back to the default value. macOS and cocoa-cb only
<appearance> can be one of the following:
auto: | Detects the system settings and sets the title bar appearance appropriately. On macOS 10.14 it also detects run time changes. |
---|---|
aqua: | The standard macOS Light appearance. |
darkAqua: | The standard macOS Dark appearance. (macOS 10.14+) |
vibrantLight: | Light vibrancy appearance with. |
vibrantDark: | Dark vibrancy appearance with. |
aquaHighContrast: | |
Light Accessibility appearance. (macOS 10.14+) | |
darkAquaHighContrast: | |
Dark Accessibility appearance. (macOS 10.14+) | |
vibrantLightHighContrast: | |
Light vibrancy Accessibility appearance. (macOS 10.14+) | |
vibrantDarkHighContrast: | |
Dark vibrancy Accessibility appearance. (macOS 10.14+) |
Sets the material of the title bar (default: titlebar). All deprecated materials should not be used on macOS 10.14+ because their functionality is not guaranteed. Not all combinations of materials and --macos-title-bar-appearance appearances make sense or are unique. Materials that are not supported by you current macOS version fall back to the default value. macOS and cocoa-cb only
<material> can be one of the following:
titlebar: | The standard macOS titel bar material. |
---|---|
selection: | The standard macOS selection material. |
menu: | The standard macOS menu material. (macOS 10.11+) |
popover: | The standard macOS popover material. (macOS 10.11+) |
sidebar: | The standard macOS sidebar material. (macOS 10.11+) |
headerView: | The standard macOS header view material. (macOS 10.14+) |
sheet: | The standard macOS sheet material. (macOS 10.14+) |
windowBackground: | |
The standard macOS window background material. (macOS 10.14+) | |
hudWindow: | The standard macOS hudWindow material. (macOS 10.14+) |
fullScreen: | The standard macOS full screen material. (macOS 10.14+) |
toolTip: | The standard macOS tool tip material. (macOS 10.14+) |
contentBackground: | |
The standard macOS content background material. (macOS 10.14+) | |
underWindowBackground: | |
The standard macOS under window background material. (macOS 10.14+) | |
underPageBackground: | |
The standard macOS under page background material. (deprecated in macOS 10.14+) | |
dark: | The standard macOS dark material. (deprecated in macOS 10.14+) |
light: | The standard macOS light material. (macOS 10.14+) |
mediumLight: | The standard macOS mediumLight material. (macOS 10.11+, deprecated in macOS 10.14+) |
ultraDark: | The standard macOS ultraDark material. (macOS 10.11+ deprecated in macOS 10.14+) |
Set dimensions of the rendering surface used by the Android gpu context. Needs to be set by the embedding application if the dimensions change during runtime (i.e. if the device is rotated), via the surfaceChanged callback.
Android with --gpu-context=android only.
The value auto (the default) selects the GPU context. You can also pass help to get a complete list of compiled in backends (sorted by autoprobe order).
Controls which type of graphics APIs will be accepted:
Controls which type of OpenGL context will be accepted:
Selects the internal format of textures used for FBOs. The format can influence performance and quality of the video output. fmt can be one of: rgb8, rgb10, rgb10_a2, rgb16, rgb16f, rgb32f, rgba12, rgba16, rgba16f, rgba16hf, rgba32f.
Default: auto, which first attempts to utilize 16bit float (rgba16f, rgba16hf), and falls back to rgba16 if those are not available. Finally, attempts to utilize rgb10_a2 or rgba8 if all of the previous formats are not available.
Set an additional raw gamma factor (default: 1.0). If gamma is adjusted in other ways (like with the --gamma option or key bindings and the gamma property), the value is multiplied with the other gamma value.
Recommended values based on the environmental brightness:
NOTE: This is based around the assumptions of typical movie content, which contains an implicit end-to-end of about 0.8 from scene to display. For bright environments it can be useful to cancel that out.
Automatically corrects the gamma value depending on ambient lighting conditions (adding a gamma boost for bright rooms).
With ambient illuminance of 16 lux, mpv will pick the 1.0 gamma value (no boost), and slightly increase the boost up until 1.2 for 256 lux.
NOTE: Only implemented on OS X.
Specifies the primaries of the display. Video colors will be adapted to this colorspace when ICC color management is not being used. Valid values are:
Specifies the transfer characteristics (gamma) of the display. Video colors will be adjusted to this curve when ICC color management is not being used. Valid values are:
Note
When using HDR output formats, mpv will encode to the specified curve but it will not set any HDMI flags or other signalling that might be required for the target device to correctly display the HDR signal. The user should independently guarantee this before using these signal formats for display.
Specifies the measured peak brightness of the output display, in cd/m^2 (AKA nits). The interpretation of this brightness depends on the configured --target-trc. In all cases, it imposes a limit on the signal values that will be sent to the display. If the source exceeds this brightness level, a tone mapping filter will be inserted. For HLG, it has the additional effect of parametrizing the inverse OOTF, in order to get colorimetrically consistent results with the mastering display. For SDR, or when using an ICC (profile (--icc-profile), setting this to a value above 100 essentially causes the display to be treated as if it were an HDR display in disguise. (See the note below)
In auto mode (the default), the chosen peak is an appropriate value based on the TRC in use. For SDR curves, it uses 100. For HDR curves, it uses 100 * the transfer function's nominal peak.
Note
When using an SDR transfer function, this is normally not needed, and setting it may lead to very unexpected results. The one time it is useful is if you want to calibrate a HDR display using traditional transfer functions and calibration equipment. In such cases, you can set your HDR display to a high brightness such as 800 cd/m^2, and then calibrate it to a standard curve like gamma2.8. Setting this value to 800 would then instruct mpv to essentially treat it as an HDR display with the given peak. This may be a good alternative in environments where PQ or HLG input to the display is not possible, and makes it possible to use HDR displays with mpv regardless of operating system support for HDMI HDR metadata.
In such a configuration, we highly recommend setting --tone-mapping to mobius or even clip.
Specifies the algorithm used for tone-mapping images onto the target display. This is relevant for both HDR->SDR conversion as well as gamut reduction (e.g. playing back BT.2020 content on a standard gamut display). Valid values are:
Set tone mapping parameters. By default, this is set to the special string default, which maps to an algorithm-specific default value. Ignored if the tone mapping algorithm is not tunable. This affects the following tone mapping algorithms:
Apply desaturation for highlights (default: 0.75). The parameter controls the strength of the desaturation curve. A value of 0.0 completely disables it, while a value of 1.0 means that overly bright colors will tend towards white. (This is not always the case, especially not for highlights that are near primary colors)
Values in between apply progressively more/less aggressive desaturation. This setting helps prevent unnaturally oversaturated colors for super-highlights, by (smoothly) turning them into less saturated (per channel tone mapped) colors instead. This makes images feel more natural, at the cost of chromatic distortions for out-of-range colors. The default value of 0.75 provides a good balance. Setting this to 0.0 preserves the chromatic accuracy of the tone mapping process.
Automatically select the ICC display profile currently specified by the display settings of the operating system.
NOTE: On Windows, the default profile must be an ICC profile. WCS profiles are not supported.
Applications using libmpv with the render API need to provide the ICC profile via MPV_RENDER_PARAM_ICC_PROFILE.
Store and load the 3D LUTs created from the ICC profile in this directory. This can be used to speed up loading, since LittleCMS 2 can take a while to create a 3D LUT. Note that these files contain uncompressed LUTs. Their size depends on the --icc-3dlut-size, and can be very big.
NOTE: This is not cleaned automatically, so old, unused cache files may stick around indefinitely.
Specifies the ICC intent used for the color transformation (when using --icc-profile).
Blend subtitles directly onto upscaled video frames, before interpolation and/or color management (default: no). Enabling this causes subtitles to be affected by --icc-profile, --target-prim, --target-trc, --interpolation, --gamma-factor and --glsl-shaders. It also increases subtitle performance when using --interpolation.
The downside of enabling this is that it restricts subtitles to the visible portion of the video, so you can't have subtitles exist in the black margins below a video (for example).
If video is selected, the behavior is similar to yes, but subs are drawn at the video's native resolution, and scaled along with the video.
Warning
This changes the way subtitle colors are handled. Normally, subtitle colors are assumed to be in sRGB and color managed as such. Enabling this makes them treated as being in the video's color space instead. This is good if you want things like softsubbed ASS signs to match the video colors, but may cause SRT subtitles or similar to look slightly off.
Decides what to do if the input has an alpha component.
Call glFlush() after rendering a frame and before attempting to display it (default: auto). Can fix stuttering in some cases, in other cases probably causes it. The auto mode will call glFlush() only if the renderer is going to wait for a while after rendering, instead of flipping GL front and backbuffers immediately (i.e. it doesn't call it in display-sync mode).
On OSX this is always deactivated because it only causes performance problems and other regressions.
This mode is extremely restricted, and will disable most extended features. That includes high quality scalers and custom shaders!
It is intended for hardware that does not support FBOs (including GLES, which supports it insufficiently), or to get some more performance out of bad or old hardware.
This mode is forced automatically if needed, and this option is mostly useful for debugging. The default of auto will enable it automatically if nothing uses features which require FBOs.
This option might be silently removed in the future.
Store and load compiled GLSL shaders in this directory. Normally, shader compilation is very fast, so this is usually not needed. It mostly matters for GPU APIs that require internally recompiling shaders to other languages, for example anything based on ANGLE or Vulkan. Enabling this can improve startup performance on these platforms.
NOTE: This is not cleaned automatically, so old, unused cache files may stick around indefinitely.
Set the list of tags that should be displayed on the terminal. Tags that are in the list, but are not present in the played file, will not be shown. If a value ends with *, all tags are matched by prefix (though there is no general globbing). Just passing * essentially filtering.
The default includes a common list of tags, call mpv with --list-options to see it.
This is a string list option. See List Options for details.
Control how long before video display target time the frame should be rendered (default: 0.050). If a video frame should be displayed at a certain time, the VO will start rendering the frame earlier, and then will perform a blocking wait until the display time, and only then "swap" the frame to display. The rendering cannot start before the previous frame is displayed, so this value is implicitly limited by the video framerate. With normal video frame rates, the default value will ensure that rendering is always immediately started after the previous frame was displayed. On the other hand, setting a too high value can reduce responsiveness with low FPS value.
For client API users using the render API (or the deprecated opengl-cb API), this option is interesting, because you can stop the render API from limiting your FPS (see mpv_render_context_render() documentation).
This applies only to audio timing modes (e.g. --video-sync=audio). In other modes (--video-sync=display-...), video timing relies on vsync blocking, and this option is not used.
How the player synchronizes audio and video.
If you use this option, you usually want to set it to display-resample to enable a timing mode that tries to not skip or repeat frames when for example playing 24fps video on a 24Hz screen.
The modes starting with display- try to output video frames completely synchronously to the display, using the detected display vertical refresh rate as a hint how fast frames will be displayed on average. These modes change video speed slightly to match the display. See --video-sync-... options for fine tuning. The robustness of this mode is further reduced by making a some idealized assumptions, which may not always apply in reality. Behavior can depend on the VO and the system's video and audio drivers. Media files must use constant framerate. Section-wise VFR might work as well with some container formats (but not e.g. mkv).
Under some circumstances, the player automatically reverts to audio mode for some time or permanently. This can happen on very low framerate video, or if the framerate cannot be detected.
Also in display-sync modes it can happen that interruptions to video playback (such as toggling fullscreen mode, or simply resizing the window) will skip the video frames that should have been displayed, while audio mode will display them after the renderer has resumed (typically resulting in a short A/V desync and the video "catching up").
Before mpv 0.30.0, there was a fallback to audio mode on severe A/V desync. This was changed for the sake of not sporadically stopping. Now, display-desync does what it promises and may desync with audio by an arbitrary amount, until it is manually fixed with a seek.
These modes also require a vsync blocked presentation mode. For OpenGL, this translates to --opengl-swapinterval=1. For Vulkan, it translates to --vulkan-swap-mode=fifo (or fifo-relaxed).
The modes with desync in their names do not attempt to keep audio/video in sync. They will slowly (or quickly) desync, until e.g. the next seek happens. These modes are meant for testing, not serious use.
audio: | Time video frames to audio. This is the most robust mode, because the player doesn't have to assume anything about how the display behaves. The disadvantage is that it can lead to occasional frame drops or repeats. If audio is disabled, this uses the system clock. This is the default mode. |
---|---|
display-resample: | |
Resample audio to match the video. This mode will also try to adjust audio speed to compensate for other drift. (This means it will play the audio at a different speed every once in a while to reduce the A/V difference.) | |
display-resample-vdrop: | |
Resample audio to match the video. Drop video frames to compensate for drift. | |
display-resample-desync: | |
Like the previous mode, but no A/V compensation. | |
display-vdrop: | Drop or repeat video frames to compensate desyncing video. (Although it should have the same effects as audio, the implementation is very different.) |
display-adrop: | Drop or repeat audio data to compensate desyncing video. See --video-sync-adrop-size. This mode will cause severe audio artifacts if the real monitor refresh rate is too different from the reported or forced rate. |
display-desync: | Sync video to display, and let audio play on its own. |
desync: | Sync video according to system clock, and let audio play on its own. |
Maximum speed difference in percent that is applied to video with --video-sync=display-... (default: 1). Display sync mode will be disabled if the monitor and video refresh way do not match within the given range. It tries multiples as well: playing 30 fps video on a 60 Hz screen will duplicate every second frame. Playing 24 fps video on a 60 Hz screen will play video in a 2-3-2-3-... pattern.
The default settings are not loose enough to speed up 23.976 fps video to 25 fps. We consider the pitch change too extreme to allow this behavior by default. Set this option to a value of 5 to enable it.
Note that in the --video-sync=display-resample mode, audio speed will additionally be changed by a small amount if necessary for A/V sync. See --video-sync-max-audio-change.
Set AVOptions on streams opened with libavformat. Unknown or misspelled options are silently ignored. (They are mentioned in the terminal output in verbose mode, i.e. --v. In general we can't print errors, because other options such as e.g. user agent are not available with all protocols, and printing errors for unknown options would end up being too noisy.)
This is a key/value list option. See List Options for details.
(Windows only.) Set process priority for mpv according to the predefined priorities available under Windows.
Possible values of <prio>: idle|belownormal|normal|abovenormal|high|realtime
Warning
Using realtime priority can cause system lockup.
Load a file and add all of its tracks. This is useful to play different files together (for example audio from one file, video from another), or for advanced --lavfi-complex used (like playing two video files at the same time).
Unlike --sub-files and --audio-files, this includes all tracks, and does not cause default stream selection over the "proper" file. This makes it slightly less intrusive. (In mpv 0.28.0 and before, this was not quite strictly enforced.)
This is a path list option. See List Options for details.
Automatically load/select external files (default: yes).
If set to no, then do not automatically load external files as specified by --sub-auto and --audio-file-auto. If external files are forcibly added (like with --sub-files), they will not be auto-selected.
This does not affect playlist expansion, redirection, or other loading of referenced files like with ordered chapters.
Deprecated, use --stream-record, or the dump-cache command.
Record the current stream to the given target file. The target file will always be overwritten without asking.
This was deprecated because it isn't very nice to use. For one, seeking while this is enabled will be directly reflected in the output, which was not useful and annoying.
Write received/read data from the demuxer to the given output file. The output file will always be overwritten without asking. The output format is determined by the extension of the output file.
Switching streams or seeking during recording might result in recording being stopped and/or broken files. Use with care.
Seeking outside of the demuxer cache will result in "skips" in the output file, but seeking within the demuxer cache should not affect recording. One exception is when you seek back far enough to exceed the forward buffering size, in which case the cache stops actively reading. This will return in dropped data if it's a live stream.
If this is set at runtime, the old file is closed, and the new file is opened. Note that this will write only data that is appended at the end of the cache, and the already cached data cannot be written. You can try the dump-cache command as an alternative.
External files (--audio-file etc.) are ignored by this, it works on the "main" file only. Using this with files using ordered chapters or EDL files will also not work correctly in general.
There are some glitches with this because it uses FFmpeg's libavformat for writing the output file. For example, it's typical that it will only work if the output format is the same as the input format. This is the case even if it works with the ffmpeg tool. One reason for this is that ffmpeg and its libraries contain certain hacks and workarounds for these issues, that are unavailable to outside users.
This replaces --record-file. It is similar to the ancient/removed --stream-capture/-capture options, and provides better behavior in most cases (i.e. actually works).
Set a "complex" libavfilter filter, which means a single filter graph can take input from multiple source audio and video tracks. The graph can result in a single audio or video output (or both).
Currently, the filter graph labels are used to select the participating input tracks and audio/video output. The following rules apply:
Each label can be used only once. If you want to use e.g. an audio stream for multiple filters, you need to use the asplit filter. Multiple video or audio outputs are not possible, but you can use filters to merge them into one.
It's not possible to change the tracks connected to the filter at runtime, unless you explicitly change the lavfi-complex property and set new track assignments. When the graph is changed, the track selection is changed according to the used labels as well.
Other tracks, as long as they're not connected to the filter, and the corresponding output is not connected to the filter, can still be freely changed with the normal methods.
Note that the normal filter chains (--af, --vf) are applied between the complex graphs (e.g. ao label) and the actual output.
Examples
See the FFmpeg libavfilter documentation for details on the available filters.
Codepage for various input metadata (default: utf-8). This affects how file tags, chapter titles, etc. are interpreted. You can for example set this to auto to enable autodetection of the codepage. (This is not the default because non-UTF-8 codepages are an obscure fringe use-case.)
See --sub-codepage option on how codepages are specified and further details regarding autodetection and codepage conversion. (The underlying code is the same.)
Conversion is not applied to metadata that is updated at runtime.
Run an internal unit test. There are multiple, and the name specifies which.
The special value all-simple runs all tests which do not need further setup (other arguments and such). Some tests may need additional arguments to do anything useful.
On success, the player binary exits with exit status 0, otherwise it returns with an undefined non-0 exit status (it may crash or abort itself on test failures).
This is only enabled if built with --enable-tests, and should normally be enabled and used by developers only.
Audio output drivers are interfaces to different audio output facilities. The syntax is:
If the list has a trailing ',', mpv will fall back on drivers not contained in the list.
Note
See --ao=help for a list of compiled-in audio output drivers. The driver --ao=alsa is preferred. --ao=pulse is preferred on systems where PulseAudio is used. On BSD systems, --ao=oss or --ao=sndio may work (the latter being experimental).
Available audio output drivers are:
ALSA audio output driver
See ALSA audio output options for options specific to this AO.
Warning
To get multichannel/surround audio, use --audio-channels=auto. The default for this option is auto-safe, which makes this audio output explicitly reject multichannel output, as there is no way to detect whether a certain channel layout is actually supported.
You can also try using the upmix plugin. This setup enables multichannel audio on the default device with automatic upmixing with shared access, so playing stereo and multichannel audio at the same time will work as expected.
OSS audio output driver
The following global options are supported by this audio output:
JACK (Jack Audio Connection Kit) audio output driver.
The following global options are supported by this audio output:
Native Mac OS X audio output driver using AudioUnits and the CoreAudio sound server.
Automatically redirects to coreaudio_exclusive when playing compressed formats.
The following global options are supported by this audio output:
OpenAL audio output driver
PulseAudio audio output driver
The following global options are supported by this audio output:
Enable hacks to workaround PulseAudio timing bugs (default: no). If enabled, mpv will do elaborate latency calculations on its own. If disabled, it will use PulseAudio automatically updated timing information. Disabling this might help with e.g. networked audio or some plugins, while enabling it might help in some unknown situations (it used to be required to get good behavior on old PulseAudio versions).
If you have stuttering video when using pulse, try to enable this option. (Or try to update PulseAudio.)
SDL 1.2+ audio output driver. Should work on any platform supported by SDL 1.2, but may require the SDL_AUDIODRIVER environment variable to be set appropriately for your system.
Note
This driver is for compatibility with extremely foreign environments, such as systems where none of the other drivers are available.
The following global options are supported by this audio output:
Produces no audio output but maintains video playback speed. You can use --ao=null --ao-null-untimed for benchmarking.
The following global options are supported by this audio output:
Raw PCM/WAVE file writer audio output
The following global options are supported by this audio output:
Audio output to an RSound daemon. Use --audio-device=rsound/<hostname> to set the host name (with <hostname> replaced, without the < >).
Note
Completely useless, unless you intend to run RSound. Not to be confused with RoarAudio, which is something completely different.
Audio output to the OpenBSD sndio sound system
Note
Experimental. There are known bugs and issues.
(Note: only supports mono, stereo, 4.0, 5.1 and 7.1 channel layouts.)
Video output drivers are interfaces to different video output facilities. The syntax is:
If the list has a trailing ,, mpv will fall back on drivers not contained in the list.
Note
See --vo=help for a list of compiled-in video output drivers.
The recommended output driver is --vo=gpu, which is the default. All other drivers are for compatibility or special purposes. If the default does not work, it will fallback to other drivers (in the same order as listed by --vo=help).
Available video output drivers are:
Uses the XVideo extension to enable hardware-accelerated display. This is the most compatible VO on X, but may be low-quality, and has issues with OSD and subtitle display.
Note
This driver is for compatibility with old systems.
The following global options are supported by this video output:
Select the source from which the color key is taken (default: cur).
Sets the color key drawing method (default: man).
Shared memory video output driver without hardware acceleration that works whenever X11 is present.
Since mpv 0.30.0, you may need to use --profile=sw-fast to get decent performance.
Note
This is a fallback only, and should not be normally used.
Uses the VDPAU interface to display and optionally also decode video. Hardware decoding is used with --hwdec=vdpau.
Note
Earlier versions of mpv (and MPlayer, mplayer2) provided sub-options to tune vdpau post-processing, like deint, sharpen, denoise, chroma-deint, pullup, hqscaling. These sub-options are deprecated, and you should use the vdpaupp video filter instead.
The following global options are supported by this video output:
(Deprecated. See note about vdpaupp.)
For positive values, apply a sharpening algorithm to the video, for negative values a blurring algorithm (default: 0).
(Deprecated. See note about vdpaupp.)
Apply a noise reduction algorithm to the video (default: 0; no noise reduction).
(Deprecated. See note about vdpaupp.)
Select deinterlacing mode (default: 0). In older versions (as well as MPlayer/mplayer2) you could use this option to enable deinterlacing. This doesn't work anymore, and deinterlacing is enabled with either the d key (by default mapped to the command cycle deinterlace), or the --deinterlace option. Also, to select the default deint mode, you should use something like --vf-defaults=vdpaupp:deint-mode=temporal instead of this sub-option.
(Deprecated. See note about vdpaupp.)
Makes temporal deinterlacers operate both on luma and chroma (default). Use no-chroma-deint to solely use luma and speed up advanced deinterlacing. Useful with slow video memory.
(Deprecated. See note about vdpaupp.)
Try to apply inverse telecine, needs motion adaptive temporal deinterlacing.
(Deprecated. See note about vdpaupp.)
Using the VDPAU frame queuing functionality controlled by the queuetime options makes mpv's frame flip timing less sensitive to system CPU load and allows mpv to start decoding the next frame(s) slightly earlier, which can reduce jitter caused by individual slow-to-decode frames. However, the NVIDIA graphics drivers can make other window behavior such as window moves choppy if VDPAU is using the blit queue (mainly happens if you have the composite extension enabled) and this feature is active. If this happens on your system and it bothers you then you can set the queuetime value to 0 to disable this feature. The settings to use in windowed and fullscreen mode are separate because there should be no reason to disable this for fullscreen mode (as the driver issue should not affect the video itself).
You can queue more frames ahead by increasing the queuetime values and the output_surfaces count (to ensure enough surfaces to buffer video for a certain time ahead you need at least as many surfaces as the video has frames during that time, plus two). This could help make video smoother in some cases. The main downsides are increased video RAM requirements for the surfaces and laggier display response to user commands (display changes only become visible some time after they're queued). The graphics driver implementation may also have limits on the length of maximum queuing time or number of queued surfaces that work well or at all.
Video output driver that uses the Direct3D interface.
Note
This driver is for compatibility with systems that don't provide proper OpenGL drivers, and where ANGLE does not perform well.
Note
Before to 0.21.0, direct3d_shaders and direct3d were different, with direct3d not using shader by default. Now both use shaders by default, and direct3d_shaders is a deprecated alias. Use the --vo-direct3d-prefer-stretchrect or the --vo-direct3d-disable-shaders options to get the old behavior of direct3d.
The following global options are supported by this video output:
Debug options. These might be incorrect, might be removed in the future, might crash, might cause slow downs, etc. Contact the developers if you actually need any of these for performance or proper operation.
Only affects operation with shaders/texturing enabled, and (E)OSD. Possible values:
General purpose, customizable, GPU-accelerated video output driver. It supports extended scaling methods, dithering, color management, custom shaders, HDR, and more.
See GPU renderer options for options specific to this VO.
By default, it tries to use fast and fail-safe settings. Use the gpu-hq profile to use this driver with defaults set to high quality rendering. The profile can be applied with --profile=gpu-hq and its contents can be viewed with --show-profile=gpu-hq.
This VO abstracts over several possible graphics APIs and windowing contexts, which can be influenced using the --gpu-api and --gpu-context options.
Hardware decoding over OpenGL-interop is supported to some degree. Note that in this mode, some corner case might not be gracefully handled, and color space conversion and chroma upsampling is generally in the hand of the hardware decoder APIs.
gpu makes use of FBOs by default. Sometimes you can achieve better quality or performance by changing the --gpu-fbo-format option to rgb16f, rgb32f or rgb. Known problems include Mesa/Intel not accepting rgb16, Mesa sometimes not being compiled with float texture support, and some OS X setups being very slow with rgb16 but fast with rgb32f. If you have problems, you can also try enabling the --gpu-dumb-mode=yes option.
SDL 2.0+ Render video output driver, depending on system with or without hardware acceleration. Should work on all platforms supported by SDL 2.0. For tuning, refer to your copy of the file SDL_hints.h.
Note
This driver is for compatibility with systems that don't provide proper graphics drivers.
The following global options are supported by this video output:
Intel VA API video output driver with support for hardware decoding. Note that there is absolutely no reason to use this, other than compatibility. This is low quality, and has issues with OSD.
Note
This driver is for compatibility with crappy systems. You can use vaapi hardware decoding with --vo=gpu too.
The following global options are supported by this video output:
Select deinterlacing algorithm. Note that by default deinterlacing is initially always off, and needs to be enabled with the d key (default key binding for cycle deinterlace).
This option doesn't apply if libva supports video post processing (vpp). In this case, the default for deint-mode is no, and enabling deinterlacing via user interaction using the methods mentioned above actually inserts the vavpp video filter. If vpp is not actually supported with the libva backend in use, you can use this option to forcibly enable VO based deinterlacing.
Produces no video output. Useful for benchmarking.
Usually, it's better to disable video with --no-video instead.
The following global options are supported by this video output:
Color ASCII art video output driver that works on a text console.
Note
This driver is a joke.
Color Unicode art video output driver that works on a text console. Depends on support of true color by modern terminals to display the images at full color range. On Windows it requires an ansi terminal such as mintty.
Since mpv 0.30.0, you may need to use --profile=sw-fast to get decent performance.
Select how to write the pixels to the terminal.
Output each frame into an image file in the current directory. Each file takes the frame number padded with leading zeros as name.
The following global options are supported by this video output:
Select the image file format.
For use with libmpv direct embedding. As a special case, on OS X it is used like a normal VO within mpv (cocoa-cb). Otherwise useless in any other contexts. (See <mpv/render.h>.)
This also supports many of the options the gpu VO has, depending on the backend.
Native video output on the Raspberry Pi using the MMAL API.
This is deprecated. Use --vo=gpu instead, which is the default and provides the same functionality. The rpi VO will be removed in mpv 0.23.0. Its functionality was folded into --vo=gpu, which now uses RPI hardware decoding by treating it as a hardware overlay (without applying GL filtering). Also to be changed in 0.23.0: the --fs flag will be reset to "no" by default (like on the other platforms).
The following deprecated global options are supported by this video output:
Video output driver using Kernel Mode Setting / Direct Rendering Manager. Should be used when one doesn't want to install full-blown graphical environment (e.g. no X). Does not support hardware acceleration (if you need this, check the drm backend for gpu VO).
Since mpv 0.30.0, you may need to use --profile=sw-fast to get decent performance.
The following global options are supported by this video output:
Mode to use (resolution and frame rate). Possible values:
preferred: | Use the preferred mode for the screen on the selected connector. (default) |
---|---|
highest: | Use the mode with the highest resolution available on the selected connector. |
N: | Select mode by index. |
WxH[@R]: | Specify mode by width, height, and optionally refresh rate. In case several modes match, selects the mode that comes first in the EDID list of modes. |
Use --drm-mode=help to get a list of available modes for all active connectors.
Toggle use of atomic modesetting. Mostly useful for debugging.
no: | Use legacy modesetting. |
---|---|
auto: | Use atomic modesetting, falling back to legacy modesetting if not available. (default) |
Note: Only affects gpu-context=drm. vo=drm supports legacy modesetting only.
Select the DRM plane to which video and OSD is drawn to, under normal circumstances. The plane can be specified as primary, which will pick the first applicable primary plane; overlay, which will pick the first applicable overlay plane; or by index. The index is zero based, and related to the CRTC. (default: primary)
When using this option with the drmprime-drm hwdec interop, only the OSD is rendered to this plane.
Select the DRM plane to use for video with the drmprime-drm hwdec interop (used by e.g. the rkmpp hwdec on RockChip SoCs, and v4l2 hwdec:s on various other SoC:s). The plane is unused otherwise. This option accepts the same values as --drm-draw-plane. (default: overlay)
To be able to successfully play 4K video on various SoCs you might need to set --drm-draw-plane=overlay --drm-drmprime-video-plane=primary and setting --drm-draw-surface-size=1920x1080, to render the OSD at a lower resolution (the video when handled by the hwdec will be on the drmprime-video plane and at full 4K resolution)
Select the DRM format to use (default: xrgb8888). This allows you to choose the bit depth of the DRM mode. xrgb8888 is your usual 24 bit per pixel/8 bits per channel packed RGB format with 8 bits of padding. xrgb2101010 is a packed 30 bits per pixel/10 bits per channel packed RGB format with 2 bits of padding.
There are cases when xrgb2101010 will work with the drm VO, but not with the drm backend for the gpu VO. This is because with the gpu VO, in addition to requiring support in your DRM driver, requires support for xrgb2101010 in your EGL driver
Sets the size of the surface used on the draw plane. The surface will then be upscaled to the current screen resolution. This option can be useful when used together with the drmprime-drm hwdec interop at high resolutions, as it allows scaling the draw plane (which in this case only handles the OSD) down to a size the GPU can handle.
When used without the drmprime-drm hwdec interop this option will just cause the video to get rendered at a different resolution and then scaled to screen size.
Note: this option is only available with DRM atomic support. (default: display resolution)
Renders IMGFMT_MEDIACODEC frames directly to an android.view.Surface. Requires --hwdec=mediacodec for hardware decoding, along with --vo=mediacodec_embed and --wid=(intptr_t)(*android.view.Surface).
Since this video output driver uses native decoding and rendering routines, many of mpv's features (subtitle rendering, OSD/OSC, video filters, etc) are not available with this driver.
To use hardware decoding with --vo=gpu instead, use --hwdec=mediacodec-copy along with --gpu-context=android.
Shared memory video output driver without hardware acceleration that works whenever Wayland is present.
Since mpv 0.30.0, you may need to use --profile=sw-fast to get decent performance.
Note
This is a fallback only, and should not be normally used.
Audio filters allow you to modify the audio stream and its properties. The syntax is:
Note
To get a full list of available audio filters, see --af=help.
Also, keep in mind that most actual filters are available via the lavfi wrapper, which gives you access to most of libavfilter's filters. This includes all filters that have been ported from MPlayer to libavfilter.
The --vf description describes how libavfilter can be used and how to workaround deprecated mpv filters.
See --vf group of options for info on how --af-defaults, --af-add, --af-pre, --af-del, --af-clr, and possibly others work.
Available filters are:
Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports 16-bit native-endian input format, maximum 6 channels. The output is big-endian when outputting a raw AC-3 stream, native-endian when outputting to S/PDIF. If the input sample rate is not 48 kHz, 44.1 kHz or 32 kHz, it will be resampled to 48 kHz.
The bitrate use for the AC-3 stream. Set it to 384 to get 384 kbps.
The default is 640. Some receivers might not be able to handle this.
Valid values: 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640.
The special value auto selects a default bitrate based on the input channel number:
1ch: | 96 |
---|---|
2ch: | 192 |
3ch: | 224 |
4ch: | 384 |
5ch: | 448 |
6ch: | 448 |
Does not do any format conversion itself. Rather, it may cause the filter system to insert necessary conversion filters before or after this filter if needed. It is primarily useful for controlling the audio format going into other filters. To specify the format for audio output, see --audio-format, --audio-samplerate, and --audio-channels. This filter is able to force a particular format, whereas --audio-* may be overridden by the ao based on output compatibility.
All parameters are optional. The first 3 parameters restrict what the filter accepts as input. They will therefore cause conversion filters to be inserted before this one. The out- parameters tell the filters or audio outputs following this filter how to interpret the data without actually doing a conversion. Setting these will probably just break things unless you really know you want this for some reason, such as testing or dealing with broken media.
<out-srate>
<out-channels>
NOTE: this filter used to be named force. The old format filter used to do conversion itself, unlike this one which lets the filter system handle the conversion.
Scales audio tempo without altering pitch, optionally synced to playback speed (default).
This works by playing 'stride' ms of audio at normal speed then consuming 'stride*scale' ms of input audio. It pieces the strides together by blending 'overlap'% of stride with audio following the previous stride. It optionally performs a short statistical analysis on the next 'search' ms of audio to determine the best overlap position.
Set response to speed change.
Reverses effect of filter. Scales pitch without altering tempo. Add this to your input.conf to step by musical semi-tones:
[ multiply speed 0.9438743126816935 ] multiply speed 1.059463094352953
Warning
Loses sync with video.
Examples
High quality pitch correction with librubberband. This can be used in place of scaletempo, and will be used to adjust audio pitch when playing at speed different from normal. It can also be used to adjust audio pitch without changing playback speed.
This filter has a number of additional sub-options. You can list them with mpv --af=rubberband=help. This will also show the default values for each option. The options are not documented here, because they are merely passed to librubberband. Look at the librubberband documentation to learn what each option does: http://breakfastquay.com/rubberband/code-doc/classRubberBand_1_1RubberBandStretcher.html (The mapping of the mpv rubberband filter sub-option names and values to those of librubberband follows a simple pattern: "Option" + Name + Value.)
This filter supports the following af-command commands:
Filter audio using FFmpeg's libavfilter.
Libavfilter graph. See lavfi video filter for details - the graph syntax is the same.
Warning
Don't forget to quote libavfilter graphs as described in the lavfi video filter section.
Video filters allow you to modify the video stream and its properties. All of the information described in this section applies to audio filters as well (generally using the prefix --af instead of --vf).
The exact syntax is:
Setup a chain of video filters. This consists on the filter name, and an option list of parameters after =. The parameters are separated by : (not ,, as that starts a new filter entry).
Before the filter name, a label can be specified with @name:, where name is an arbitrary user-given name, which identifies the filter. This is only needed if you want to toggle the filter at runtime.
A ! before the filter name means the filter is disabled by default. It will be skipped on filter creation. This is also useful for runtime filter toggling.
See the vf command (and toggle sub-command) for further explanations and examples.
The general filter entry syntax is:
["@"<label-name>":"] ["!"] <filter-name> [ "=" <filter-parameter-list> ]
or for the special "toggle" syntax (see vf command):
"@"<label-name>
and the filter-parameter-list:
<filter-parameter> | <filter-parameter> "," <filter-parameter-list>
and filter-parameter:
( <param-name> "=" <param-value> ) | <param-value>
param-value can further be quoted in [ / ] in case the value contains characters like , or =. This is used in particular with the lavfi filter, which uses a very similar syntax as mpv (MPlayer historically) to specify filters and their parameters.
Filters can be manipulated at run time. You can use @ labels as described above in combination with the vf command (see COMMAND INTERFACE) to get more control over this. Initially disabled filters with ! are useful for this as well.
You can also set defaults for each filter. The defaults are applied before the normal filter parameters. This is deprecated and never worked for the libavfilter bridge.
Note
To get a full list of available video filters, see --vf=help and http://ffmpeg.org/ffmpeg-filters.html .
Also, keep in mind that most actual filters are available via the lavfi wrapper, which gives you access to most of libavfilter's filters. This includes all filters that have been ported from MPlayer to libavfilter.
Most builtin filters are deprecated in some ways, unless they're only available in mpv (such as filters which deal with mpv specifics, or which are implemented in mpv only).
If a filter is not builtin, the lavfi-bridge will be automatically tried. This bridge does not support help output, and does not verify parameters before the filter is actually used. Although the mpv syntax is rather similar to libavfilter's, it's not the same. (Which means not everything accepted by vf_lavfi's graph option will be accepted by --vf.)
You can also prefix the filter name with lavfi- to force the wrapper. This is helpful if the filter name collides with a deprecated mpv builtin filter. For example --vf=lavfi-scale=args would use libavfilter's scale filter over mpv's deprecated builtin one.
Video filters are managed in lists. There are a few commands to manage the filter list.
With filters that support it, you can access parameters by their name.
Available mpv-only filters are:
Applies video parameter overrides, with optional conversion. By default, this overrides the video's parameters without conversion (except for the fmt parameter), but can be made to perform an appropriate conversion with convert=yes for parameters for which conversion is supported.
Image format name, e.g. rgb15, bgr24, 420p, etc. (default: don't change).
This filter always performs conversion to the given format.
Note
For a list of available formats, use --vf=format=fmt=help.
Force conversion of color parameters (default: no).
If this is disabled (the default), the only conversion that is possibly performed is format conversion if <fmt> is set. All other parameters (like <colormatrix>) are forced without conversion. This mode is typically useful when files have been incorrectly tagged.
If this is enabled, libswscale or zimg is used if any of the parameters mismatch. zimg is used of the input/output image formats are supported by mpv's zimg wrapper, and if --sws-allow-zimg=yes is used. Both libraries may not support all kinds of conversions. This typically results in silent incorrect conversion. zimg has in many cases a better chance of performing the conversion correctly.
In both cases, the color parameters are set on the output stage of the image format conversion (if fmt was set). The difference is that with convert=no, the color parameters are not passed on to the converter.
If input and output video parameters are the same, conversion is always skipped.
Examples
Results in true conversion to ycgco, assuming the renderer supports it (--vo=gpu normally does). You can add --vo=xv to force a VO which definitely does not support it, which should show incorrect colors as confirmation.
Using --sws-allow-zimg=no (or disabling zimg at build time) will use libswscale, which cannot perform this conversion as of this writing.
Controls the YUV to RGB color space conversion when playing video. There are various standards. Normally, BT.601 should be used for SD video, and BT.709 for HD video. (This is done by default.) Using incorrect color space results in slightly under or over saturated and shifted colors.
These options are not always supported. Different video outputs provide varying degrees of support. The gpu and vdpau video output drivers usually offer full support. The xv output can set the color space if the system video driver supports it, but not input and output levels. The scale video filter can configure color space and input levels, but only if the output format is RGB (if the video output driver supports RGB output, you can force this with -vf scale,format=rgba).
If this option is set to auto (which is the default), the video's color space flag will be used. If that flag is unset, the color space will be selected automatically. This is done using a simple heuristic that attempts to distinguish SD and HD video. If the video is larger than 1279x576 pixels, BT.709 (HD) will be used; otherwise BT.601 (SD) is selected.
Available color spaces are:
auto: | automatic selection (default) |
---|---|
bt.601: | ITU-R BT.601 (SD) |
bt.709: | ITU-R BT.709 (HD) |
bt.2020-ncl: | ITU-R BT.2020 non-constant luminance system |
bt.2020-cl: | ITU-R BT.2020 constant luminance system |
smpte-240m: | SMPTE-240M |
YUV color levels used with YUV to RGB conversion. This option is only necessary when playing broken files which do not follow standard color levels or which are flagged wrong. If the video does not specify its color range, it is assumed to be limited range.
The same limitations as with <colormatrix> apply.
Available color ranges are:
auto: | automatic selection (normally limited range) (default) |
---|---|
limited: | limited range (16-235 for luma, 16-240 for chroma) |
full: | full range (0-255 for both luma and chroma) |
RGB primaries the source file was encoded with. Normally this should be set in the file header, but when playing broken or mistagged files this can be used to override the setting.
This option only affects video output drivers that perform color management, for example gpu with the target-prim or icc-profile suboptions set.
If this option is set to auto (which is the default), the video's primaries flag will be used. If that flag is unset, the color space will be selected automatically, using the following heuristics: If the <colormatrix> is set or determined as BT.2020 or BT.709, the corresponding primaries are used. Otherwise, if the video height is exactly 576 (PAL), BT.601-625 is used. If it's exactly 480 or 486 (NTSC), BT.601-525 is used. If the video resolution is anything else, BT.709 is used.
Available primaries are:
auto: | automatic selection (default) |
---|---|
bt.601-525: | ITU-R BT.601 (SD) 525-line systems (NTSC, SMPTE-C) |
bt.601-625: | ITU-R BT.601 (SD) 625-line systems (PAL, SECAM) |
bt.709: | ITU-R BT.709 (HD) (same primaries as sRGB) |
bt.2020: | ITU-R BT.2020 (UHD) |
apple: | Apple RGB |
adobe: | Adobe RGB (1998) |
prophoto: | ProPhoto RGB (ROMM) |
cie1931: | CIE 1931 RGB |
dci-p3: | DCI-P3 (Digital Cinema) |
v-gamut: | Panasonic V-Gamut primaries |
Gamma function the source file was encoded with. Normally this should be set in the file header, but when playing broken or mistagged files this can be used to override the setting.
This option only affects video output drivers that perform color management.
If this option is set to auto (which is the default), the gamma will be set to BT.1886 for YCbCr content, sRGB for RGB content and Linear for XYZ content.
Available gamma functions are:
auto: | automatic selection (default) |
---|---|
bt.1886: | ITU-R BT.1886 (EOTF corresponding to BT.601/BT.709/BT.2020) |
srgb: | IEC 61966-2-4 (sRGB) |
linear: | Linear light |
gamma1.8: | Pure power curve (gamma 1.8) |
gamma2.0: | Pure power curve (gamma 2.0) |
gamma2.2: | Pure power curve (gamma 2.2) |
gamma2.4: | Pure power curve (gamma 2.4) |
gamma2.6: | Pure power curve (gamma 2.6) |
gamma2.8: | Pure power curve (gamma 2.8) |
prophoto: | ProPhoto RGB (ROMM) curve |
pq: | ITU-R BT.2100 PQ (Perceptual quantizer) curve |
hlg: | ITU-R BT.2100 HLG (Hybrid Log-gamma) curve |
v-log: | Panasonic V-Log transfer curve |
s-log1: | Sony S-Log1 transfer curve |
s-log2: | Sony S-Log2 transfer curve |
Reference peak illumination for the video file, relative to the signal's reference white level. This is mostly interesting for HDR, but it can also be used tone map SDR content to simulate a different exposure. Normally inferred from tags such as MaxCLL or mastering metadata.
The default of 0.0 will default to the source's nominal peak luminance.
Light type of the scene. This is mostly correctly inferred based on the gamma function, but it can be useful to override this when viewing raw camera footage (e.g. V-Log), which is normally scene-referred instead of display-referred.
Available light types are:
auto: | Automatic selection (default) |
---|---|
display: | Display-referred light (most content) |
hlg: | Scene-referred using the HLG OOTF (e.g. HLG content) |
709-1886: | Scene-referred using the BT709+BT1886 interaction |
gamma1.2: | Scene-referred using a pure power OOTF (gamma=1.2) |
Filter video using FFmpeg's libavfilter.
The libavfilter graph string. The filter must have a single video input pad and a single video output pad.
See https://ffmpeg.org/ffmpeg-filters.html for syntax and available filters.
Warning
If you want to use the full filter syntax with this option, you have to quote the filter graph in order to prevent mpv's syntax and the filter graph syntax from clashing. To prevent a quoting and escaping mess, consider using --lavfi-complex if you know which video track you want to use from the input file. (There is only one video track for nearly all video files anyway.)
Examples
If libavfilter inserts filters for pixel format conversion, this option gives the flags which should be passed to libswscale. This option is numeric and takes a bit-wise combination of SWS_ flags.
See http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libswscale/swscale.h.
Set AVFilterGraph options. These should be documented by FFmpeg.
Example
Moves subtitle rendering to an arbitrary point in the filter chain, or force subtitle rendering in the video filter as opposed to using video output OSD support.
Examples
Loads a VapourSynth filter script. This is intended for streamed processing: mpv actually provides a source filter, instead of using a native VapourSynth video source. The mpv source will answer frame requests only within a small window of frames (the size of this window is controlled with the buffered-frames parameter), and requests outside of that will return errors. As such, you can't use the full power of VapourSynth, but you can use certain filters.
Warning
Do not use this filter, unless you have expert knowledge in VapourSynth, and know how to fix bugs in the mpv VapourSynth wrapper code.
If you just want to play video generated by VapourSynth (i.e. using a native VapourSynth video source), it's better to use vspipe and a pipe or FIFO to feed the video to mpv. The same applies if the filter script requires random frame access (see buffered-frames parameter).
Filename of the script source. Currently, this is always a python script (.vpy in VapourSynth convention).
The variable video_in is set to the mpv video source, and it is expected that the script reads video from it. (Otherwise, mpv will decode no video, and the video packet queue will overflow, eventually leading to only audio playing, or worse.)
The filter graph created by the script is also expected to pass through timestamps using the _DurationNum and _DurationDen frame properties.
See the end of the option list for a full list of script variables defined by mpv.
Example:
import vapoursynth as vs core = vs.get_core() core.std.AddBorders(video_in, 10, 10, 20, 20).set_output()
Warning
The script will be reloaded on every seek. This is done to reset the filter properly on discontinuities.
Maximum number of decoded video frames that should be buffered before the filter (default: 4). This specifies the maximum number of frames the script can request in backward direction.
E.g. if buffered-frames=5, and the script just requested frame 15, it can still request frame 10, but frame 9 is not available anymore. If it requests frame 30, mpv will decode 15 more frames, and keep only frames 25-30.
The only reason why this buffer exists is to serve the random access requests the VapourSynth filter can make.
The VapourSynth API has a getFrameAsync function, which takes an absolute frame number. Source filters must respond to all requests. For example, a source filter can request frame 2432, and then frame 3. Source filters typically implement this by pre-indexing the entire file.
mpv on the other hand is stream oriented, and does not allow filters to seek. (And it would not make sense to allow it, because it would ruin performance.) Filters get frames sequentially in playback direction, and cannot request them out of order.
To compensate for this mismatch, mpv allows the filter to access frames within a certain window. buffered-frames controls the size of this window. Most VapourSynth filters happen to work with this, because mpv requests frames sequentially increasing from it, and most filters only require frames "close" to the requested frame.
If the filter requests a frame that has a higher frame number than the highest buffered frame, new frames will be decoded until the requested frame number is reached. Excessive frames will be flushed out in a FIFO manner (there are only at most buffered-frames in this buffer).
If the filter requests a frame that has a lower frame number than the lowest buffered frame, the request cannot be satisfied, and an error is returned to the filter. This kind of error is not supposed to happen in a "proper" VapourSynth environment. What exactly happens depends on the filters involved.
Increasing this buffer will not improve performance. Rather, it will waste memory, and slow down seeks (when enough frames to fill the buffer need to be decoded at once). It is only needed to prevent the error described in the previous paragraph.
How many frames a filter requires depends on filter implementation details, and mpv has no way of knowing. A scale filter might need only 1 frame, an interpolation filter may require a small number of frames, and the Reverse filter will require an infinite number of frames.
If you want reliable operation to the full extend VapourSynth is capable, use vspipe.
The actual number of buffered frames also depends on the value of the concurrent-frames option. Currently, both option values are multiplied to get the final buffer size.
Number of frames that should be requested in parallel. The level of concurrency depends on the filter and how quickly mpv can decode video to feed the filter. This value should probably be proportional to the number of cores on your machine. Most time, making it higher than the number of cores can actually make it slower.
Technically, mpv will call the VapourSynth getFrameAsync function in a loop, until there are concurrent-frames frames that have not been returned by the filter yet. This also assumes that the rest of the mpv filter chain reads the output of the vapoursynth filter quickly enough. (For example, if you pause the player, filtering will stop very soon, because the filtered frames are waiting in a queue.)
Actual concurrency depends on many other factors.
By default, this uses the special value auto, which sets the option to the number of detected logical CPU cores.
The following .vpy script variables are defined by mpv:
FPS value as reported by file headers. This value can be wrong or completely broken (e.g. 0 or NaN). Even if the value is correct, if another filter changes the real FPS (by dropping or inserting frames), the value of this variable will not be useful. Note that the --fps command line option overrides this value.
Useful for some filters which insist on having a FPS.
VA-API video post processing. Requires the system to support VA-API, i.e. Linux/BSD only. Works with --vo=vaapi and --vo=gpu only. Currently deinterlaces. This filter is automatically inserted if deinterlacing is requested (either using the d key, by default mapped to the command cycle deinterlace, or the --deinterlace option).
Select the deinterlacing algorithm.
no: | Deinterlace all frames (default). |
---|---|
yes: | Only deinterlace frames marked as interlaced. |
no: | Use the API as it was interpreted by older Mesa drivers. While this interpretation was more obvious and inuitive, it was apparently wrong, and not shared by Intel driver developers. |
---|---|
yes: | Use Intel interpretation of surface forward and backwards references (default). This is what Intel drivers and newer Mesa drivers expect. Matters only for the advanced deinterlacing algorithms. |
VDPAU video post processing. Works with --vo=vdpau and --vo=gpu only. This filter is automatically inserted if deinterlacing is requested (either using the d key, by default mapped to the command cycle deinterlace, or the --deinterlace option). When enabling deinterlacing, it is always preferred over software deinterlacer filters if the vdpau VO is used, and also if gpu is used and hardware decoding was activated at least once (i.e. vdpau was loaded).
Select deinterlacing mode (default: temporal).
Note that there's currently a mechanism that allows the vdpau VO to change the deint-mode of auto-inserted vdpaupp filters. To avoid confusion, it's recommended not to use the --vo=vdpau suboptions related to filtering.
Direct3D 11 video post processing. Currently requires D3D11 hardware decoding for use.
Compute video frame fingerprints and provide them as metadata. Actually, it currently barely deserved to be called fingerprint, because it does not compute "proper" fingerprints, only tiny downscaled images (but which can be used to compute image hashes or for similarity matching).
The main purpose of this filter is to support the skip-logo.lua script. If this script is dropped, or mpv ever gains a way to load user-defined filters (other than VapourSynth), this filter will be removed. Due to the "special" nature of this filter, it will be removed without warning.
The intended way to read from the filter is using vf-metadata (also see clear-on-query filter parameter). The property will return a list of key/value pairs as follows:
fp0.pts = 1.2345 fp0.hex = 1234abcdef...bcde fp1.pts = 1.4567 fp1.hex = abcdef1234...6789 ... fpN.pts = ... fpN.hex = ... type = gray-hex-16x16
Each fp<N> entry is for a frame. The pts entry specifies the timestamp of the frame (within the filter chain; in simple cases this is the same as the display timestamp). The hex field is the hex encoded fingerprint, whose size and meaning depend on the type filter option. The type field has the same value as the option the filter was created with.
This returns the frames that were filtered since the last query of the property. If clear-on-query=no was set, a query doesn't reset the list of frames. In both cases, a maximum of 10 frames is returned. If there are more frames, the oldest frames are discarded. Frames are returned in filter order.
(This doesn't return a structured list for the per-frame details because the internals of the vf-metadata mechanism suck. The returned format may change in the future.)
This filter uses zimg for speed and profit. However, it will fallback to libswscale in a number of situations: lesser pixel formats, unaligned data pointers or strides, or if zimg fails to initialize for unknown reasons. In these cases, the filter will use more CPU. Also, it will output different fingerprints, because libswscale cannot perform the full range expansion we normally request from zimg. As a consequence, the filter may be slower and not work correctly in random situations.
What fingerprint to compute. Available types are:
gray-hex-8x8: | grayscale, 8 bit, 8x8 size |
---|---|
gray-hex-16x16: | grayscale, 8 bit, 16x16 size (default) |
Both types simply remove all colors, downscale the image, concatenate all pixel values to a byte array, and convert the array to a hex string.
Convert video to RGB using the OpenGL renderer normally used with --vo=gpu. This requires that the EGL implementation supports off-screen rendering on the default display. (This is the case with Mesa.)
Sub-options:
Warning
This is highly experimental. Performance is bad, and it will not work everywhere in the first place. Some features are not supported.
Warning
This does not do OSD rendering. If you see OSD, then it has been rendered by the VO backend. (Subtitles are rendered by the gpu filter, if possible.)
Warning
If you use this with encoding mode, keep in mind that encoding mode will convert the RGB filter's output back to yuv420p in software, using the configured software scaler. Using zimg might improve this, but in any case it might go against your goals when using this filter.
Warning
Do not use this with --vo=gpu. It will apply filtering twice, since most --vo=gpu options are unconditionally applied to the gpu filter. There is no mechanism in mpv to prevent this.
You can encode files from one format/codec to another using this facility.
Specifies the output format options for libavformat. See --ofopts=help for a full list of supported options.
This is a key/value list option. See List Options for details.
Specifies the output audio codec options for libavcodec. See --oacopts=help for a full list of supported options.
Example
This is a key/value list option. See List Options for details.
Specifies the output video codec options for libavcodec. See --ovcopts=help for a full list of supported options.
Examples
This is a key/value list option. See List Options for details.
Specifies metadata to include in the output file. Supported keys vary between output formats. For example, Matroska (MKV) and FLAC allow almost arbitrary keys, while support in MP4 and MP3 is more limited.
This is a key/value list option. See List Options for details.
Example
Specifies metadata to exclude from the output file when copying from the input file.
This is a string list option. See List Options for details.
Example
The mpv core can be controlled with commands and properties. A number of ways to interact with the player use them: key bindings (input.conf), OSD (showing information with properties), JSON IPC, the client API (libmpv), and the classic slave mode.
The input.conf file consists of a list of key bindings, for example:
s screenshot # take a screenshot with the s key LEFT seek 15 # map the left-arrow key to seeking forward by 15 seconds
Each line maps a key to an input command. Keys are specified with their literal value (upper case if combined with Shift), or a name for special keys. For example, a maps to the a key without shift, and A maps to a with shift.
The file is located in the mpv configuration directory (normally at ~/.config/mpv/input.conf depending on platform). The default bindings are defined here:
https://github.com/mpv-player/mpv/blob/master/etc/input.conf
A list of special keys can be obtained with
mpv --input-keylist
In general, keys can be combined with Shift, Ctrl and Alt:
ctrl+q quit
mpv can be started in input test mode, which displays key bindings and the commands they're bound to on the OSD, instead of executing the commands:
mpv --input-test --force-window --idle
(Only closing the window will make mpv exit, pressing normal keys will merely display the binding, even if mapped to quit.)
Also see Key names.
[Shift+][Ctrl+][Alt+][Meta+]<key> [{<section>}] <command> ( ; <command> )*
Note that by default, the right Alt key can be used to create special characters, and thus does not register as a modifier. The option --no-input-right-alt-gr changes this behavior.
Newlines always start a new binding. # starts a comment (outside of quoted string arguments). To bind commands to the # key, SHARP can be used.
<key> is either the literal character the key produces (ASCII or Unicode character), or a symbolic name (as printed by --input-keylist).
<section> (braced with { and }) is the input section for this command.
<command> is the command itself. It consists of the command name and multiple (or none) commands, all separated by whitespace. String arguments need to be quoted with ". Details see Flat command syntax.
You can bind multiple commands to one key. For example:
It's also possible to bind a command to a sequence of keys:
(This is not shown in the general command syntax.)
If a or a-b or b are already bound, this will run the first command that matches, and the multi-key command will never be called. Intermediate keys can be remapped to ignore in order to avoid this issue. The maximum number of (non-modifier) keys for combinations is currently 4.
All mouse and keyboard input is to converted to mpv-specific key names. Key names are either special symbolic identifiers representing a physical key, or a text key names, which are unicode code points encoded as UTF-8. These are what keyboard input would normally produce, for example a for the A key. As a consequence, mpv uses input translated by the current OS keyboard layout, rather than physical scan codes.
Currently there is the hardcoded assumption that every text key can be represented as a single unicode code point (in NFKC form).
All key names can be combined with the modifiers Shift, Ctrl, Alt, Meta. They must be prefixed to the actual key name, where each modifier is followed by a + (for example ctrl+q).
Symbolic key names and modifier names are case-insensitive. Unicode key names are case-sensitive because input bindings typically respect the shift key.
Another type of key names are hexadecimal key names, that serve as fallback for special keys that are neither unicode, nor have a special mpv defined name. They will break as soon as mpv adds proper names for them, but can enable you to use a key at all if that does not happen.
All symbolic names are listed by --input-keylist. --input-test is a special mode that prints all input on the OSD.
Comments on some symbolic names:
Various mouse buttons.
Depending on backend, the mouse wheel might also be represented as a button. In addition, MOUSE_BTN3 to MOUSE_BTN6 are deprecated aliases for WHEEL_UP, WHEEL_DOWN, WHEEL_LEFT, WHEEL_RIGHT.
MBTN* are aliases for MOUSE_BTN*.
This is the syntax used in input.conf, and referred to "input.conf syntax" in a number of other places.
<command> ::= [<prefixes>] <command_name> (<argument>)* <argument> ::= (<string> | " <quoted_string> " )
command_name is an unquoted string with the command name itself. See List of Input Commands for a list.
Arguments are separated by whitespace. This applies even to string arguments. For this reason, string arguments should be quoted with ". If a string argument contains spaces or certain special characters, quoting and possibly escaping is mandatory, or the command cannot be parsed correctly.
Inside quotes, C-style escaping can be used. JSON escapes according to RFC 8259, minus surrogate pair escapes, should be a safe subset that can be used.
This applies to certain APIs, such as mp.commandv() or mp.command_native() (with array parameters) in Lua scripting, or mpv_command() or mpv_command_node() (with MPV_FORMAT_NODE_ARRAY) in the C libmpv client API.
The command as well as all arguments are passed as a single array. Similar to the Flat command syntax, you can first pass prefixes as strings (each as separate array item), then the command name as string, and then each argument as string or a native value.
Since these APIs pass arguments as separate strings or native values, they do not expect quotes, and do support escaping. Technically, there is the input.conf parser, which first splits the command string into arguments, and then invokes argument parsers for each argument. The input.conf parser normally handles quotes and escaping. The array command APIs mentioned above pass strings directly to the argument parsers, or can sidestep them by the ability to pass non-string values.
Sometimes commands have string arguments, that in turn are actually parsed by other components (e.g. filter strings with vf add) - in these cases, you you would have to double-escape in input.conf, but not with the array APIs.
For complex commands, consider using Named arguments instead, which should give slightly more compatibility. Some commands do not support named arguments and inherently take an array, though.
This applies to certain APIs, such as mp.command_native() (with tables that have string keys) in Lua scripting, or mpv_command_node() (with MPV_FORMAT_NODE_MAP) in the C libmpv client API.
Like with array commands, quoting and escaping is inherently not needed in the normal case.
The name of each command is defined in each command description in the List of Input Commands. --input-cmdlist also lists them.
Some commands do not support named arguments (e.g. run command). You need to use APIs that pass arguments as arrays.
Named arguments are not supported in the "flat" input.conf syntax, which means you cannot use them for key bindings in input.conf at all.
Commands with parameters have the parameter name enclosed in < / >. Don't add those to the actual command. Optional arguments are enclosed in [ / ]. If you don't pass them, they will be set to a default value.
Remember to quote string arguments in input.conf (see Flat command syntax).
Change the playback position. By default, seeks by a relative amount of seconds.
The second argument consists of flags controlling the seek mode:
Multiple flags can be combined, e.g.: absolute+keyframes.
By default, keyframes is used for relative, relative-percent, and absolute-percent seeks, while exact is used for absolute seeks.
Before mpv 0.9, the keyframes and exact flags had to be passed as 3rd parameter (essentially using a space instead of +). The 3rd parameter is still parsed, but is considered deprecated.
Undoes the seek command, and some other commands that seek (but not necessarily all of them). Calling this command once will jump to the playback position before the seek. Calling it a second time undoes the revert-seek command itself. This only works within a single file.
The first argument is optional, and can change the behavior:
Using it without any arguments gives you the default behavior.
Go back by one frame, then pause. Note that this can be very slow (it tries to be precise, not fast), and sometimes fails to behave as expected. How well this works depends on whether precise seeking works correctly (e.g. see the --hr-seek-demuxer-offset option). Video filters or other video post-processing that modifies timing of frames (e.g. deinterlacing) should usually work, but might make backstepping silently behave incorrectly in corner cases. Using --hr-seek-framedrop=no should help, although it might make precise seeking slower.
This does not work with audio-only playback.
Take a screenshot.
Multiple flags are available (some can be combined with +):
Older mpv versions required passing single and each-frame as second argument (and did not have flags). This syntax is still understood, but deprecated and might be removed in the future.
If you combine this command with another one using ;, you can use the async flag to make encoding/writing the image file asynchronous. For normal standalone commands, this is always asynchronous, and the flag has no effect. (This behavior changed with mpv 0.29.0.)
Take a screenshot and save it to a given file. The format of the file will be guessed by the extension (and --screenshot-format is ignored - the behavior when the extension is missing or unknown is arbitrary).
The second argument is like the first argument to screenshot and supports subtitles, video, window.
If the file already exists, it's overwritten.
Like all input command parameters, the filename is subject to property expansion as described in Property Expansion.
Go to the next entry on the playlist.
First argument:
Go to the previous entry on the playlist.
First argument:
Load the given file or URL and play it.
Second argument:
The third argument is a list of options and values which should be set while the file is playing. It is of the form opt1=value1,opt2=value2,... Not all options can be changed this way. Some options require a restart of the player.
Load the given playlist file or URL (like --playlist).
Second argument:
Run the given command. Unlike in MPlayer/mplayer2 and earlier versions of mpv (0.2.x and older), this doesn't call the shell. Instead, the command is run directly, with each argument passed separately. Each argument is expanded like in Property Expansion.
This command has a variable number of arguments, and cannot be used with named arguments.
The program is run in a detached way. mpv doesn't wait until the command is completed, but continues playback right after spawning it.
To get the old behavior, use /bin/sh and -c as the first two arguments.
Example
run "/bin/sh" "-c" "echo ${title} > /tmp/playing"
This is not a particularly good example, because it doesn't handle escaping, and a specially prepared file might allow an attacker to execute arbitrary shell commands. It is recommended to write a small shell script, and call that with run.
Similar to run, but gives more control about process execution to the caller, and does does not detach the process.
You can avoid blocking until the process terminates by running this command asynchronously. (For example mp.command_native_async() in Lua scripting.)
This has the following named arguments. The order of them is not guaranteed, so you should always call them with named arguments, see Named arguments.
Array of strings with the command as first argument, and subsequent command line arguments following. This is just like the run command argument list.
The first array entry is either an absolute path to the executable, or a filename with no path components, in which case the PATH environment variable. On Unix, this is equivalent to posix_spawnp and execvp behavior.
The command returns the following result (as MPV_FORMAT_NODE_MAP):
The raw exit status of the process. It will be negative on error. The meaning of negative values is undefined, other than meaning error (and does not necessarily correspond to OS low level exit status values).
On Windows, it can happen that a negative return value is returned even if the process exits gracefully, because the win32 UINT exit code is assigned to an int variable before being set as int64_t field in the result map. This might be fixed later.
Empty string if the process exited gracefully. The string killed if the process was terminated in an unusual way. The string init if the process could not be started.
On Windows, killed is only returned when the process has been killed by mpv as a result of playback_only being set to yes.
Note that the command itself will always return success as long as the parameters are correct. Whether the process could be spawned or whether it was somehow killed or returned an error status has to be queried from the result value.
This command can be asynchronously aborted via API.
In all cases, the subprocess will be terminated on player exit. Also see Asynchronous command details. Only the run command can start processes in a truly detached way.
Warning
Don't forget to set the playback_only field if you want the command run while the player is in idle mode, or if you don't want that end of playback kills the command.
Load the given subtitle file or stream. By default, it is selected as current subtitle after loading.
The flags argument is one of the following values:
<select>
Select the subtitle immediately (default).
<auto>
Don't select the subtitle. (Or in some special situations, let the default stream selection mechanism decide.)
<cached>
Select the subtitle. If a subtitle with the same filename was already added, that one is selected, instead of loading a duplicate entry. (In this case, title/language are ignored, and if the was changed since it was loaded, these changes won't be reflected.)
The title argument sets the track title in the UI.
The lang argument sets the track language, and can also influence stream selection with flags set to auto.
Reload the given subtitle tracks. If the id argument is missing, reload the current track. (Works on external subtitle files only.)
This works by unloading and re-adding the subtitle track.
Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle. This is similar to sub-step, except that it seeks video and audio instead of adjusting the subtitle delay.
For embedded subtitles (like with Matroska), this works only with subtitle events that have already been displayed, or are within a short prefetch range.
Show text on the OSD. The string can contain properties, which are expanded as described in Property Expansion. This can be used to show playback time, filename, and so on.
Expand a path's double-tilde placeholders into a platform-specific path. As expand-text, this can only be used through the client API or from a script using mp.command_native.
Example
mp.osd_message(mp.command_native({"expand-path", "~~home/"}))
This line of Lua would show the location of the user's mpv configuration directory on the OSD.
Send a mouse event with given coordinate (<x>, <y>).
Second argument:
Third argument:
Rescan external files according to the current --sub-auto and --audio-file-auto settings. This can be used to auto-load external files after the file was loaded.
The mode argument is one of the following:
Change video filter chain.
The semantics are exactly the same as with option parsing (see VIDEO FILTERS). As such the text below is a redundant and incomplete summary.
The first argument decides what happens:
Check if the given filter (with the exact parameters) is already in the video chain. If yes, remove the filter. If no, add the filter. (If several filters are passed to the command, this is done for each filter.)
A special variant is combining this with labels, and using @name without filter name and parameters as filter entry. This toggles the enable/disable flag.
The argument is always needed. E.g. in case of clr use vf clr "".
You can assign labels to filter by prefixing them with @name: (where name is a user-chosen arbitrary identifier). Labels can be used to refer to filters by name in all of the filter chain modification commands. For add, using an already used label will replace the existing filter.
The vf command shows the list of requested filters on the OSD after changing the filter chain. This is roughly equivalent to show-text ${vf}. Note that auto-inserted filters for format conversion are not shown on the list, only what was requested by the user.
Normally, the commands will check whether the video chain is recreated successfully, and will undo the operation on failure. If the command is run before video is configured (can happen if the command is run immediately after opening a file and before a video frame is decoded), this check can't be run. Then it can happen that creating the video chain fails.
Example for input.conf
Example how to toggle disabled filters at runtime
Cycle through a list of values. Each invocation of the command will set the given property to the next value in the list. The command will use the current value of the property/option, and use it to determine the current position in the list of values. Once it has found it, it will set the next value in the list (wrapping around to the first item if needed).
This command has a variable number of arguments, and cannot be used with named arguments.
The special argument !reverse can be used to cycle the value list in reverse. The only advantage is that you don't need to reverse the value list yourself when adding a second key binding for cycling backwards.
This command is deprecated, except for mpv-internal uses.
Enable all key bindings in the named input section.
The enabled input sections form a stack. Bindings in sections on the top of the stack are preferred to lower sections. This command puts the section on top of the stack. If the section was already on the stack, it is implicitly removed beforehand. (A section cannot be on the stack more than once.)
The flags parameter can be a combination (separated by +) of the following flags:
This command is deprecated, except for mpv-internal uses.
Disable the named input section. Undoes enable-section.
This command is deprecated, except for mpv-internal uses.
Create a named input section, or replace the contents of an already existing input section. The contents parameter uses the same syntax as the input.conf file (except that using the section syntax in it is not allowed), including the need to separate bindings with a newline character.
If the contents parameter is an empty string, the section is removed.
The section with the name default is the normal input section.
In general, input sections have to be enabled with the enable-section command, or they are ignored.
The last parameter has the following meaning:
This command can be used to dispatch arbitrary keys to a script or a client API user. If the input section defines script-binding commands, it is also possible to get separate events on key up/down, and relatively detailed information about the key state. The special key name unmapped can be used to match any unmapped key.
Add an OSD overlay sourced from raw data. This might be useful for scripts and applications controlling mpv, and which want to display things on top of the video window.
Overlays are usually displayed in screen resolution, but with some VOs, the resolution is reduced to that of the video's. You can read the osd-width and osd-height properties. At least with --vo-xv and anamorphic video (such as DVD), osd-par should be read as well, and the overlay should be aspect-compensated.
This has the following named arguments. The order of them is not guaranteed, so you should always call them with named arguments, see Named arguments.
id is an integer between 0 and 63 identifying the overlay element. The ID can be used to add multiple overlay parts, update a part by using this command with an already existing ID, or to remove a part with overlay-remove. Using a previously unused ID will add a new overlay, while reusing an ID will update it.
x and y specify the position where the OSD should be displayed.
file specifies the file the raw image data is read from. It can be either a numeric UNIX file descriptor prefixed with @ (e.g. @4), or a filename. The file will be mapped into memory with mmap(), copied, and unmapped before the command returns (changed in mpv 0.18.1).
It is also possible to pass a raw memory address for use as bitmap memory by passing a memory address as integer prefixed with an & character. Passing the wrong thing here will crash the player. This mode might be useful for use with libmpv. The offset parameter is simply added to the memory address (since mpv 0.8.0, ignored before).
offset is the byte offset of the first pixel in the source file. (The current implementation always mmap's the whole file from position 0 to the end of the image, so large offsets should be avoided. Before mpv 0.8.0, the offset was actually passed directly to mmap, but it was changed to make using it easier.)
fmt is a string identifying the image format. Currently, only bgra is defined. This format has 4 bytes per pixels, with 8 bits per component. The least significant 8 bits are blue, and the most significant 8 bits are alpha (in little endian, the components are B-G-R-A, with B as first byte). This uses premultiplied alpha: every color component is already multiplied with the alpha component. This means the numeric value of each component is equal to or smaller than the alpha component. (Violating this rule will lead to different results with different VOs: numeric overflows resulting from blending broken alpha values is considered something that shouldn't happen, and consequently implementations don't ensure that you get predictable behavior in this case.)
w, h, and stride specify the size of the overlay. w is the visible width of the overlay, while stride gives the width in bytes in memory. In the simple case, and with the bgra format, stride==4*w. In general, the total amount of memory accessed is stride * h. (Technically, the minimum size would be stride * (h - 1) + w * 4, but for simplicity, the player will access all stride * h bytes.)
Note
Before mpv 0.18.1, you had to do manual "double buffering" when updating an overlay by replacing it with a different memory buffer. Since mpv 0.18.1, the memory is simply copied and doesn't reference any of the memory indicated by the command's arguments after the commend returns. If you want to use this command before mpv 0.18.1, reads the old docs to see how to handle this correctly.
Add/update/remove an OSD overlay.
(Although this sounds similar to overlay-add, osd-overlay is for text overlays, while overlay-add is for bitmaps. Maybe overlay-add will be merged into osd-overlay to remove this oddity.)
You can use this to add text overlays in ASS format. ASS has advanced positioning and rendering tags, which can be used to render almost any kind of vector graphics.
This command accepts the following parameters:
Arbitrary integer that identifies the overlay. Multiple overlays can be added by calling this command with different id parameters. Calling this command with the same id replaces the previously set overlay.
There is a separate namespace for each libmpv client (i.e. IPC connection, script), so IDs can be made up and assigned by the API user without conflicting with other API users.
If the libmpv client is destroyed, all overlays associated with it are also deleted. In particular, connecting via --input-ipc-server, adding an overlay, and disconnecting will remove the overlay immediately again.
String that gives the type of the overlay. Accepts the following values:
The data parameter is a string. The string is split on the newline character. Every line is turned into the Text part of a Dialogue ASS event. Timing is unused (but behavior of timing dependent ASS tags may change in future mpv versions).
Note that it's better to put multiple lines into data, instead of adding multiple OSD overlays.
This provides 2 ASS Styles. OSD contains the text style as defined by the current --osd-... options. Default is similar, and contains style that OSD would have if all options were set to the default.
In addition, the res_x and res_y options specify the value of the ASS PlayResX and PlayResY header fields. If res_y is set to 0, PlayResY is initialized to an arbitrary default value (but note that the default for this command is 720, not 0). If res_x is set to 0, PlayResX is set based on res_y such that a virtual ASS pixel has a square pixel aspect ratio.
The Z order of the overlay. Optional, defaults to 0.
Note that Z order between different overlays of different formats is static, and cannot be changed (currently, this means that bitmap overlays added by overlay-add are always on top of the ASS overlays added by osd-overlay). In addition, the builtin OSD components are always below any of the custom OSD. (This includes subtitles of any kind as well as text rendered by show-text.)
It's possible that future mpv versions will randomly change how Z order between different OSD formats and builtin OSD is handled.
Note: always use named arguments (mpv_command_node()). Scripts should use the mp.create_osd_overlay() helper instead of invoking this command directly.
Send a message to all clients, and pass it the following list of arguments. What this message means, how many arguments it takes, and what the arguments mean is fully up to the receiver and the sender. Every client receives the message, so be careful about name clashes (or use script-message-to).
This command has a variable number of arguments, and cannot be used with named arguments.
Same as script-message, but send it only to the client named <target>. Each client (scripts etc.) has a unique name. For example, Lua scripts can get their name via mp.get_script_name().
This command has a variable number of arguments, and cannot be used with named arguments.
Invoke a script-provided key binding. This can be used to remap key bindings provided by external Lua scripts.
The argument is the name of the binding.
It can optionally be prefixed with the name of the script, using / as separator, e.g. script-binding scriptname/bindingname.
For completeness, here is how this command works internally. The details could change any time. On any matching key event, script-message-to or script-message is called (depending on whether the script name is included), with the following arguments:
The 5th argument is only set if no modifiers are present (using the shift key with a letter is normally not emitted as having a modifier, and results in upper case text instead, but some backends may mess up).
The key state consists of 2 characters:
Future versions can add more arguments and more key state characters to support more input peculiarities.
Return a screenshot in memory. This can be used only through the client API. The MPV_FORMAT_NODE_MAP returned by this command has the w, h, stride fields set to obvious contents. The format field is set to bgr0 by default. This format is organized as B8G8R8X8 (where B is the LSB). The contents of the padding X are undefined. The data field is of type MPV_FORMAT_BYTE_ARRAY with the actual image data. The image is freed as soon as the result mpv_node is freed. As usual with client API semantics, you are not allowed to write to the image data.
The stride is the number of bytes from a pixel at (x0, y0) to the pixel at (x0, y0 + 1). This can be larger than w * 4 if the image was cropped, or if there is padding. This number can be negative as well. You access a pixel with byte_index = y * stride + x * 4 (assuming the bgr0 format).
The flags argument is like the first argument to screenshot and supports subtitles, video, window.
Send a command to the filter with the given <label>. Use all to send it to all filters at once. The command and argument string is filter specific. Currently, this only works with the lavfi filter - see the libavfilter documentation for which commands a filter supports.
Note that the <label> is a mpv filter label, not a libavfilter filter name.
Apply the contents of a named profile. This is like using profile=name in a config file, except you can map it to a key binding to change it at runtime.
There is no such thing as "unapplying" a profile - applying a profile merely sets all option values listed within the profile.
This command changes list options as described in List Options. The <name> parameter is the normal option name, while <operation> is the suffix or action used on the option.
Some operations take no value, but the command still requires the value parameter. In these cases, the value must be an empty string.
Example
change-list glsl-shaders append file.glsl
Add a filename to the glsl-shaders list. The command line equivalent is --glsl-shaders-append=file.glsl or alternatively --glsl-shader=file.glsl.
Dump the current cache to the given filename. The <filename> file is overwritten if it already exists. <start> and <end> give the time range of what to dump. If no data is cached at the given time range, nothing may be dumped (creating a file with no packets).
Dumping a larger part of the cache will freeze the player. No effort was made to fix this, as this feature was meant mostly for creating small excerpts.
See --stream-record for various caveats that mostly apply to this command too, as both use the same underlying code for writing the output file.
If <filename> is an empty string, an ongoing dump-cache is stopped.
If <end> is no, then continuous dumping is enabled. Then, after dumping the existing parts of the cache, anything read from network is appended to the cache as well. This behaves similar to --stream-record (although it does not conflict with that option, and they can be both active at the same time).
If the <end> time is after the cache, the command will _not_ wait and write newly received data to it.
The end of the resulting file may be slightly damaged or incomplete at the end. (Not enough effort was made to ensure that the end lines up properly.)
Note that this command will finish only once dumping ends. That means it works similar to the screenshot command, just that it can block much longer. If continuous dumping is used, the command will not finish until playback is stopped, an error happens, another dump-cache command is run, or an API like mp.abort_async_command was called to explicitly stop the command. See Synchronous vs. Asynchronous.
Note
This was mostly created for network streams. For local files, there may be much better methods to create excerpts and such. There are tons of much more user-friendly Lua scripts, that will reencode parts of a file by spawning a separate instance of ffmpeg. With network streams, this is not that easily possible, as the stream would have to be downloaded again. Even if --stream-record is used to record the stream to the local filesystem, there may be problems, because the recorded file is still written to.
This command is experimental, and all details about it may change in the future.
Essentially calls dump-cache with the current AB-loop points as arguments. Like dump-cache, this will overwrite the file at <filename>. Likewise, if the B point is set to no, it will enter continuous dumping after the existing cache was dumped.
The author reserves the right to remove this command if enough motivation is found to move this functionality to a trivial Lua script.
Re-adjust the A/B loop points to the start and end within the cache the ab-loop-dump-cache command will (probably) dump. Basically, it aligns the times on keyframes. The guess might be off especially at the end (due to granularity issues due to remuxing). If the cache shrinks in the meantime, the points set by the command will not be the effective parameters either.
This command has an even more uncertain future than ab-loop-dump-cache and might disappear without replacement if the author decides it's useless.
Undocumented commands: ao-reload (experimental/internal).
Hooks are synchronous events between player core and a script or similar. This applies to client API (including the Lua scripting interface). Normally, events are supposed to be asynchronous, and the hook API provides an awkward and obscure way to handle events that require stricter coordination. There are no API stability guarantees made. Not following the protocol exactly can make the player freeze randomly. Basically, nobody should use this API.
The C API is described in the header files. The Lua API is described in the Lua section.
The following hooks are currently defined:
Called after a file has been opened, and before tracks are selected and decoders are created. This has some usefulness if an API users wants to select tracks manually, based on the set of available tracks. It's also useful to initialize --lavfi-complex in a specific way by API, without having to "probe" the available streams at first.
Note that this does not yet apply default track selection. Which operations exactly can be done and not be done, and what information is available and what is not yet available yet, is all subject to change.
Warning
The legacy API is deprecated and will be removed soon.
There are two special commands involved. Also, the client must listen for client messages (MPV_EVENT_CLIENT_MESSAGE in the C API).
Subscribe to the hook identified by the first argument (basically, the name of event). The id argument is an arbitrary integer chosen by the user. priority is used to sort all hook handlers globally across all clients. Each client can register multiple hook handlers (even for the same hook-name). Once the hook is registered, it cannot be unregistered.
When a specific event happens, all registered handlers are run serially. This uses a protocol every client has to follow explicitly. When a hook handler is run, a client message (MPV_EVENT_CLIENT_MESSAGE) is sent to the client which registered the hook. This message has the following arguments:
Upon receiving this message, the client can handle the event. While doing this, the player core will still react to requests, but playback will typically be stopped.
When the client is done, it must continue the core's hook execution by running the hook-ack command.
These prefixes are placed between key name and the actual command. Multiple prefixes can be specified. They are separated by whitespace.
All of the osd prefixes are still overridden by the global --osd-level settings.
The async and sync prefix matter only for how the issuer of the command waits on the completion of the command. Normally it does not affect how the command behaves by itself. There are the following cases:
Before mpv 0.29.0, the async prefix was only used by screenshot commands, and made them run the file saving code in a detached manner. This is the default now, and async changes behavior only in the ways mentioned above.
Currently the following commands have different waiting characteristics with sync vs. async: sub-add, audio-add, sub-reload, audio-reload, rescan-external-files, screenshot, screenshot-to-file, dump-cache, ab-loop-dump-cache.
On the API level, every asynchronous command is bound to the context which started it. For example, an asynchronous command started by mpv_command_async is bound to the mpv_handle passed to the function. Only this mpv_handle receives the completion notification (MPV_EVENT_COMMAND_REPLY), and only this handle can abort a still running command directly. If the mpv_handle is destroyed, any still running async. commands started by it are terminated.
The scripting APIs and JSON IPC give each script/connection its own implicit mpv_handle.
If the player is closed, the core may abort all pending async. commands on its own (like a forced mpv_abort_async_command() call for each pending command on behalf of the API user). This happens at the same time MPV_EVENT_SHUTDOWN is sent, and there is no way to prevent this.
Input sections group a set of bindings, and enable or disable them at once. In input.conf, each key binding is assigned to an input section, rather than actually having explicit text sections.
See also: enable-section and disable-section commands.
Predefined bindings:
Properties are used to set mpv options during runtime, or to query arbitrary information. They can be manipulated with the set/add/cycle commands, and retrieved with show-text, or anything else that uses property expansion. (See Property Expansion.)
The property name is annotated with RW to indicate whether the property is generally writable.
If an option is referenced, the property will normally take/return exactly the same values as the option. In these cases, properties are merely a way to change an option at runtime.
Note
Most options can be set as runtime via properties as well. Just remove the leading -- from the option name. These are not documented. Only properties which do not exist as option with the same name, or which have very different behavior from the options are documented below.
Factor multiplied with speed at which the player attempts to play the file. Usually it's exactly 1. (Display sync mode will make this useful.)
OSD formatting will display it in the form of +1.23456%, with the number being (raw - 1) * 100 for the given raw property value.
Currently played file, with path stripped. If this is an URL, try to undo percent encoding as well. (The result is not necessarily correct, but looks better for display purposes. Use the path property to get an unmodified filename.)
This has a sub-property:
Total number of frames in current file.
Note
This is only an estimate. (It's computed from two unreliable quantities: fps and stream length.)
Number of current frame in current stream.
Note
This is only an estimate. (It's computed from two unreliable quantities: fps and possibly rounded timestamps.)
If the currently played file has a title tag, use that.
Otherwise, return the filename property.
Name of the current demuxer. (This is useless.)
(Renamed from demuxer.)
Duration of the current file in seconds. If the duration is unknown, the property is unavailable. Note that the file duration is not always exactly known, so this is an estimate.
This replaces the length property, which was deprecated after the mpv 0.9 release. (The semantics are the same.)
Video frames dropped by decoder, because video is too far behind audio (when using --framedrop=decoder). Sometimes, this may be incremented in other situations, e.g. when video packets are damaged, or the decoder doesn't follow the usual rules. Unavailable if video is disabled.
drop-frame-count is a deprecated alias.
Frames dropped by VO (when using --framedrop=vo).
vo-drop-frame-count is a deprecated alias.
Current MKV edition number. Setting this property to a different value will restart playback. The number of the first edition is 0.
Before mpv 0.31.0, this showed the actual edition selected at runtime, if you didn't set the option or property manually. With mpv 0.31.0 and later, this strictly returns the user-set option or property value, and the current-edition property was added to return the runtime selected edition (this matters with --edition=auto, the default).
List of editions, current entry marked. Currently, the raw property value is useless.
This has a number of sub-properties. Replace N with the 0-based edition index.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each edition) "id" MPV_FORMAT_INT64 "title" MPV_FORMAT_STRING "default" MPV_FORMAT_FLAG
Metadata key/value pairs.
If the property is accessed with Lua's mp.get_property_native, this returns a table with metadata keys mapping to metadata values. If it is accessed with the client API, this returns a MPV_FORMAT_NODE_MAP, with tag keys mapping to tag values.
For OSD, it returns a formatted list. Trying to retrieve this property as a raw string doesn't work.
This has a number of sub-properties:
The layout of this property might be subject to change. Suggestions are welcome how exactly this property should work.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_MAP (key and string value for each metadata entry)
Metadata of current chapter. Works similar to metadata property. It also allows the same access methods (using sub-properties).
Per-chapter metadata is very rare. Usually, only the chapter name (title) is set.
For accessing other information, like chapter start, see the chapter-list property.
Metadata added by video filters. Accessed by the filter label, which, if not explicitly specified using the @filter-label: syntax, will be <filter-name>NN.
Works similar to metadata property. It allows the same access methods (using sub-properties).
An example of this kind of metadata are the cropping parameters added by --vf=lavfi=cropdetect.
Return yes if no file is loaded, but the player is staying around because of the --idle option.
(Renamed from idle.)
Return yes if the playback core is paused, otherwise no. This can be different pause in special situations, such as when the player pauses itself due to low network cache.
This also returns yes if playback is restarting or if nothing is playing at all. In other words, it's only no if there's actually video playing. (Behavior since mpv 0.7.0.)
Various undocumented or half-documented things.
Each entry in seekable-ranges represents a region in the demuxer cache that can be seeked to. If there are multiple demuxers active, this only returns information about the "main" demuxer, but might be changed in future to return unified information about all demuxers. The ranges are in arbitrary order. Often, ranges will overlap for a bit, before being joined. In broken corner cases, ranges may overlap all over the place.
The end of a seek range is usually smaller than the value returned by the demuxer-cache-time property, because that property returns the guessed buffering amount, while the seek ranges represent the buffered data that can actually be used for cached seeking.
bof-cached indicates whether the seek range with the lowest timestamp points to the beginning of the stream (BOF). This implies you cannot seek before this position at all. eof-cached indicates whether the seek range with the highest timestamp points to the end of the stream (EOF). If both bof-cached and eof-cached are set to yes, and there's only 1 cache range, the entire stream is cached.
fw-bytes is the number of bytes of packets buffered in the range starting from the current decoding position. This is a rough estimate (may not account correctly for various overhead), and stops at the demuxer position (it ignores seek ranges after it).
file-cache-bytes is the number of bytes stored in the file cache. This includes all overhead, and possibly unused data (like pruned data). This member is missing if the file cache is not active.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_MAP "seekable-ranges" MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP "start" MPV_FORMAT_DOUBLE "end" MPV_FORMAT_DOUBLE "bof-cached" MPV_FORMAT_FLAG "eof-cached" MPV_FORMAT_FLAG "fw-bytes" MPV_FORMAT_INT64 "file-cache-bytes" MPV_FORMAT_INT64
Other fields (might be changed or removed in the future):
Return yes if the audio mixer is active, no otherwise.
This option is relatively useless. Before mpv 0.18.1, it could be used to infer behavior of the volume property.
Audio format as output by the audio decoder. This has a number of sub-properties:
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_MAP "format" MPV_FORMAT_STRING "samplerate" MPV_FORMAT_INT64 "channels" MPV_FORMAT_STRING "channel-count" MPV_FORMAT_INT64 "hr-channels" MPV_FORMAT_STRING
Reflects the --hwdec option.
Writing to it may change the currently used hardware decoder, if possible. (Internally, the player may reinitialize the decoder, and will perform a seek to refresh the video properly.) You can watch the other hwdec properties to see whether this was successful.
Unlike in mpv 0.9.x and before, this does not return the currently active hardware decoder. Since mpv 0.18.0, hwdec-current is available for this purpose.
This returns the currently loaded hardware decoding/output interop driver. This is known only once the VO has opened (and possibly later). With some VOs (like gpu), this might be never known in advance, but only when the decoder attempted to create the hw decoder successfully. (Using --gpu-hwdec-interop can load it eagerly.) If there are multiple drivers loaded, they will be separated by ,.
If no VO is active or no interop driver is known, this property is unavailable.
This does not necessarily use the same values as hwdec. There can be multiple interop drivers for the same hardware decoder, depending on platform and VO.
Video parameters, as output by the decoder (with overrides like aspect etc. applied). This has a number of sub-properties:
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_MAP "pixelformat" MPV_FORMAT_STRING "w" MPV_FORMAT_INT64 "h" MPV_FORMAT_INT64 "dw" MPV_FORMAT_INT64 "dh" MPV_FORMAT_INT64 "aspect" MPV_FORMAT_DOUBLE "par" MPV_FORMAT_DOUBLE "colormatrix" MPV_FORMAT_STRING "colorlevels" MPV_FORMAT_STRING "primaries" MPV_FORMAT_STRING "gamma" MPV_FORMAT_STRING "sig-peak" MPV_FORMAT_DOUBLE "light" MPV_FORMAT_STRING "chroma-location" MPV_FORMAT_STRING "rotate" MPV_FORMAT_INT64 "stereo-in" MPV_FORMAT_STRING
Video display size. This is the video size after filters and aspect scaling have been applied. The actual video window size can still be different from this, e.g. if the user resized the video window manually.
These have the same values as video-out-params/dw and video-out-params/dh.
Same as video-params, but after video filters have been applied. If there are no video filters in use, this will contain the same values as video-params. Note that this is still not necessarily what the video window uses, since the user can change the window size, and all real VOs do their own scaling independently from the filter chain.
Has the same sub-properties as video-params.
Approximate information of the current frame. Note that if any of these are used on OSD, the information might be off by a few frames due to OSD redrawing and frame display being somewhat disconnected, and you might have to pause and force a redraw.
Sub-properties:
video-frame-info/picture-type video-frame-info/interlaced video-frame-info/tff video-frame-info/repeat
Container FPS. This can easily contain bogus values. For videos that use modern container formats or video codecs, this will often be incorrect.
(Renamed from fps.)
Window size multiplier. Setting this will resize the video window to the values contained in dwidth and dheight multiplied with the value set with this property. Setting 1 will resize to original video size (or to be exact, the size the video filters output). 2 will set the double size, 0.5 halves the size.
See current-window-scale for the value derived from the actual window size.
Since mpv 0.31.0, this always returns the previously set value (or the default value), instead of the value implied by the actual window size. Before mpv 0.31.0, this returned what current-window-scale returns now, after the window was created.
The refresh rate of the current display. Currently, this is the lowest FPS of any display covered by the video, as retrieved by the underlying system APIs (e.g. xrandr on X11). It is not the measured FPS. It's not necessarily available on all platforms. Note that any of the listed facts may change any time without a warning.
Writing to this property is deprecated. It has the same effect as writing to override-display-fps. Since mpv 0.31.0, this property is unavailable if no display FPS was reported (e.g. if no video is active), while in older versions, it returned the --display-fps option value.
Deprecated. This is tied to --video-aspect-override, but always reports the current video aspect if video is active.
The read and write components of this option can be split up into video-params/aspect and video-aspect-override respectively.
Last known OSD width (can be 0). This is needed if you want to use the overlay-add command. It gives you the actual OSD size, which can be different from the window size in some cases.
Alias to osd-dimensions/w and osd-dimensions/h.
Last known OSD display pixel aspect (can be 0).
Alias to osd-dimensions/osd-par.
Last known OSD dimensions.
Has the following sub-properties (which can be read as MPV_FORMAT_NODE or Lua table with mp.get_property_native):
Any of these properties may be unavailable or set to dummy values if the VO window is not created or visible.
Return the current subtitle text regardless of sub visibility. Formatting is stripped. If the subtitle is not text-based (i.e. DVD/BD subtitles), an empty string is returned.
This property is experimental and might be removed in the future.
Playlist, current entry marked. Currently, the raw property value is useless.
This has a number of sub-properties. Replace N with the 0-based playlist entry index.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each playlist entry) "filename" MPV_FORMAT_STRING "current" MPV_FORMAT_FLAG (might be missing; since mpv 0.7.0) "playing" MPV_FORMAT_FLAG (same) "title" MPV_FORMAT_STRING (optional)
List of audio/video/sub tracks, current entry marked. Currently, the raw property value is useless.
This has a number of sub-properties. Replace N with the 0-based track index.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each track) "id" MPV_FORMAT_INT64 "type" MPV_FORMAT_STRING "src-id" MPV_FORMAT_INT64 "title" MPV_FORMAT_STRING "lang" MPV_FORMAT_STRING "albumart" MPV_FORMAT_FLAG "default" MPV_FORMAT_FLAG "forced" MPV_FORMAT_FLAG "selected" MPV_FORMAT_FLAG "external" MPV_FORMAT_FLAG "external-filename" MPV_FORMAT_STRING "codec" MPV_FORMAT_STRING "ff-index" MPV_FORMAT_INT64 "decoder-desc" MPV_FORMAT_STRING "demux-w" MPV_FORMAT_INT64 "demux-h" MPV_FORMAT_INT64 "demux-channel-count" MPV_FORMAT_INT64 "demux-channels" MPV_FORMAT_STRING "demux-samplerate" MPV_FORMAT_INT64 "demux-fps" MPV_FORMAT_DOUBLE "demux-bitrate" MPV_FORMAT_INT64 "demux-rotation" MPV_FORMAT_INT64 "demux-par" MPV_FORMAT_DOUBLE "audio-channels" MPV_FORMAT_INT64 "replaygain-track-peak" MPV_FORMAT_DOUBLE "replaygain-track-gain" MPV_FORMAT_DOUBLE "replaygain-album-peak" MPV_FORMAT_DOUBLE "replaygain-album-gain" MPV_FORMAT_DOUBLE
List of chapters, current entry marked. Currently, the raw property value is useless.
This has a number of sub-properties. Replace N with the 0-based chapter index.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each chapter) "title" MPV_FORMAT_STRING "time" MPV_FORMAT_DOUBLE
See --vf/--af and the vf/af command.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each filter entry) "name" MPV_FORMAT_STRING "label" MPV_FORMAT_STRING [optional] "enabled" MPV_FORMAT_FLAG [optional] "params" MPV_FORMAT_NODE_MAP [optional] "key" MPV_FORMAT_STRING "value" MPV_FORMAT_STRING
It's also possible to write the property using this format.
Return yes if the current file is considered seekable, but only because the cache is active. This means small relative seeks may be fine, but larger seeks may fail anyway. Whether a seek will succeed or not is generally not known in advance.
If this property returns true, seekable will also return true.
${osd-ass-cc/0} disables escaping ASS sequences of text in OSD, ${osd-ass-cc/1} enables it again. By default, ASS sequences are escaped to avoid accidental formatting, and this property can disable this behavior. Note that the properties return an opaque OSD control code, which only makes sense for the show-text command or options which set OSD messages.
Example
Any ASS override tags as understood by libass can be used.
Note that you need to escape the \ character, because the string is processed for C escape sequences before passing it to the OSD code.
A list of tags can be found here: http://docs.aegisub.org/latest/ASS_Tags/
Contains introspection about the VO's active render passes and their execution times. Not implemented by all VOs.
This is further subdivided into two frame types, vo-passes/fresh for fresh frames (which have to be uploaded, scaled, etc.) and vo-passes/redraw for redrawn frames (which only have to be re-painted). The number of passes for any given subtype can change from frame to frame, and should not be relied upon.
Each frame type has a number of further sub-properties. Replace TYPE with the frame type, N with the 0-based pass index, and M with the 0-based sample index.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_MAP "TYPE" MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP "desc" MPV_FORMAT_STRING "last" MPV_FORMAT_INT64 "avg" MPV_FORMAT_INT64 "peak" MPV_FORMAT_INT64 "count" MPV_FORMAT_INT64 "samples" MPV_FORMAT_NODE_ARRAY MP_FORMAT_INT64
Note that directly accessing this structure via subkeys is not supported, the only access is through aforementioned MPV_FORMAT_NODE.
Bitrate values calculated on the packet level. This works by dividing the bit size of all packets between two keyframes by their presentation timestamp distance. (This uses the timestamps are stored in the file, so e.g. playback speed does not influence the returned values.) In particular, the video bitrate will update only per keyframe, and show the "past" bitrate. To make the property more UI friendly, updates to these properties are throttled in a certain way.
The unit is bits per second. OSD formatting turns these values in kilobits (or megabits, if appropriate), which can be prevented by using the raw property value, e.g. with ${=video-bitrate}.
Note that the accuracy of these properties is influenced by a few factors. If the underlying demuxer rewrites the packets on demuxing (done for some file formats), the bitrate might be slightly off. If timestamps are bad or jittery (like in Matroska), even constant bitrate streams might show fluctuating bitrate.
How exactly these values are calculated might change in the future.
In earlier versions of mpv, these properties returned a static (but bad) guess using a completely different method.
Old and deprecated properties for video-bitrate, audio-bitrate, sub-bitrate. They behave exactly the same, but return a value in kilobits. Also, they don't have any OSD formatting, though the same can be achieved with e.g. ${=video-bitrate}.
These properties shouldn't be used anymore.
Return the list of discovered audio devices. This is mostly for use with the client API, and reflects what --audio-device=help with the command line player returns.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each device entry) "name" MPV_FORMAT_STRING "description" MPV_FORMAT_STRING
The name is what is to be passed to the --audio-device option (and often a rather cryptic audio API-specific ID), while description is human readable free form text. The description is set to the device name (minus mpv-specific <driver>/ prefix) if no description is available or the description would have been an empty string.
The special entry with the name set to auto selects the default audio output driver and the default device.
The property can be watched with the property observation mechanism in the client API and in Lua scripts. (Technically, change notification is enabled the first time this property is read.)
Set the audio device. This directly reads/writes the --audio-device option, but on write accesses, the audio output will be scheduled for reloading.
Writing this property while no audio output is active will not automatically enable audio. (This is also true in the case when audio was disabled due to reinitialization failure after a previous write access to audio-device.)
This property also doesn't tell you which audio device is actually in use.
How these details are handled may change in the future.
This is a key/value map of arbitrary strings shared between scripts for general use. The player itself does not use any data in it (although some builtin scripts may). The property is not preserved across player restarts.
This is very primitive, inefficient, and annoying to use. It's a makeshift solution which could go away any time (for example, when a better solution becomes available). This is also why this property has an annoying name. You should avoid using it, unless you absolutely have to.
Lua scripting has helpers starting with utils.shared_script_property_. They are undocumented because you should not use this property. If you still think you must, you should use the helpers instead of the property directly.
You are supposed to use the change-list command to modify the contents. Reading, modifying, and writing the property manually could data loss if two scripts update different keys at the same time due to lack of synchronization. The Lua helpers take care of this.
(There is no way to ensure synchronization if two scripts try to update the same key at the same time.)
List of decoders supported. This lists decoders which can be passed to --vd and --ad.
When querying the property with the client API using MPV_FORMAT_NODE, or with Lua mp.get_property_native, this will return a mpv_node with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each decoder entry) "codec" MPV_FORMAT_STRING "driver" MPV_FORMAT_STRING "description" MPV_FORMAT_STRING
Read-only access to value of option --<name>. Most options can be changed at runtime by writing to this property. Note that many options require reloading the file for changes to take effect. If there is an equivalent property, prefer setting the property instead.
There shouldn't be any reason to access options/<name> instead of <name>, except in situations in which the properties have different behavior or conflicting semantics.
Similar to options/<name>, but when setting an option through this property, the option is reset to its old value once the current file has stopped playing. Trying to write an option while no file is playing (or is being loaded) results in an error.
(Note that if an option is marked as file-local, even options/ will access the local value, and the old value, which will be restored on end of playback, cannot be read or written until end of playback.)
Additional per-option information.
This has a number of sub-properties. Replace <name> with the name of a top-level option. No guarantee of stability is given to any of these sub-properties - they may change radically in the feature.
Return list of current input key bindings. This returns an array of maps, where each map node represents a binding for a single key/command. This map has the following entries:
This property is read-only, and change notification is not supported. Currently, there is no mechanism to change key bindings at runtime, other than scripts adding or removing their own bindings.
You can access (almost) all options as properties, though there are some caveats with some properties (due to historical reasons):
While playback is active, these result the actually active tracks. For example, if you set aid=5, and the currently played file contains no audio track with ID 5, the aid property will return no.
Before mpv 0.31.0, you could set existing tracks at runtime only.
If you set the properties during playback, and the filter chain fails to reinitialize, the option will be set, but the runtime filter chain does not change. On the other hand, the next video to be played will fail, because the initial filter chain cannot be created.
This behavior changed in mpv 0.31.0. Before this, the new value was rejected iff video (for vf) or audio (for af) was active. If playback was not active, the behavior was the same as the current behavior.
All string arguments to input commands as well as certain options (like --term-playing-msg) are subject to property expansion. Note that property expansion does not work in places where e.g. numeric parameters are expected. (For example, the add command does not do property expansion. The set command is an exception and not a general rule.)
Example for input.conf
Within input.conf, property expansion can be inhibited by putting the raw prefix in front of commands.
The following expansions are supported:
In places where property expansion is allowed, C-style escapes are often accepted as well. Example:
- \n becomes a newline character
- \\ expands to \
Normally, properties are formatted as human-readable text, meant to be displayed on OSD or on the terminal. It is possible to retrieve an unformatted (raw) value from a property by prefixing its name with =. These raw values can be parsed by other programs and follow the same conventions as the options associated with the properties.
Examples
Sometimes, the difference in amount of information carried by raw and formatted property values can be rather big. In some cases, raw values have more information, like higher precision than seconds with time-pos. Sometimes it is the other way around, e.g. aid shows track title and language in the formatted case, but only the track number if it is raw.
The On Screen Controller (short: OSC) is a minimal GUI integrated with mpv to offer basic mouse-controllability. It is intended to make interaction easier for new users and to enable precise and direct seeking.
The OSC is enabled by default if mpv was compiled with Lua support. It can be disabled entirely using the --osc=no option.
By default, the OSC will show up whenever the mouse is moved inside the player window and will hide if the mouse is not moved outside the OSC for 0.5 seconds or if the mouse leaves the window.
+---------+----------+------------------------------------------+----------+ | pl prev | pl next | title | cache | +------+--+---+------+---------+-----------+------+-------+-----+-----+----+ | play | skip | skip | time | seekbar | time | audio | sub | vol | fs | | | back | frwd | elapsed | | left | | | | | +------+------+------+---------+-----------+------+-------+-----+-----+----+
left-click | play previous file in playlist |
right-click | show playlist |
shift+L-click | show playlist |
left-click | play next file in playlist |
right-click | show playlist |
shift+L-click | show playlist |
left-click | show playlist position and length and full title |
right-click | show filename |
left-click | toggle play/pause |
left-click | go to beginning of chapter / previous chapter |
right-click | show chapters |
shift+L-click | show chapters |
left-click | go to next chapter |
right-click | show chapters |
shift+L-click | show chapters |
left-click | toggle displaying timecodes with milliseconds |
left-click | seek to position |
left-click | toggle between total and remaining time |
left-click | cycle audio/sub tracks forward |
right-click | cycle audio/sub tracks backwards |
shift+L-click | show available audio/sub tracks |
left-click | toggle mute |
mouse wheel | volume up/down |
left-click | toggle fullscreen |
These key bindings are active by default if nothing else is already bound to these keys. In case of collision, the function needs to be bound to a different key. See the Script Commands section.
del | Cycles visibility between never / auto (mouse-move) / always |
The OSC offers limited configuration through a config file script-opts/osc.conf placed in mpv's user dir and through the --script-opts command-line option. Options provided through the command-line will override those from the config file.
The config file must exactly follow the following syntax:
# this is a comment optionA=value1 optionB=value2
# can only be used at the beginning of a line and there may be no spaces around the = or anywhere else.
To avoid collisions with other scripts, all options need to be prefixed with osc-.
Example:
--script-opts=osc-optionA=value1,osc-optionB=value2
Default: bottombar
The layout for the OSC. Currently available are: box, slimbox, bottombar and topbar. Default pre-0.21.0 was 'box'.
Default: bar
Sets the style of the playback position marker and overall shape of the seekbar: bar, diamond or knob.
Default: 0.6
Size ratio of the seek handle if seekbarstyle is set to dimaond or knob. This is relative to the full height of the seekbar.
Default: yes
Controls the mode used to seek when dragging the seekbar. By default, keyframes are used. If set to false, exact seeking on mouse drags will be used instead. Keyframes are preferred, but exact seeks may be useful in cases where keyframes cannot be found. Note that using exact seeks can potentially make mouse dragging much slower.
Default: inverted
Display seekable ranges on the seekbar. bar shows them on the full height of the bar, line as a thick line and inverted as a thin line that is inverted over playback position markers. none will hide them. Additionally, slider will show a permanent handle inside the seekbar with cached ranges marked inside. Note that these will look differently based on the seekbarstyle option. Also, slider does not work with seekbarstyle set to bar.
Default: yes
Controls whether to show line-style seekable ranges on top of the seekbar or separately if seekbarstyle is set to bar.
Default: 200
Alpha of the seekable ranges, 0 (opaque) to 255 (fully transparent).
Default: 0.5
Size of the deadzone. The deadzone is an area that makes the mouse act like leaving the window. Movement there won't make the OSC show up and it will hide immediately if the mouse enters it. The deadzone starts at the window border opposite to the OSC and the size controls how much of the window it will span. Values between 0.0 and 1.0, where 0 means the OSC will always popup with mouse movement in the window, and 1 means the OSC will only show up when the mouse hovers it. Default pre-0.21.0 was 0.
Default: 0
Minimum amount of pixels the mouse has to move between ticks to make the OSC show up. Default pre-0.21.0 was 3.
Default: yes
Enable the OSC when windowed
Default: yes
Enable the OSC when fullscreen
Default: 1.0
Scale factor of the OSC when windowed.
Default: 1.0
Scale factor of the OSC when fullscreen
Default: 2.0
Scale factor of the OSC when rendered on a forced (dummy) window
Default: yes
Scale the OSC with the video no tries to keep the OSC size constant as much as the window size allows
Default: 0.8
Vertical alignment, -1 (top) to 1 (bottom)
Default: 0.0
Horizontal alignment, -1 (left) to 1 (right)
Default: 0
Margin from bottom (bottombar) or top (topbar), in pixels
Default: 80
Alpha of the background box, 0 (opaque) to 255 (fully transparent)
Default: 500
Duration in ms until the OSC hides if no mouse movement, must not be negative
Default: 200
Duration of fade out in ms, 0 = no fade
Default: ${media-title}
String that supports property expansion that will be displayed as OSC title. ASS tags are escaped, and newlines and trailing slashes are stripped.
Default: 1
Size of the tooltip outline when using bottombar or topbar layouts
Default: no
Show total time instead of time remaining
Default: no
Display timecodes with milliseconds
Default: auto (auto hide/show on mouse move)
Also supports never and always
Default: 80
Max chars for the osc title at the box layout. mpv does not measure the text width on screen and so it needs to limit it by number of chars. The default is conservative to allow wide fonts to be used without overflow. However, with many common fonts a bigger number can be used. YMMV.
Default: no
Whether to overlay the osc over the video (no), or to box the video within the areas not covered by the osc (yes). If this option is set, the osc may overwrite the --video-margin-ratio-* options, even if the user has set them. (It will not overwrite them if all of them are set to default values.)
Currently, this is supported for the bottombar and topbar layout only. The other layouts do not change if this option is set. Separately, if window controls are present (see below), they will be affected regardless of which osc layout is in use.
The border is static and appears even if the OSC is configured to appear only on mouse interaction. If the OSC is invisible, the border is simply filled with the background color (black by default).
This currently still makes the OSC overlap with subtitles (if the --sub-use-margins option is set to yes, the default). This may be fixed later.
This does not work correctly with video outputs like --vo=xv, which render OSD into the unscaled video.
Default: auto (Show window controls if there is no window border)
Whether to show window management controls over the video, and if so, which side of the window to place them. This may be desirable when the window has no decorations, either because they have been explicitly disabled (border=no) or because the current platform doesn't support them (eg: gnome-shell with wayland).
The set of window controls is fixed, offering minimize, maximize, and quit. Not all platforms implement minimize and maximize, but quit will always work.
Default: right
If window controls are shown, indicates which side should they be aligned to.
Supports left and right which will place the controls on those respective sides.
Default: no
Set to yes to reduce festivity (i.e. disable santa hat in December.)
The OSC script listens to certain script commands. These commands can bound in input.conf, or sent by other scripts.
Example
You could put this into input.conf to hide the OSC with the a key and to set auto mode (the default) with b:
a script-message osc-visibility never b script-message osc-visibility auto
This builtin script displays information and statistics for the currently played file. It is enabled by default if mpv was compiled with Lua support. It can be disabled entirely using the --load-stats-overlay=no option.
The following key bindings are active by default unless something else is already bound to them:
i | Show stats for a fixed duration |
I | Toggle stats (shown until toggled again) |
While the stats are visible on screen the following key bindings are active, regardless of existing bindings. They allow you to switch between pages of stats:
1 | Show usual stats |
2 | Show frame timings |
3 | Input cache stats |
For optimal visual experience, a font with support for many font weights and monospaced digits is recommended. By default, the open source font Source Sans Pro is used.
This script can be customized through a config file script-opts/stats.conf placed in mpv's user directory and through the --script-opts command-line option. The configuration syntax is described in ON SCREEN CONTROLLER.
Default: I
Key bindings to display stats.
Default: 3
Key bindings for page switching while stats are displayed.
Default: 4
How long the stats are shown in seconds (oneshot).
Default: 1
How long it takes to refresh the displayed stats in seconds (toggling).
Default: no
When no, other scripts printing text to the screen can overwrite the displayed stats. When yes, displayed stats are persistently shown for the respective duration. This can result in overlapping text when multiple scripts decide to print text at the same time.
Default: yes
Show graphs for performance data (page 2).
Default: yes
Show graphs for vsync and jitter values (page 1). Only when toggled.
Default: yes
Clear data buffers used for drawing graphs when toggling.
Default: Source Sans Pro
Font name. Should support as many font weights as possible for optimal visual experience.
Default: Source Sans Pro
Font name for parts where monospaced characters are necessary to align text. Currently, monospaced digits are sufficient.
Default: 8
Font size used to render text.
Default: FFFFFF
Font color.
Default: 0.8
Size of border drawn around the font.
Default: 262626
Color of drawn border.
Default: 11
Transparency for drawn text.
Default: 0000FF
Border color used for drawing graphs.
Default: 262626
Background color used for drawing graphs.
Default: FFFFFF
Color used for drawing graphs.
Note: colors are given as hexadecimal values and use ASS tag order: BBGGRR (blue green red).
A different key binding can be defined with the aforementioned options key_oneshot and key_toggle but also with commands in input.conf, for example:
e script-binding stats/display-stats E script-binding stats/display-stats-toggle
Using input.conf, it is also possible to directly display a certain page:
i script-binding stats/display-page-1 e script-binding stats/display-page-2
The console is a REPL for mpv input commands. It is displayed on the video window. It also shows log messages. It can be disabled entirely using the --load-osd-console=no option.
This script can be customized through a config file script-opts/console.conf placed in mpv's user directory and through the --script-opts command-line option. The configuration syntax is described in ON SCREEN CONTROLLER.
Key bindings can be changed in a standard way, see for example stats.lua documentation.
Default: 1
All drawing is scaled by this value, including the text borders and the cursor.
If the VO backend in use has HiDPI scale reporting implemented, the option value is scaled with the reported HiDPI scale.
Default: unset (picks a hardcoded font depending on detected platform)
Set the font used for the REPL and the console. This probably doesn't have to be a monospaced font.
Default: 16
Set the font size used for the REPL and the console. This will be multiplied by "scale."
mpv can load Lua scripts. Scripts passed to the --script option, or found in the scripts subdirectory of the mpv configuration directory (usually ~/.config/mpv/scripts/) will be loaded on program start. mpv also appends the scripts subdirectory to the end of Lua's path so you can import scripts from there too. Since it's added to the end, don't name scripts you want to import the same as Lua libraries because they will be overshadowed by them.
mpv provides the built-in module mp, which contains functions to send commands to the mpv core and to retrieve information about playback state, user settings, file information, and so on.
These scripts can be used to control mpv in a similar way to slave mode. Technically, the Lua code uses the client API internally.
A script which leaves fullscreen mode when the player is paused:
function on_pause_change(name, value) if value == true then mp.set_property("fullscreen", "no") end end mp.observe_property("pause", "bool", on_pause_change)
Your script will be loaded by the player at program start from the scripts configuration subdirectory, or from a path specified with the --script option. Some scripts are loaded internally (like --osc). Each script runs in its own thread. Your script is first run "as is", and once that is done, the event loop is entered. This event loop will dispatch events received by mpv and call your own event handlers which you have registered with mp.register_event, or timers added with mp.add_timeout or similar. Note that since the script starts execution concurrently with player initialization, some properties may not be populated with meaningful values until the relevant subsystems have initialized.
When the player quits, all scripts will be asked to terminate. This happens via a shutdown event, which by default will make the event loop return. If your script got into an endless loop, mpv will probably behave fine during playback, but it won't terminate when quitting, because it's waiting on your script.
Internally, the C code will call the Lua function mp_event_loop after loading a Lua script. This function is normally defined by the default prelude loaded before your script (see player/lua/defaults.lua in the mpv sources). The event loop will wait for events and dispatch events registered with mp.register_event. It will also handle timers added with mp.add_timeout and similar (by waiting with a timeout).
Since mpv 0.6.0, the player will wait until the script is fully loaded before continuing normal operation. The player considers a script as fully loaded as soon as it starts waiting for mpv events (or it exits). In practice this means the player will more or less hang until the script returns from the main chunk (and mp_event_loop is called), or the script calls mp_event_loop or mp.dispatch_events directly. This is done to make it possible for a script to fully setup event handlers etc. before playback actually starts. In older mpv versions, this happened asynchronously. With mpv 0.29.0, this changes slightly, and it merely waits for scripts to be loaded in this manner before starting playback as part of the player initialization phase. Scripts run though initialization in parallel. This might change again.
The mp module is preloaded, although it can be loaded manually with require 'mp'. It provides the core client API.
Run the given command. This is similar to the commands used in input.conf. See List of Input Commands.
By default, this will show something on the OSD (depending on the command), as if it was used in input.conf. See Input Command Prefixes how to influence OSD usage per command.
Returns true on success, or nil, error on error.
Similar to mp.command, but pass each command argument as separate parameter. This has the advantage that you don't have to care about quoting and escaping in some cases.
Example:
mp.command("loadfile " .. filename .. " append") mp.commandv("loadfile", filename, "append")
These two commands are equivalent, except that the first version breaks if the filename contains spaces or certain special characters.
Note that properties are not expanded. You can use either mp.command, the expand-properties prefix, or the mp.get_property family of functions.
Unlike mp.command, this will not use OSD by default either (except for some OSD-specific commands).
Similar to mp.commandv, but pass the argument list as table. This has the advantage that in at least some cases, arguments can be passed as native types. It also allows you to use named argument.
If the table is an array, each array item is like an argument in mp.commandv() (but can be a native type instead of a string).
If the table contains string keys, it's interpreted as command with named arguments. This requires at least an entry with the key name to be present, which must be a string, and contains the command name. The special entry _flags is optional, and if present, must be an array of Input Command Prefixes to apply. All other entries are interpreted as arguments.
Returns a result table on success (usually empty), or def, error on error. def is the second parameter provided to the function, and is nil if it's missing.
Like mp.command_native(), but the command is ran asynchronously (as far as possible), and upon completion, fn is called. fn has two arguments: fn(success, result, error). success is always a Boolean and is true if the command was successful, otherwise false. The second parameter is the result value (can be nil) in case of success, nil otherwise (as returned by mp.command_native()). The third parameter is the error string in case of an error, nil otherwise.
Returns a table with undefined contents, which can be used as argument for mp.abort_async_command.
If starting the command failed for some reason, nil, error is returned, and fn is called indicating failure, using the same error value.
Return the value of the given property as string. These are the same properties as used in input.conf. See Properties for a list of properties. The returned string is formatted similar to ${=name} (see Property Expansion).
Returns the string on success, or def, error on error. def is the second parameter provided to the function, and is nil if it's missing.
Similar to mp.get_property, but return the property value formatted for OSD. This is the same string as printed with ${name} when used in input.conf.
Returns the string on success, or def, error on error. def is the second parameter provided to the function, and is an empty string if it's missing. Unlike get_property(), assigning the return value to a variable will always result in a string.
Similar to mp.get_property, but return the property value as Boolean.
Returns a Boolean on success, or def, error on error.
Similar to mp.get_property, but return the property value as number.
Note that while Lua does not distinguish between integers and floats, mpv internals do. This function simply request a double float from mpv, and mpv will usually convert integer property values to float.
Returns a number on success, or def, error on error.
Similar to mp.get_property, but return the property value using the best Lua type for the property. Most time, this will return a string, Boolean, or number. Some properties (for example chapter-list) are returned as tables.
Returns a value on success, or def, error on error. Note that nil might be a possible, valid value too in some corner cases.
Set the given property to the given string value. See mp.get_property and Properties for more information about properties.
Returns true on success, or nil, error on error.
Similar to mp.set_property, but set the given property to the given numeric value.
Note that while Lua does not distinguish between integers and floats, mpv internals do. This function will test whether the number can be represented as integer, and if so, it will pass an integer value to mpv, otherwise a double float.
Similar to mp.set_property, but set the given property using its native type.
Since there are several data types which cannot represented natively in Lua, this might not always work as expected. For example, while the Lua wrapper can do some guesswork to decide whether a Lua table is an array or a map, this would fail with empty tables. Also, there are not many properties for which it makes sense to use this, instead of set_property, set_property_bool, set_property_number. For these reasons, this function should probably be avoided for now, except for properties that use tables natively.
Register callback to be run on a key binding. The binding will be mapped to the given key, which is a string describing the physical key. This uses the same key names as in input.conf, and also allows combinations (e.g. ctrl+a). If the key is empty or nil, no physical key is registered, but the user still can create own bindings (see below).
After calling this function, key presses will cause the function fn to be called (unless the user remapped the key with another binding).
The name argument should be a short symbolic string. It allows the user to remap the key binding via input.conf using the script-message command, and the name of the key binding (see below for an example). The name should be unique across other bindings in the same script - if not, the previous binding with the same name will be overwritten. You can omit the name, in which case a random name is generated internally. (Omitting works as follows: either pass nil for name, or pass the fn argument in place of the name. The latter is not recommended and is handled for compatibility only.)
The last argument is used for optional flags. This is a table, which can have the following entries:
- repeatable
- If set to true, enables key repeat for this specific binding.
- complex
If set to true, then fn is called on both key up and down events (as well as key repeat, if enabled), with the first argument being a table. This table has the following entries (and may contain undocumented ones):
- event
- Set to one of the strings down, repeat, up or press (the latter if key up/down can't be tracked).
- is_mouse
- Boolean Whether the event was caused by a mouse button.
- key_name
- The name of they key that triggered this, or nil if invoked artificially. If the key name is unknown, it's an empty string.
- key_text
- Text if triggered by a text key, otherwise nil. See description of script-binding command for details (this field is equivalent to the 5th argument).
Internally, key bindings are dispatched via the script-message-to or script-binding input commands and mp.register_script_message.
Trying to map multiple commands to a key will essentially prefer a random binding, while the other bindings are not called. It is guaranteed that user defined bindings in the central input.conf are preferred over bindings added with this function (but see mp.add_forced_key_binding).
Example:
function something_handler() print("the key was pressed") end mp.add_key_binding("x", "something", something_handler)
This will print the message the key was pressed when x was pressed.
The user can remap these key bindings. Then the user has to put the following into their input.conf to remap the command to the y key:
y script-binding something
This will print the message when the key y is pressed. (x will still work, unless the user remaps it.)
You can also explicitly send a message to a named script only. Assume the above script was using the filename fooscript.lua:
y script-binding fooscript/something
Call a specific function when an event happens. The event name is a string, and the function fn is a Lua function value.
Some events have associated data. This is put into a Lua table and passed as argument to fn. The Lua table by default contains a name field, which is a string containing the event name. If the event has an error associated, the error field is set to a string describing the error, on success it's not set.
If multiple functions are registered for the same event, they are run in registration order, which the first registered function running before all the other ones.
Returns true if such an event exists, false otherwise.
See Events and List of events for details.
Watch a property for changes. If the property name is changed, then the function fn(name) will be called. type can be nil, or be set to one of none, native, bool, string, or number. none is the same as nil. For all other values, the new value of the property will be passed as second argument to fn, using mp.get_property_<type> to retrieve it. This means if type is for example string, fn is roughly called as in fn(name, mp.get_property_string(name)).
If possible, change events are coalesced. If a property is changed a bunch of times in a row, only the last change triggers the change function. (The exact behavior depends on timing and other things.)
If a property is unavailable, or on error, the value argument to fn is nil. (The observe_property() call always succeeds, even if a property does not exist.)
In some cases the function is not called even if the property changes. This depends on the property, and it's a valid feature request to ask for better update handling of a specific property.
If the type is none or nil, sporadic property change events are possible. This means the change function fn can be called even if the property doesn't actually change.
You always get an initial change notification. This is meant to initialize the user's state to the current value of the property.
Call the given function fn when the given number of seconds has elapsed. Note that the number of seconds can be fractional. For now, the timer's resolution may be as low as 50 ms, although this will be improved in the future.
This is a one-shot timer: it will be removed when it's fired.
Returns a timer object. See mp.add_periodic_timer for details.
Call the given function periodically. This is like mp.add_timeout, but the timer is re-added after the function fn is run.
This field contains the current timeout period. This value is not updated as time progresses. It's only used to calculate when the timer should fire next when the timer expires.
If you write this, you can call t:kill() ; t:resume() to reset the current timeout to the new one. (t:stop() won't use the new timeout.)
Note that these are methods, and you have to call them using : instead of . (Refer to http://www.lua.org/manual/5.2/manual.html#3.4.9 .)
Example:
seconds = 0 timer = mp.add_periodic_timer(1, function() print("called every second") # stop it after 10 seconds seconds = seconds + 1 if seconds >= 10 then timer:kill() end end)
Return the name of the current script. The name is usually made of the filename of the script, with directory and file extension removed. If there are several scripts which would have the same name, it's made unique by appending a number.
Example
The script /path/to/fooscript.lua becomes fooscript.
These also live in the mp module, but are documented separately as they are useful only in special situations.
This can be used to run custom event loops. If you want to have direct control what the Lua script does (instead of being called by the default event loop), you can set the global variable mp_event_loop to your own function running the event loop. From your event loop, you should call mp.dispatch_events() to dequeue and dispatch mpv events.
If the allow_wait parameter is set to true, the function will block until the next event is received or the next timer expires. Otherwise (and this is the default behavior), it returns as soon as the event loop is emptied. It's strongly recommended to use mp.get_next_timeout() and mp.get_wakeup_pipe() if you're interested in properly working notification of new events and working timers.
This is a helper to dispatch script-message or script-message-to invocations to Lua functions. fn is called if script-message or script-message-to (with this script as destination) is run with name as first parameter. The other parameters are passed to fn. If a message with the given name is already registered, it's overwritten.
Used by mp.add_key_binding, so be careful about name collisions.
Create an OSD overlay. This is a very thin wrapper around the osd-overlay command. The function returns a table, which mostly contains fields that will be passed to osd-overlay. The format parameter is used to initialize the format field. The data field contains the text to be used as overlay. For details, see the osd-overlay command.
In addition, it provides the following methods:
Example:
ov = mp.create_osd_overlay("ass-events") ov.data = "{\\an5}{\\b1}hello world!" ov:update()
The advantage of using this wrapper (as opposed to running osd-overlay directly) is that the id field is allocated automatically.
Returns a tuple of osd_width, osd_height, osd_par. The first two give the size of the OSD in pixels (for video ouputs like --vo=xv, this may be "scaled" pixels). The third is the display pixel aspect ratio.
May return invalid/nonsense values if OSD is not initialized yet.
This module allows outputting messages to the terminal, and can be loaded with require 'mp.msg'.
The level parameter is the message priority. It's a string and one of fatal, error, warn, info, v, debug, trace. The user's settings will determine which of these messages will be visible. Normally, all messages are visible, except v, debug and trace.
The parameters after that are all converted to strings. Spaces are inserted to separate multiple parameters.
You don't need to add newlines.
mpv comes with a built-in module to manage options from config-files and the command-line. All you have to do is to supply a table with default options to the read_options function. The function will overwrite the default values with values found in the config-file and the command-line (in that order).
A table with key-value pairs. The type of the default values is important for converting the values read from the config file or command-line back. Do not use nil as a default value!
The identifier is used to identify the config-file and the command-line options. These needs to unique to avoid collisions with other scripts. Defaults to mp.get_script_name() if the parameter is nil or missing.
The on_update parameter enables run-time updates of all matching option values via the script-opts option/property. If any of the matching options changes, the values in the table (which was originally passed to the function) are changed, and on_update(list) is called. list is a table where each updated option has a list[option_name] = true entry. There is no initial on_update() call. This never re-reads the config file. script-opts is always applied on the original config file, ignoring previous script-opts values (for example, if an option is removed from script-opts at runtime, the option will have the value in the config file). table entries are only written for option values whose values effectively change (this is important if the script changes table entries independently).
Example implementation:
require 'mp.options' local options = { optionA = "defaultvalueA", optionB = -0.5, optionC = true, } read_options(options, "myscript") print(options.optionA)
The config file will be stored in script-opts/identifier.conf in mpv's user folder. Comment lines can be started with # and stray spaces are not removed. Boolean values will be represented with yes/no.
Example config:
# comment optionA=Hello World optionB=9999 optionC=no
Command-line options are read from the --script-opts parameter. To avoid collisions, all keys have to be prefixed with identifier-.
Example command-line:
--script-opts=myscript-optionA=TEST,myscript-optionB=0,myscript-optionC=yes
This built-in module provides generic helper functions for Lua, and have strictly speaking nothing to do with mpv or video/audio playback. They are provided for convenience. Most compensate for Lua's scarce standard library.
Be warned that any of these functions might disappear any time. They are not strictly part of the guaranteed API.
Enumerate all entries at the given path on the filesystem, and return them as array. Each entry is a directory entry (without the path). The list is unsorted (in whatever order the operating system returns it).
If the filter argument is given, it must be one of the following strings:
- files
- List regular files only. This excludes directories, special files (like UNIX device files or FIFOs), and dead symlinks. It includes UNIX symlinks to regular files.
- dirs
- List directories only, or symlinks to directories. . and .. are not included.
- normal
- Include the results of both files and dirs. (This is the default.)
- all
- List all entries, even device files, dead symlinks, FIFOs, and the . and .. entries.
On error, nil, error is returned.
Stats the given path for information and returns a table with the following entries:
- mode
- protection bits (on Windows, always 755 (octal) for directories and 644 (octal) for files)
- size
- size in bytes
- atime
- time of last access
- mtime
- time of last modification
- ctime
- time of last metadata change (Linux) / time of creation (Windows)
- is_file
- Whether path is a regular file (boolean)
- is_dir
- Whether path is a directory (boolean)
mode and size are integers. Timestamps (atime, mtime and ctime) are integer seconds since the Unix epoch (Unix time). The booleans is_file and is_dir are provided as a convenience; they can be and are derived from mode.
On error (eg. path does not exist), nil, error is returned.
Runs an external process and waits until it exits. Returns process status and the captured output. This is a legacy wrapper around calling the subprocess command with mp.command_native. It does the following things:
It is recommended to use mp.command_native or mp.command_native_async directly, instead of calling this legacy wrapper. It is for compatibility only.
See the subprocess documentation for semantics and further parameters.
Runs an external process and detaches it from mpv's control.
The parameter t is a table. The function reads the following entries:
- args
- Array of strings of the same semantics as the args used in the subprocess function.
The function returns nil.
This is a legacy wrapper around calling the run command with mp.commandv and other functions.
Parses the given string argument as JSON, and returns it as a Lua table. On error, returns nil, error. (Currently, error is just a string reading error, because there is no fine-grained error reporting of any kind.)
The returned value uses similar conventions as mp.get_property_native() to distinguish empty objects and arrays.
If the trail parameter is true (or any value equal to true), then trailing non-whitespace text is tolerated by the function, and the trailing text is returned as 3rd return value. (The 3rd return value is always there, but with trail set, no error is raised.)
Format the given Lua table (or value) as a JSON string and return it. On error, returns nil, error. (Errors usually only happen on value types incompatible with JSON.)
The argument value uses similar conventions as mp.set_property_native() to distinguish empty objects and arrays.
Events are notifications from player core to scripts. You can register an event handler with mp.register_event.
Note that all scripts (and other parts of the player) receive events equally, and there's no such thing as blocking other scripts from receiving events.
Example:
function my_fn(event) print("start of playback!") end mp.register_event("file-loaded", my_fn)
Happens after a file was unloaded. Typically, the player will load the next file right away, or quit if this was the last file.
The event has the reason field, which takes one of these values:
Receives messages enabled with mp.enable_messages. The message data is contained in the table passed as first parameter to the event handler. The table contains, in addition to the default event fields, the following fields:
Keep in mind that these messages are meant to be hints for humans. You should not parse them, and prefix/level/text of messages might change any time.
The following events also happen, but are deprecated: tracks-changed, track-switched, pause, unpause, metadata-update, chapter-change. Use mp.observe_property() instead.
This documents experimental features, or features that are "too special" to guarantee a stable interface.
Add a hook callback for type (a string identifying a certain kind of hook). These hooks allow the player to call script functions and wait for their result (normally, the Lua scripting interface is asynchronous from the point of view of the player core). priority is an arbitrary integer that allows ordering among hooks of the same kind. Using the value 50 is recommended as neutral default value. fn is the function that will be called during execution of the hook.
See Hooks for currently existing hooks and what they do - only the hook list is interesting; handling hook execution is done by the Lua script function automatically.
JavaScript support in mpv is near identical to its Lua support. Use this section as reference on differences and availability of APIs, but otherwise you should refer to the Lua documentation for API details and general scripting in mpv.
JavaScript code which leaves fullscreen mode when the player is paused:
function on_pause_change(name, value) { if (value == true) mp.set_property("fullscreen", "no"); } mp.observe_property("pause", "bool", on_pause_change);
mpv tries to load a script file as JavaScript if it has a .js extension, but otherwise, the documented Lua options, script directories, loading, etc apply to JavaScript files too.
Script initialization and lifecycle is the same as with Lua, and most of the Lua functions at the modules mp, mp.utils, mp.msg and mp.options are available to JavaScript with identical APIs - including running commands, getting/setting properties, registering events/key-bindings/hooks, etc.
No need to load modules. mp, mp.utils, mp.msg and mp.options are preloaded, and you can use e.g. var cwd = mp.utils.getcwd(); without prior setup.
Errors are slightly different. Where the Lua APIs return nil for error, the JavaScript ones return undefined. Where Lua returns something, error JavaScript returns only something - and makes error available via mp.last_error(). Note that only some of the functions have this additional error value - typically the same ones which have it in Lua.
Standard APIs are preferred. For instance setTimeout and JSON.stringify are available, but mp.add_timeout and mp.utils.format_json are not.
No standard library. This means that interaction with anything outside of mpv is limited to the available APIs, typically via mp.utils. However, some file functions were added, and CommonJS require is available too - where the loaded modules have the same privileges as normal scripts.
The scripting backend which mpv currently uses is MuJS - a compatible minimal ES5 interpreter. As such, String.substring is implemented for instance, while the common but non-standard String.substr is not. Please consult the MuJS pages on language features and platform support - http://mujs.com .
mp.add_timeout(seconds, fn) JS: id = setTimeout(fn, ms)
mp.add_periodic_timer(seconds, fn) JS: id = setInterval(fn, ms)
utils.parse_json(str [, trail]) JS: JSON.parse(str)
utils.format_json(v) JS: JSON.stringify(v)
utils.to_string(v) see dump below.
mp.suspend() JS: none (deprecated).
mp.resume() JS: none (deprecated).
mp.resume_all() JS: none (deprecated).
mp.get_next_timeout() see event loop below.
mp.dispatch_events([allow_wait]) see event loop below.
(LE) - Last-Error, indicates that mp.last_error() can be used after the call to test for success (empty string) or failure (non empty reason string). Where the Lua APIs use nil to indicate error, JS APIs use undefined.
mp.command(string) (LE)
mp.commandv(arg1, arg2, ...) (LE)
mp.command_native(table [,def]) (LE)
id = mp.command_native_async(table [,fn]) (LE) Notes: id is true-thy on success, fn is called always a-sync, error is empty string on success.
mp.abort_async_command(id)
mp.get_property(name [,def]) (LE)
mp.get_property_osd(name [,def]) (LE)
mp.get_property_bool(name [,def]) (LE)
mp.get_property_number(name [,def]) (LE)
mp.get_property_native(name [,def]) (LE)
mp.set_property(name, value) (LE)
mp.set_property_bool(name, value) (LE)
mp.set_property_number(name, value) (LE)
mp.set_property_native(name, value) (LE)
mp.get_time()
mp.add_key_binding(key, name|fn [,fn [,flags]])
mp.add_forced_key_binding(...)
mp.remove_key_binding(name)
mp.register_event(name, fn)
mp.unregister_event(fn)
mp.observe_property(name, type, fn)
mp.unobserve_property(fn)
mp.get_opt(key)
mp.get_script_name()
mp.osd_message(text [,duration])
mp.get_wakeup_pipe()
mp.register_idle(fn)
mp.unregister_idle(fn)
mp.enable_messages(level)
mp.register_script_message(name, fn)
mp.unregister_script_message(name)
mp.create_osd_overlay(format)
mp.get_osd_size() (returned object has properties: width, height, aspect)
mp.msg.log(level, ...)
mp.msg.fatal(...)
mp.msg.error(...)
mp.msg.warn(...)
mp.msg.info(...)
mp.msg.verbose(...)
mp.msg.debug(...)
mp.msg.trace(...)
mp.utils.getcwd() (LE)
mp.utils.readdir(path [, filter]) (LE)
mp.utils.file_info(path) (LE)
mp.utils.split_path(path)
mp.utils.join_path(p1, p2)
mp.utils.subprocess(t)
mp.utils.subprocess_detached(t)
mp.utils.getpid() (LE)
mp.add_hook(type, priority, fn)
mp.options.read_options(obj [, identifier [, on_update]]) (types: string/boolean/number)
Note: read_file and write_file throw on errors, allow text content only.
The standard HTML/node.js timers are available:
id = setTimeout(fn [,duration [,arg1 [,arg2...]]])
id = setTimeout(code_string [,duration])
clearTimeout(id)
id = setInterval(fn [,duration [,arg1 [,arg2...]]])
id = setInterval(code_string [,duration])
clearInterval(id)
setTimeout and setInterval return id, and later call fn (or execute code_string) after duration ms. Interval also repeat every duration.
duration has a minimum and default value of 0, code_string is a plain string which is evaluated as JS code, and [,arg1 [,arg2..]] are used as arguments (if provided) when calling back fn.
The clear...(id) functions cancel timer id, and are irreversible.
Note: timers always call back asynchronously, e.g. setTimeout(fn) will never call fn before returning. fn will be called either at the end of this event loop iteration or at a later event loop iteration. This is true also for intervals - which also never call back twice at the same event loop iteration.
Additionally, timers are processed after the event queue is empty, so it's valid to use setTimeout(fn) as a one-time idle observer.
CommonJS Modules are a standard system where scripts can export common functions for use by other scripts. Specifically, a module is a script which adds properties (functions, etc) to its pre-existing exports object, which another script can access with require(module-id). This runs the module and returns its exports object. Further calls to require for the same module will return its cached exports object without running the module again.
Modules and require are supported, standard compliant, and generally similar to node.js. However, most node.js modules won't run due to missing modules such as fs, process, etc, but some node.js modules with minimal dependencies do work. In general, this is for mpv modules and not a node.js replacement.
A .js file extension is always added to id, e.g. require("./foo") will load the file ./foo.js and return its exports object.
An id is relative (to the script which require'd it) if it starts with ./ or ../. Otherwise, it's considered a "top-level id" (CommonJS term).
Top level id is evaluated as absolute filesystem path if possible, e.g. /x/y or ~/x. Otherwise, it's considered a global module id and searched at scripts/modules.js/ in mpv config dirs - in normal config search order. E.g. require("x") is searched as file x.js at those dirs, and id foo/x is searched as file x.js inside dir foo at those dirs.
Search paths for global module id's are at the array mp.module_paths, which is searched in order. Initially it contains one item: ~~/scripts/modules.js such that it behaves as described above. Modifying it will affect future require calls with global module id's which are not already loaded/cached.
No global variable, but a module's this at its top lexical scope is the global object - also in strict mode. If you have a module which needs global as the global object, you could do this.global = this; before require.
Functions and variables declared at a module don't pollute the global object.
The event loop poll/dispatch mpv events as long as the queue is not empty, then processes the timers, then waits for the next event, and repeats this forever.
You could put this code at your script to replace the built-in event loop, and also print every event which mpv sends to your script:
function mp_event_loop() { var wait = 0; do { var e = mp.wait_event(wait); dump(e); // there could be a lot of prints... if (e.event != "none") { mp.dispatch_event(e); wait = 0; } else { wait = mp.process_timers() / 1000; if (wait != 0) { mp.notify_idle_observers(); wait = mp.peek_timers_wait() / 1000; } } } while (mp.keep_running); }
mp_event_loop is a name which mpv tries to call after the script loads. The internal implementation is similar to this (without dump though..).
e = mp.wait_event(wait) returns when the next mpv event arrives, or after wait seconds if positive and no mpv events arrived. wait value of 0 returns immediately (with e.event == "none" if the queue is empty).
mp.dispatch_event(e) calls back the handlers registered for e.event, if there are such (event handlers, property observers, script messages, etc).
mp.process_timers() calls back the already-added, non-canceled due timers, and returns the duration in ms till the next due timer (possibly 0), or -1 if there are no pending timers. Must not be called recursively.
mp.notify_idle_observers() calls back the idle observers, which we do when we're about to sleep (wait != 0), but the observers may add timers or take non-negligible duration to complete, so we re-calculate wait afterwards.
mp.peek_timers_wait() returns the same values as mp.process_timers() but without doing anything. Invalid result if called from a timer callback.
Note: exit() is also registered for the shutdown event, and its implementation is a simple mp.keep_running = false.
mpv can be controlled by external programs using the JSON-based IPC protocol. It can be enabled by specifying the path to a unix socket or a named pipe using the option --input-ipc-server. Clients can connect to this socket and send commands to the player or receive events from it.
Warning
This is not intended to be a secure network protocol. It is explicitly insecure: there is no authentication, no encryption, and the commands themselves are insecure too. For example, the run command is exposed, which can run arbitrary system commands. The use-case is controlling the player locally. This is not different from the MPlayer slave protocol.
You can use the socat tool to send commands (and receive replies) from the shell. Assuming mpv was started with:
mpv file.mkv --input-ipc-server=/tmp/mpvsocket
Then you can control it using socat:
> echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpvsocket {"data":190.482000,"error":"success"}
In this case, socat copies data between stdin/stdout and the mpv socket connection.
See the --idle option how to make mpv start without exiting immediately or playing a file.
It's also possible to send input.conf style text-only commands:
> echo 'show-text ${playback-time}' | socat - /tmp/mpvsocket
But you won't get a reply over the socket. (This particular command shows the playback time on the player's OSD.)
Unfortunately, it's not as easy to test the IPC protocol on Windows, since Windows ports of socat (in Cygwin and MSYS2) don't understand named pipes. In the absence of a simple tool to send and receive from bidirectional pipes, the echo command can be used to send commands, but not receive replies from the command prompt.
Assuming mpv was started with:
mpv file.mkv --input-ipc-server=\\.\pipe\mpvsocket
You can send commands from a command prompt:
echo show-text ${playback-time} >\\.\pipe\mpvsocket
To be able to simultaneously read and write from the IPC pipe, like on Linux, it's necessary to write an external program that uses overlapped file I/O (or some wrapper like .NET's NamedPipeClientStream.)
The protocol uses UTF-8-only JSON as defined by RFC-8259. Unlike standard JSON, "u" escape sequences are not allowed to construct surrogate pairs. To avoid getting conflicts, encode all text characters including and above codepoint U+0020 as UTF-8. mpv might output broken UTF-8 in corner cases (see "UTF-8" section below).
Clients can execute commands on the player by sending JSON messages of the following form:
{ "command": ["command_name", "param1", "param2", ...] }
where command_name is the name of the command to be executed, followed by a list of parameters. Parameters must be formatted as native JSON values (integers, strings, booleans, ...). Every message must be terminated with \n. Additionally, \n must not appear anywhere inside the message. In practice this means that messages should be minified before being sent to mpv.
mpv will then send back a reply indicating whether the command was run correctly, and an additional field holding the command-specific return data (it can also be null).
{ "error": "success", "data": null }
mpv will also send events to clients with JSON messages of the following form:
{ "event": "event_name" }
where event_name is the name of the event. Additional event-specific fields can also be present. See List of events for a list of all supported events.
Because events can occur at any time, it may be difficult at times to determine which response goes with which command. Commands may optionally include a request_id which, if provided in the command request, will be copied verbatim into the response. mpv does not intrepret the request_id in any way; it is solely for the use of the requester. The only requirement is that the request_id field must be an integer (a number without fractional parts in the range -2^63..2^63-1). Using other types is deprecated and will currently show a warning. In the future, this will raise an error.
For example, this request:
{ "command": ["get_property", "time-pos"], "request_id": 100 }
Would generate this response:
{ "error": "success", "data": 1.468135, "request_id": 100 }
If you don't specify a request_id, command replies will set it to 0.
Commands may run asynchronously in the future, instead of blocking the socket until a reply is sent.
All commands, replies, and events are separated from each other with a line break character (\n).
If the first character (after skipping whitespace) is not {, the command will be interpreted as non-JSON text command, as they are used in input.conf (or mpv_command_string() in the client API). Additionally, lines starting with # and empty lines are ignored.
Currently, embedded 0 bytes terminate the current line, but you should not rely on this.
In addition to the commands described in List of Input Commands, a few extra commands can also be used as part of the protocol:
Return the value of the given property. The value will be sent in the data field of the replay message.
Example:
{ "command": ["get_property", "volume"] } { "data": 50.0, "error": "success" }
Like get_property, but the resulting data will always be a string.
Example:
{ "command": ["get_property_string", "volume"] } { "data": "50.000000", "error": "success" }
Set the given property to the given value. See Properties for more information about properties.
Example:
{ "command": ["set_property", "pause", true] } { "error": "success" }
Watch a property for changes. If the given property is changed, then an event of type property-change will be generated
Example:
{ "command": ["observe_property", 1, "volume"] } { "error": "success" } { "event": "property-change", "id": 1, "data": 52.0, "name": "volume" }
Warning
If the connection is closed, the IPC client is destroyed internally, and the observed properties are unregistered. This happens for example when sending commands to a socket with separate socat invocations. This can make it seem like property observation does not work. You must keep the IPC connection open to make it work.
Like observe_property, but the resulting data will always be a string.
Example:
{ "command": ["observe_property_string", 1, "volume"] } { "error": "success" } { "event": "property-change", "id": 1, "data": "52.000000", "name": "volume" }
Undo observe_property or observe_property_string. This requires the numeric id passed to the observed command as argument.
Example:
{ "command": ["unobserve_property", 1] } { "error": "success" }
Enable output of mpv log messages. They will be received as events. The parameter to this command is the log-level (see mpv_request_log_messages C API function).
Log message output is meant for humans only (mostly for debugging). Attempting to retrieve information by parsing these messages will just lead to breakages with future mpv releases. Instead, make a feature request, and ask for a proper event that returns the information you need.
Enables or disables the named event. Mirrors the mpv_request_event C API function. If the string all is used instead of an event name, all events are enabled or disabled.
By default, most events are enabled, and there is not much use for this command.
Returns the client API version the C API of the remote mpv instance provides.
See also: DOCS/client-api-changes.rst.
Normally, all strings are in UTF-8. Sometimes it can happen that strings are in some broken encoding (often happens with file tags and such, and filenames on many Unixes are not required to be in UTF-8 either). This means that mpv sometimes sends invalid JSON. If that is a problem for the client application's parser, it should filter the raw data for invalid UTF-8 sequences and perform the desired replacement, before feeding the data to its JSON parser.
mpv will not attempt to construct invalid UTF-8 with broken "u" escape sequences. This includes surrogate pairs.
The following non-standard extensions are supported:
- a list or object item can have a trailing ","
- object syntax accepts "=" in addition of ":"
- object keys can be unquoted, if they start with a character in "A-Za-z_" and contain only characters in "A-Za-z0-9_"
- byte escapes with "xAB" are allowed (with AB being a 2 digit hex number)
Example:
{ objkey = "value\x0A" }
Is equivalent to:
{ "objkey": "value\n" }
There is no real changelog, but you can look at the following things:
The release changelog, which should contain most user-visible changes, including new features and bug fixes:
The git log, which is the "real" changelog
The files client-api-changes.rst and interface-changes.rst in the DOCS sub directoryon the git repository, which document API and user interface changes (the latter usually documents breaking changes only, rather than additions).
The file mplayer-changes.rst in the DOCS sub directory on the git repository, which used to be in place of this section. It documents some changes that happened since mplayer2 forked off MPlayer. (Not updated anymore.)
mpv can be embedded into other programs as video/audio playback backend. The recommended way to do so is using libmpv. See libmpv/client.h in the mpv source code repository. This provides a C API. Bindings for other languages might be available (see wiki).
Since libmpv merely allows access to underlying mechanisms that can control mpv, further documentation is spread over a few places:
You can write C plugins for mpv. These use the libmpv API, although they do not use the libmpv library itself.
Currently, they must be explicitly enabled at build time with --enable-cplugins. They are available on Linux/BSD platforms only.
C plugins are put into the mpv scripts directory in its config directory (see the FILES section for details). They must have a .so file extension. They can also be explicitly loaded with the --script option.
A C plugin must export the following function:
int mpv_open_cplugin(mpv_handle *handle)
The plugin function will be called on loading time. This function does not return as long as your plugin is loaded (it runs in its own thread). The handle will be deallocated as soon as the plugin function returns.
The return value is interpreted as error status. A value of 0 is interpreted as success, while -1 signals an error. In the latter case, the player prints an uninformative error message that loading failed.
Return values other than 0 and -1 are reserved, and trigger undefined behavior.
Within the plugin function, you can call libmpv API functions. The handle is created by mpv_create_client() (or actually an internal equivalent), and belongs to you. You can call mpv_wait_event() to wait for things happening, and so on.
Note that the player might block until your plugin calls mpv_wait_event() for the first time. This gives you a chance to install initial hooks etc. before playback begins.
The details are quite similar to Lua scripts.
The current implementation requires that your plugins are not linked against libmpv. What your plugins uses are not symbols from a libmpv binary, but symbols from the mpv host binary.
There are a number of environment variables that can be used to control the behavior of mpv.
Used to determine mpv config directory. If XDG_CONFIG_HOME is not set, $HOME/.config/mpv is used.
$HOME/.mpv is always added to the list of config search paths with a lower priority.
This library accesses various environment variables. However, they are not centrally documented, and documenting them is not our job. Therefore, this list is incomplete.
Notable environment variables:
Sets the authentication and decryption method that libdvdcss will use to read scrambled discs. Can be one of title, key or disc.
Sets the libdvdcss verbosity level.
0: | Outputs no messages at all. |
---|---|
1: | Outputs error messages to stderr. |
2: | Outputs error messages and debug messages to stderr. |
Normally mpv returns 0 as exit code after finishing playback successfully. If errors happen, the following exit codes can be returned:
1: Error initializing mpv. This is also returned if unknown options are passed to mpv. 2: The file passed to mpv couldn't be played. This is somewhat fuzzy: currently, playback of a file is considered to be successful if initialization was mostly successful, even if playback fails immediately after initialization. 3: There were some files that could be played, and some files which couldn't (using the definition of success from above). 4: Quit due to a signal, Ctrl+c in a VO window (by default), or from the default quit key bindings in encoding mode.
Note that quitting the player manually will always lead to exit code 0, overriding the exit code that would be returned normally. Also, the quit input command can take an exit code: in this case, that exit code is returned.
For Windows-specifics, see FILES ON WINDOWS section.
Fontconfig fonts.conf that is customized for mpv. You should include system fonts.conf in this file or mpv would not know about fonts that you already have in the system.
Only available when libass is built with fontconfig.
Contains temporary config files needed for resuming playback of files with the watch later feature. See for example the Q key binding, or the quit-watch-later input command.
Each file is a small config file which is loaded if the corresponding media file is loaded. It contains the playback position and some (not necessarily all) settings that were changed during playback. The filenames are hashed from the full paths of the media files. It's in general not possible to extract the media filename from this hash. However, you can set the --write-filename-in-watch-later-config option, and the player will add the media filename to the contents of the resume config file.
This is loaded by the OSC script. See the ON SCREEN CONTROLLER docs for details.
Other files in this directory are specific to the corresponding scripts as well, and the mpv core doesn't touch them.
Note that the environment variables $XDG_CONFIG_HOME and $MPV_HOME can override the standard directory ~/.config/mpv/.
Also, the old config location at ~/.mpv/ is still read, and if the XDG variant does not exist, will still be preferred.
On win32 (if compiled with MinGW, but not Cygwin), the default config file locations are different. They are generally located under %APPDATA%/mpv/. For example, the path to mpv.conf is %APPDATA%/mpv/mpv.conf, which maps to a system and user-specific path, for example
C:\users\USERNAME\AppData\Roaming\mpv\mpv.conf
You can find the exact path by running echo %APPDATA%\mpv\mpv.conf in cmd.exe.
Other config files (such as input.conf) are in the same directory. See the FILES section above.
The environment variable $MPV_HOME completely overrides these, like on UNIX.
If a directory named portable_config next to the mpv.exe exists, all config will be loaded from this directory only. Watch later config files are written to this directory as well. (This exists on Windows only and is redundant with $MPV_HOME. However, since Windows is very scripting unfriendly, a wrapper script just setting $MPV_HOME, like you could do it on other systems, won't work. portable_config is provided for convenience to get around this restriction.)
Config files located in the same directory as mpv.exe are loaded with lower priority. Some config files are loaded only once, which means that e.g. of 2 input.conf files located in two config directories, only the one from the directory with higher priority will be loaded.
A third config directory with the lowest priority is the directory named mpv in the same directory as mpv.exe. This used to be the directory with the highest priority, but is now discouraged to use and might be removed in the future.
Note that mpv likes to mix / and \ path separators for simplicity. kernel32.dll accepts this, but cmd.exe does not.