mpv(1)
๐ NAME ๐
okay bestie, welcome to mpv(1) โ the multimedia section of the manual, and this page is literally all about mpv, which is a media player. that's it. that's the name. ๐
๐ธ SYNOPSIS ๐ธ
mpv [options] [file|URL|PLAYLIST|-]
mpv [options] files
๐ฆ DESCRIPTION ๐ฆ
so like, mpv is a media player built on top of MPlayer and mplayer2. she supports a wide variety of video file formats, audio and video codecs, and subtitle types โ the range is honestly iconic. ๐ซถ
there are also special input URL types that let you read input from a bunch of sources that aren't just disk files, which is giving versatility. and depending on your platform, a whole variety of different video and audio output methods are supported. no cap.
if you wanna get started fast, there are usage examples at the end of this man page. go look, i'll wait. ๐
โจ INTERACTIVE CONTROL โจ
mpv has a fully configurable, command-driven control layer, which means you can drive her with your keyboard, your mouse, or a remote control. (quick note: there is no LIRC support โ you configure remotes as input devices instead. okay? okay. ๐
)
peep the --input- options if you wanna customize any of this.
the listings below are not necessarily complete, just so we're clear. the real full list of default bindings lives in etc/input.conf in the mpv source files. and your own input.conf files and Lua scripts can define additional key bindings on top of that. slay.
for more on configuring keybindings, go read COMMAND INTERFACE and the Key names sections.
also worth knowing: --input-test gives you interactive binding details by key, and the stats built-in script gives you the key bindings list (including printing it to the terminal). by default, the ? key toggles the display of this list. โจ
๐ Keyboard Control ๐
LEFTandRIGHTโ seek backward/forward 5 seconds.Shift+arrow does a 1 second exact seek (see--hr-seek).UPandDOWNโ seek forward/backward 1 minute.Shift+arrow does a 5 second exact seek (see--hr-seek).Ctrl+LEFTandCtrl+RIGHTโ seek to the previous/next subtitle. this one is subject to some restrictions and might not always work, so don't come for her; see thesub-seekcommand.Ctrl+Shift+LEFTandCtrl+Shift+RIGHTโ adjust subtitle delay so that the previous or next subtitle is displayed now. this is especially useful for syncing subtitles to audio. chef's kiss. ๐ญ[and]โ decrease/increase current playback speed by 10%.{and}โ halve/double current playback speed.BACKSPACEโ reset playback speed to normal. periodt.Shift+BACKSPACEโ undo the last seek. this only works if the playlist entry was not changed. hitting it a second time will go back to the original position. see therevert-seekcommand for details.Shift+Ctrl+BACKSPACEโ mark the current position. this then gets used byShift+BACKSPACEas the revert position (once you seek back, the marker will be reset). you can use this to seek around in the file and then return to the exact position where you left off. main character behaviour, honestly.<and>โ go backward/forward in the playlist.ENTERโ go forward in the playlist.Shift+HOMEandShift+ENDโ go to the first/last playlist entry.pandSPACEโ pause (pressing again unpauses)..โ step forward. pressing once will pause, and every consecutive press will play one frame and then go into pause mode again.,โ step backward. pressing once will pause, and every consecutive press will play one frame in reverse and then go into pause mode again.qโ stop playing and quit.Qโ likeq, but store the current playback position. playing the same file later will resume at the old playback position if possible. see RESUMING PLAYBACK./and*โ decrease/increase volume.KP_DIVIDEandKP_MULTIPLYโ decrease/increase volume.9and0โ decrease/increase volume.mโ mute sound._โ cycle through the available video tracks.#โ cycle through the available audio tracks.Eโ cycle through the available Editions.fโ toggle fullscreen (see also--fs).ESCโ exit fullscreen mode.Tโ toggle stay-on-top (see also--ontop).wandWโ decrease/increase pan-and-scan range. theekey does the same asWcurrently, but use is discouraged. see--panscanfor more information.oandPโ show progression bar, elapsed time and total duration on the OSD.Oโ toggle OSD states between normal and playback time/duration.vโ toggle subtitle visibility.Alt+vโ toggle secondary subtitle visibility.jandJโ cycle through the available subtitles.zandZโ adjust subtitle delay by -/+ 0.1 seconds. thexkey does the same asZcurrently, but use is discouraged.lโ set/clear A-B loop points. see theab-loopcommand for details.Lโ toggle infinite looping.Ctrl++andCtrl+-โ adjust audio delay (A/V sync) by +/- 0.1 seconds.Ctrl+KP_ADDandCtrl+KP_SUBTRACTโ adjust audio delay (A/V sync) by +/- 0.1 seconds.GandFโ adjust subtitle font size by +/- 10%.uโ switch between applying only--sub-ass-*overrides (default) to SSA/ASS subtitles, and overriding them almost completely with the normal subtitle style. see--sub-ass-overridefor more info.Vโ cycle through which video data gets used for ASS rendering. see--sub-ass-use-video-datafor more info.randRโ move subtitles up/down. thetkey does the same asRcurrently, but use is discouraged.sโ take a screenshot.Sโ take a screenshot, without subtitles. (whether this works depends on VO driver support, so, y'know. ๐)Ctrl+sโ take a screenshot, as the window shows it (with subtitles, OSD, and scaled video).HOMEโ seek to the beginning of the file.PGUPandPGDWNโ seek to the beginning of the previous/next chapter. in most cases, "previous" will actually go to the beginning of the current chapter; see--chapter-seek-threshold.Shift+PGUPandShift+PGDWNโ seek backward or forward by 10 minutes. (this used to be mapped toPGUP/PGDWNwithoutShift.)bโ activate/deactivate debanding.dโ cycle the deinterlacing filter.Aโ cycle aspect ratio override.Ctrl+hโ toggle hardware video decoding on/off.Alt+LEFT,Alt+RIGHT,Alt+UP,Alt+DOWNโ move the video rectangle (panning).Alt++andAlt+-โ change video zoom.Alt+KP_ADDandAlt+KP_SUBTRACTโ change video zoom.Alt+BACKSPACEโ reset the pan/zoom settings.F8โ show the playlist and the current position in it.F9โ show the list of audio and subtitle streams.Ctrl+vโ append the file or URL in the clipboard to the playlist. if nothing is currently playing, it is played immediately. only works on platforms that support theclipboardproperty. iykyk.iandIโ show/toggle an overlay displaying statistics about the currently playing file such as codec, framerate, number of dropped frames and so on. see STATS for more information.?โ toggle an overlay displaying the active key bindings. see STATS for more information.DELโ cycle OSC visibility between never / auto (mouse-move) / always`โ show the console. (ESCcloses it again. see CONSOLE.)
(the following keys are valid only when using a video output that supports the corresponding adjustment. ๐)
1and2โ adjust contrast.3and4โ adjust brightness.5and6โ adjust gamma.7and8โ adjust saturation.Alt+0(andCommand+0on macOS) โ resize video window to half its original size.Alt+1(andCommand+1on macOS) โ resize video window to its original size.Alt+2(andCommand+2on macOS) โ resize video window to double its original size.Command + f(macOS only) โ toggle fullscreen (see also--fs).
(the following keybindings open a menu in the console that lets you choose from a list of items by typing part of the desired item, by clicking the desired item, or by navigating them with keybindings: Down and Ctrl+n go down, Up and Ctrl+p go up, Page down and Ctrl+f scroll down one page, and Page up and Ctrl+b scroll up one page. ๐ง)
in track menus, selecting the current tracks disables it.
g-pโ select a playlist entry.g-sโ select a subtitle track.g-Sโ select a secondary subtitle track.g-aโ select an audio track.g-vโ select a video track.g-tโ select a track of any type.g-cโ select a chapter.g-eโ select an MKV edition or DVD/Blu-ray title.g-lโ select a subtitle line to seek to. this currently requiresffmpeginPATH, or in the same folder asmpvon Windows.g-dโ select an audio device.g-hโ select a file from the watch history. requires--save-watch-history.g-wโ select a file from watch later config files (see RESUMING PLAYBACK) to resume playing. requires--write-filename-in-watch-later-config.g-bโ select a defined input binding.g-rโ show the values of all properties.g-m,MENU,Ctrl+pโ show a menu with miscellaneous entries.
see SELECT for more information. ๐
(the following keys are valid if you have a keyboard with multimedia keys. โจ)
PAUSEโ pause.STOPโ stop playing and quit.PREVIOUSandNEXTโ seek backward/forward 1 minute.ZOOMINandZOOMOUTโ change video zoom.
if you're missing some older key bindings, go look at etc/restore-old-bindings.conf in the mpv git repository. she's got you. ๐ซถ
๐ญ Mouse Control ๐ญ
Ctrl+left clickโ pan while holding the button, keeping the clicked part of the video under the cursor.Left double clickโ toggle fullscreen on/off.Right clickโ toggle pause on/off.Forward/Back buttonโ skip to next/previous entry in playlist.Wheel up/downโ decrease/increase volume.Wheel left/rightโ seek forward/backward 10 seconds.Ctrl+Wheel up/downโ change video zoom keeping the part of the video hovered by the cursor under it.
๐ Context Menu ๐
Context Menu is a menu that pops up on the video window when the user interacts with it (mouse right click, etc.).
to use this feature, you need to fill the menu-data property with menu definition data, and add a keybinding to run the context-menu command. you can do all that with a user script. ๐
๐ USAGE ๐
command line arguments starting with - are interpreted as options, and everything else is interpreted 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 ./-. ๐
)
Okay so real talk: every flag option in mpv has a no-flag counterpart. Like, the opposite of --fs is --no-fs. And --fs=yes is literally the same thing as --fs, while --fs=no is the same as --no-fs. Symmetry, we love to see it. ๐
If an option is marked as (XXX only), it will only work in combination with the XXX option or if XXX is compiled in.
๐ Legacy option syntax ๐
Bestie, the --option=value syntax is not strictly enforced, and the alternative legacy syntax -option value and -option=value will also work. It's mostly for compatibility with MPlayer. Using these should be avoided. Their semantics can change any time in the future. No cap.
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. And 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.
๐ฆ Escaping spaces and other special characters ๐ฆ
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
Note: where applicable with JSON-IPC, %n% is the length in UTF-8 bytes, after decoding the JSON data.
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.
๐ Paths ๐
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.) Slay.
The special argument -- can be used to stop mpv from interpreting the following arguments as options.
For paths passed to mpv suboptions (options that have multiple : and ,-separated values), the situation is further complicated by the need to escape special characters. To work around this, the path can instead be wrapped in the "fixed-length" syntax, e.g. %n%string_of_length_n (see above).
When using the libmpv 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.
The same applies when you're using the scripting API, where you should avoid using mp.command, and instead prefer using "separate parameter" APIs, such as mp.commandv and mp.command_native.
Some mpv options will interpret special meanings for paths starting with ~, making it easy to dynamically find special directories, such as referring to the current user's home directory or the mpv configuration directory.
When using the special ~ prefix, there must always be a trailing / after the special path prefix. In other words, ~ doesn't work, but ~/ will work. (Iconic behavior tbh.)
The following special paths/keywords are currently recognized:
Warning: Beware that if--no-configis used, all of the "config directory"-based paths (~~/,~~home/and~~global/) will be empty strings. This means that~~home/would expand to an empty string, and that sub-paths such as~~home/foo/bar"would expand to a relative path (foo/bar), which may not be what you expected. Furthermore, any commands that search in config directories will fail to find anything, since there won't be any directories to search in. Be sure that your scripts can handle these "no config" scenarios.
~/โ The current user's home directory (equivalent to~/and$HOME/in terminal environments).~~/โ If the sub-path exists in any of mpv's config directories, then the path of the existing file/dir is returned. Otherwise this is equivalent to~~home/.~~home/โ mpv's config dir (for example~/.config/mpv/).~~global/โ The global config path (such as/etc/mpv), if available (not on win32).~~osxbundle/โ The macOS bundle resource path (macOS only).~~desktop/โ The path to the desktop.~~exe_dir/โ The path to the directory containingmpv.exe(for config file purposes,$MPV_HOMEwill override this) (win32 only).~~cache/โ The path to application cache data (~/.cache/mpv/). On some platforms, this will be the same as~~home/.~~state/โ The path to application state data (~/.local/state/mpv/). On some platforms, this will be the same as~~home/.~~old_home/โ Do not use. ๐ซ
๐ Per-File Options ๐
When playing multiple files, any option given on the command line usually affects all files. Example:
so bestie, if you run this:
mpv --a file1.mkv --b file2.mkv --c
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ File โ Active options โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ file1.mkv โ --a --b --c โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ file2.mkv โ --a --b --c โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโ
both files get the whole squad of options ๐ and yeah โ this is different from MPlayer and mplayer2, they did their own thing.
also, heads up: if any option is changed at runtime (like, through input commands), those changes are NOT reset when a new file gets played. the option just stays changed, no take-backs. ๐
sometimes tho you want options to be per-file, and for that you drop in the special per-file markers --{ and --}. note that you must escape these on some shells โ your shell will absolutely eat them otherwise. example time:
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 โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโ
see how the stuff between the markers only clings to the files inside them? iconic behaviour tbh ๐ฆ
and one more thing: any file-local option that gets changed at runtime is reset the moment the current file stops playing. so if --c gets changed while file2.mkv is playing, it snaps right back when you move on to file3.mkv. this only applies to file-local options โ --a is never reset here, not ever, not once. ๐
โจ List Options โจ
some options store lists of values, and those ones can take action suffixes. for example, --display-tags takes a ,-separated list of tags, but the option also lets you append a single tag with --display-tags-append โ and the tag name can, say, contain a literal , with zero escaping needed. slay. ๐
๐ String list and path list options ๐
string lists are separated by ,. the strings themselves are not parsed or interpreted by the option system โ it just hands them over. BUT: most path or file list options use : (on Unix) or ; (on Windows) as the separator instead of ,. iykyk. ๐ธ
they support these operations:
-setโ Set a list of items (using the list separator, escaped with backslash)-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)-delโ Delete 1 or more items if present (same syntax as-set)-removeโ Delete item if present (does not interpret escapes)-toggleโ Append an item, or remove it if it already exists (no escapes)
-append is the low-effort queen here โ it's 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 tho, sorry bestie. ๐ญ)
๐ Key/value list options ๐
a key/value list is exactly what it sounds like: a list of key/value string pairs. in programming-land this data structure is often called a map or a dictionary. the order normally doesn't matter โ although in some cases it might. ๐
they support these operations:
-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)-clrโ Clear the option (remove all items)-delโ Delete 1 or more keys if present (same syntax as-set)-removeโ Delete item by key if present (does not interpret escapes)
keys are unique within the list. if you set a key that's already there, the existing one gets removed before the new value is appended โ no duplicates allowed, periodt. ๐ซถ
if you want to pass a value without interpreting it for escapes or ,, the recommendation is to use the -append variant. and when you're using libmpv, prefer MPV_FORMAT_NODE_MAP; when you're using a scripting backend or the JSON IPC, use an appropriate structured data type. (yes this is the "let the data structure do the work" pipeline โจ)
prior to mpv 0.33,:was also recognized as a separator by-set.
๐ฆ Object settings list options ๐ฆ
okay this one is a very complex option type, used by some options like --af and --vf. they often require complicated escaping ๐ฉ โ see VIDEO FILTERS for the details, because it's a whole thing.
...and the way they work is by tacking a lil suffix onto the option name, and each suffix does a different thing ๐ here's the whole squad:
-setโ sets a list of items (using,as the separator)-appendโ appends a single item-addโ appends 1 or more items (same syntax as-set)-preโ prepends 1 or more items (same syntax as-set)-clrโ clears the option (removes all items, gone, bye ๐)-removeโ deletes 1 or items if they're present (same syntax as-set)-toggleโ appends an item, or removes it if it already exists-helpโ a pseudo operation that prints a help text to the terminal
๐ฆ General ๐ฆ
If you don't put any suffix on, the operation you get is normally -set.
Some operations like -add and -pre let you specify multiple items, but bestie be aware that you may need to escape the arguments ๐ญ. -append only accepts a single, unescaped item (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 literally just aliases for the proper option with the -append action. For example, --sub-file is an alias for --sub-files-append. so iconic.
Options of this type can be changed at runtime using the change-list command, which takes the suffix (without the -) as a separate operation parameter.
An object settings list can hold up to 100 elements. that's the limit, no cap ๐
๐ CONFIGURATION FILES ๐
๐ Location and Syntax
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), and 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 both. 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, and if the value is omitted, yes is implied. Even suboptions can be specified in this way. we love a flexible queen โจ
Example configuration file
# Don't allow new windows to be larger than the screen.
autofit-larger=100%x100%
# Enable hardware decoding if available, =yes is implied.
hwdec
# Spaces don't have to be escaped.
osd-playing-msg=File: ${filename}
๐ช Escaping special characters
This is done like with command line options. 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 a 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 ๐). The shell is not involved here, so option values only need to be quoted to escape # anywhere in the value, ", ' or % at the beginning of the value, and leading and trailing whitespace. that's the whole checklist bestie, nothing more ๐
๐ Putting Command Line Options into the Configuration File
Almost all command line options can be put into the configuration file. Here is a small guide:
--flagโflag-opt valโopt=val--opt=valโopt=val-opt "has spaces"โopt=has spaces
๐๏ธ File-specific Configuration Files
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. it's giving "layers of lore" fr fr ๐ง
๐ Profiles
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=512MiB
demuxer-readahead-secs=20
[network]
profile-desc="profile for content over network"
force-window=immediate
# you can also include other profiles
profile=big-cache
[reduce-judder]
video-sync=display-resample
interpolation=yes
# using a profile again extends it
[network]
demuxer-max-back-bytes=512MiB
# reference a builtin profile
profile=fast
โช Runtime profiles
Profiles can be set at runtime with the apply-profile command. Since this operation is "destructive" (every item in a profile is simply set as an option, overwriting the previous value), you can't just enable and disable profiles again. it's not undo-able, bestie, that's just the deal ๐
As a partial remedy, there is a way to make profiles save old option values before overwriting them with the profile values, and then restoring the old values at a later point using apply-profile <profile-name> restore.
This can be enabled with the profile-restore option, which takes one of the following options:
defaultโ does nothing, and nothing can be restored (this is the default).copyโ when applying a profile, copy the old values of all profile options to a backup before setting them from the profile. These options are reset to their old values using the backup when restoring.- Every profile has its own list of backed up values. If the backup already exists (e.g. if
apply-profile namewas called more than once in a row), the existing backup is no changed. The restore operation will remove the backup. - It's important to know that restoring does not "undo" setting an option, but simply copies the old option value. Consider for example
vf-add, which appends an entry tovf. This mechanism will simply copy the entirevflist, and does not execute the inverse ofvf-add(that would bevf-remove) on restoring. - Note that if a profile contains recursive profiles (via the
profileoption), the options in these recursive profiles are treated as if they were part of this profile. The referenced profile's backup list is not used when creating or using the backup. Restoring a profile does not restore referenced profiles, only the options of referenced profiles (as if they were part of the main profile).
- Every profile has its own list of backed up values. If the backup already exists (e.g. if
copy-equalโ similar tocopy, but restore an option only if it has the same value as the value effectively set by the profile. This tries to deal with the situation when the user does not want the option to be reset after interactively changing it.
Example
[something]
profile-restore=copy-equal
vf-add=rotate=PI/2 # rotate by 90 degrees
so like, if you then run these commands, here's what you get (the comments are the receipts):
set vf vflip
apply-profile something
vf add hflip
apply-profile something
# vf == vflip,rotate=PI/2,hflip,rotate=PI/2
apply-profile something restore
# vf == vflip
like, restore literally rewinds it back to vflip because copy-equal remembered the og state. bestie behavior fr ๐
Conditional auto profiles โจ
okay so this is the โจfancyโจ one. profiles that have the profile-cond option set get applied automatically the second the matching condition hits โ unless auto profiles are turned off, obviously. the option takes a string, and that string is read as a Lua expression. if the expression comes back truthy โ profile goes on. if it errors or comes back falsy โ profile stays off. simple.
๐จ real talk: this Lua code execution is not sandboxed. not even a little. it's giving "raw dogging the interpreter".
any variables in condition expressions can reference properties. if an identifier isn't already defined by Lua or mpv, it gets interpreted as a property. so like, pause would give you the current pause status. you can't reference properties with - this way, because that would mean subtraction (math girlies stay losing), but if the variable name has any _ characters in it, those get turned into -. so playback_time returns the property playback-time. cute right?
a more robust way to get at properties is p.property_name or get("property-name", default_value). the automatic variable-to-property magic will break if a new identifier with the same name shows up โ for example, if a function named pause() got added, then pause would hand you a function value instead of the value of the pause property. ๐
also note: if a property isn't available, it returns nil, which can absolutely cause errors if you use it in expressions. those get logged in verbose mode, and the expression is treated as false. ๐
whenever a property that's referenced by a profile condition changes, the condition gets re-evaluated. if the return value flips from falsy-or-error to truthy, the profile is applied.
this mechanism tries to "unapply" profiles once the condition flips from truthy to falsy or error. if you wanna use that, you gotta set profile-restore for the profile. another option is to make a whole other profile with an inverse condition to undo the first one. periodt.
recursive profiles? yeah you can. but it's discouraged to reference other conditional profiles inside a conditional profile, because that leads to tricky and unintuitive behavior. don't do it bestie, it's not worth the drama.
Example ๐ฌ
make only HD video look funny:
[something]
profile-desc=HD video sucks
profile-cond=width >= 1280
hue=-50
make only videos containing "youtube" or "youtu.be" in their path brighter:
[youtube]
profile-cond=path:find('youtu%.?be')
gamma=20
if you want the profile reverted when the condition goes false again, you can set profile-restore:
[something]
profile-desc=Mess up video when entering fullscreen
profile-cond=fullscreen
profile-restore=copy
vf-add=rotate=PI/2 # rotate by 90 degrees
this appends the rotate filter to the video filter chain when you enter fullscreen. when you leave fullscreen, the vf option gets set back to whatever value it had before you went fullscreen. heads up though โ that would also nuke any other filters the user added during fullscreen mode. avoiding that is trickier, and could for example be solved by adding a second profile with an inverse condition and operation:
[something]
profile-cond=fullscreen
vf-add=@rot:rotate=PI/2
[something-inv]
profile-cond=not fullscreen
vf-remove=@rot
โ ๏ธ Warning: every single time an involved property changes, the condition gets evaluated again. if your condition uses p.playback_time for example, the condition is re-evaluated like, approximately on every video frame. this is probably slow. ๐
this feature is managed by an internal Lua script. conditions are executed as Lua code inside that script. its environment contains at least the following things:
(function environment table)โ every Lua function has an environment table. it's used for identifier access. there's no named Lua symbol for it, it's just implicit. the environment does "magic" accesses to mpv properties: if an identifier isn't already defined in_G, it retrieves the mpv property of the same name. any occurrences of_in the name get replaced with-before reading the property. the returned value is exactly whatmp.get_property_native(name)would give you. internally, a cache of property values (updated by observing the property) is used instead, so properties that aren't observable will be stuck at the initial value forever. if you wanna access properties that actually contain_in the name, useget()โ that one does not perform transliteration. internally, the environment table has a__indexmeta method set, which does the access logic.pโ a "magic" table similar to the environment table. but unlike the environment table, this one does not prefer accessing variables defined in_Gโ it always accesses properties.get(name [, def])โ read a property and return its value. if the property value isnil(e.g. if the property doesn't exist),defis returned. this is superficially similar tomp.get_property_native(name). the important difference is that this one accesses the property cache, and enables the change detection logic (which is essential to the dynamic runtime behavior of auto profiles). also, it doesn't return an error value as a second return value. the "magic" tables mentioned above use this function as their backend. it does not perform the_transliteration.
in addition, the same environment as in a blank mpv Lua script is present. for example, math is defined and gives access to the Lua standard math library. ๐งฎ
โ ๏ธ Warning: this feature is subject to change indefinitely. you might be forced to adjust your profiles on mpv updates. no cap.
Legacy auto profiles ๐ง
some profiles get loaded automatically using a legacy mechanism. this example demonstrates it:
Auto profile loading:
[extension.mkv]
profile-desc="profile for .mkv files"
vf=vflip
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, bestie, read it again ๐.
this feature is very limited, and is considered soft-deprecated. use conditional auto profiles instead. that's the glow-up. โจ
Using mpv from other programs or scripts ๐
there are three choices for using mpv from other programs or scripts:
- Calling it as a UNIX process. if you do this, do not parse terminal output. the terminal output is intended for humans, and may change any time. plus, terminal behavior itself may change any time. compatibility cannot be guaranteed. your code should work even if you pass
--terminal=no. do not attempt to simulate user input by sending terminal control codes to mpv's stdin. if you need interactive control, using--input-ipc-serveror--input-ipc-clientis 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-configor--config-dirmay be a good idea, to avoid conflicts with the normal mpv user configuration intended for CLI playback. using--input-ipc-serveror--input-ipc-clientis 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 a 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, sorry bestie ๐ญ. see EMBEDDING INTO OTHER PROGRAMS (LIBMPV).
- 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 of 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. ๐
TAKING SCREENSHOTS ๐ธ
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. yeah, case-sensitive, we love her for it ๐
unlike with MPlayer, the screenshot video filter is not required. this filter was never required in mpv, and has been removed. rip to a real one ๐ชฆ
๐ TERMINAL STATUS LINE ๐
Okay bestie, so while stuff is playing, mpv is gonna be yapping at you in the terminal with the playback status. It looks like, well, this:
AV: 00:03:12 / 00:24:25 (13%) A-V: -0.000
You can take over that whole line with the --term-status-msg option if you want to do your own thing. โจ
So here's literally everything that could pop up in that status line, and ngl the input properties that let you grab the same info yourself are listed too, iykyk.
AV:orV:(video only) orA:(audio only)- The current time position, in
HH:MM:SSformat (that's theplayback-timeproperty) - The total file duration โ it just isn't there if it's unknown (that's the
durationproperty) - Playback speed, like
x2.0. You only see this when the speed isn't normal. Heads up though: this is the speed you asked for, not the actual speed โ usually those two are the same, unless playback is being too slow ๐ (that's thespeedproperty.) - Playback percentage, like
(13%). That's how much of the file has been played. Normally it's calculated from playback position and duration, but it can fall back to other methods (like byte position) if those aren't available. (that's thepercent-posproperty.) - The audio/video sync, shown as
A-V: 0.000. This is the difference between audio and video time. Normally it should be 0 or close to 0. If it keeps growing, that might mean there's a playback problem ๐ (that's theavsyncproperty.) - Total A/V sync change, like
ct: -0.417. Normally invisible. It can show up if there's audio that's "missing", or if not enough frames can be dropped. Usually this means something's wrong. (that's thetotal-avsync-changeproperty.) - Encoding state in
{...}, only shown in encoding mode. - Display sync state. If display sync is active (the
display-sync-activeproperty), this showsDS: 2.500/13, where the first number is the average number of vsyncs per video frame (like 2.5 when you're playing 24Hz videos on 60Hz screens), which might jitter if the ratio doesn't round off, or if there are mistimed frames (that'svsync-ratio), and the second number is the estimated number of vsyncs that took too long (that's thevo-delayed-frame-countproperty). The second one is a heuristic, because generally it's just not possible to determine this with certainty. ๐คท - Dropped frames, like
Dropped: 4. Only shows up if the count isn't 0. It can grow if the video framerate is higher than the display's, or if video rendering is too slow. It might also get bumped up on "hiccups" and when the video frame couldn't be displayed on time. (that's theframe-drop-countproperty.) If the decoder drops frames, the number of decoder-dropped frames gets appended to the display too, like:Dropped: 4/34. This only happens if decoder frame dropping is enabled with the--framedropoptions. (that's thedecoder-frame-drop-countproperty.) - Cache state, like
Cache: 2s/134KB. Visible if the stream cache is enabled. The first value shows the amount of video buffered in the demuxer, in seconds, and the second value shows the estimated size of the buffered amount in kilobytes. (that's thedemuxer-cache-durationanddemuxer-cache-stateproperties.)
๐ LOW LATENCY PLAYBACK ๐
So mpv is optimized for normal video playback, meaning it genuinely tries to buffer as much data as it seems to make sense to buffer. Which, yeah, increases latency. Reducing latency is only possible by specifically disabling the features that increase latency. No shortcuts, bestie. ๐
The builtin low-latency profile tries to apply some of the options that can reduce latency. You can use --profile=low-latency to apply all of them. And you can list what's inside with --show-profile=low-latency (ngl some of these options are quite obscure, and they may change every single mpv release).
Be aware that some of these options can reduce playback quality. ๐ซฃ
Most latency is actually caused by inconvenient timing behavior. You can disable that 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 super common problem is with MJPEG streams. These do not signal the correct framerate. Using --untimed or --correct-pts=no --container-fps-override=60 might help.
For livestreams, data can build up because of pausing the stream, because of a slightly lower playback rate, or because of "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:
--opengl-glfinish=yes, can reduce buffering in the graphics driver--opengl-swapinterval=0, same--vo=xv, same- without audio,
--framedrop=no --speed=1.01may help for live sources (results can be mixed)
๐ RESUMING PLAYBACK ๐
Okay so this is the iconic feature. mpv is capable of storing the playback position of the currently playing file and resuming from there the next time that file is played. This is done with the commands quit-watch-later (bound to Shift+Q by default) and write-watch-later-config, and with the --save-position-on-quit option. Obsessed. โจ
The difference between always quitting with a key bound to quit-watch-later and using --save-position-on-quit is that the latter will save the playback position even when mpv is closed with a method other than a keybinding, such as clicking the close button in the window title bar. However, if mpv is terminated abruptly and doesn't have the time to save, then the position will not be saved. For example, if you shutdown your system without closing mpv beforehand. ๐ญ
mpv also stores options other than the playback position when they've been modified after playback began โ for example the volume and the selected audio/subtitles โ and restores their values the next time the file is played. Which options get saved can be configured with the --watch-later-options option.
When playing multiple playlist entries, mpv checks if one of them has a resume config file associated, and if it finds one it restarts playback from it. For example, if you use quit-watch-later on the 5th episode of a show, and later play all the episodes, mpv will automatically resume playback from episode 5. Main character behavior, honestly. ๐
More options to configure this functionality are listed in Watch Later.
๐ PROTOCOLS ๐
bestie, this is the whole menu of ways you can hand mpv a thing to play ๐
โจ mpv://...
mpv protocol, hiii ๐ This one is for starting mpv from a URL handler. The protocol gets stripped off and the rest is passed to the player as a normal open argument. Only safe network protocols are allowed to be opened this way, okay? Safety first, always ๐
โจ http://..., https://, ...
So 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, no cap.
Heads up: 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, but it 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. iconic ๐ฅ
Keep in mind that you can't pass youtube-dl command line options by this, and you have to use --ytdl-raw-options instead. that's the rule, sorry bestie ๐ญ
โจ -
Play data from stdin. tiny, simple, perfect ๐
โจ smb://PATH
Play a path from Samba share. (Requires FFmpeg support.)
โจ 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, sorry. 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. twins fr ๐ฏ
โจ dvb://[cardnumber@]channel --dvbin-...
Digital TV via DVB. (Linux only.) penguin gang ๐ง
โจ mf://[@listfile|filemask|glob|printf-format] --mf-...
Play a series of images as video ๐ธ
If the URL path begins with @, it is interpreted as the path to a file containing a list of image paths separated by newlines. If the URL path contains ,, it is interpreted as a list of image paths separated by ,. If the URL path does not contain % and if on POSIX platforms, is interpreted as a glob, and * is automatically appended if it was not specified. Otherwise, the printf sequences %[.][NUM]d, where NUM is one, two, or three decimal digits, and %% and are interpreted. For example, mf://image-%d.jpg plays files like image-1.jpg, image-2.jpg and image-10.jpg, provided that there are no big gaps between the files.
โจ cdda://[device] --cdda-device=PATH
Play CD ๐ง You can select a specific range of tracks to play by using the --start and --end options and specifying chapters. Navigating forwards and backwards through tracks can also be done by navigating through chapters (PGUP and PGDOWN in the default keybinds).
Example
mpv cdda:// --start=#4 --end=#6
This will start from track 4, play track 5, and then end. chef's kiss ๐
โจ lavf://...
Access any FFmpeg libavformat protocol. Basically, this passed the string after the // directly to libavformat. straight to the source, periodt โจ
โจ 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 --untimed
This 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. yes, three slashes, don't @ me ๐ซถ
โจ 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, usetailto 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. sneaky but valid ๐
โจ 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. one and done, no reuse ๐
โจ edl://[edl specification as in edl-mpv.rst]
Stitch together parts of multiple files and play them. frankenstein energy, but make it cinema ๐ฌ
โจ slice://start[-end]@URL
Read a slice of a stream.
start and end represent a byte range and accept suffixes such as KiB and MiB. end is optional.
if end starts with +, it is considered as offset from start.
Only works with seekable streams.
Examples:
mpv slice://1g-2g@cap.ts
This starts reading from cap.ts after seeking 1 GiB, then reads until reaching 2 GiB or end of file.
mpv slice://1g-+2g@cap.ts
This starts reading from cap.ts after seeking 1 GiB, then reads until reaching 3 GiB or end of file.
mpv slice://100m@appending://cap.ts
This starts reading from cap.ts after seeking 100MiB, then reads until end of file.
โจ 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). it's giving void, it's giving nothing, obsessed ๐
โจ memory://data
Use the data part as source data.
โจ hex://data
Like memory://, but the string is interpreted as hexdump. nerdy and I love her for it ๐ง
๐ PSEUDO GUI MODE ๐
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. it's cosplaying as a GUI, and honestly? slay ๐ฆ
Currently this happens only in the following cases:
- if started using the
mpv.desktopfile on Linux (e.g. started from menus or file associations provided by desktop environments) - if started from
explorer.exeon Windows (technically, if it was started on Windows, and all of the stdout/stderr/stdin handles are unset) - started out of the bundle on macOS
- if you manually use
--player-operation-mode=pseudo-guion the command line
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, which is the main difference to using --profile=builtin-pseudo-gui. subtle but important, bestie โญ
The profile is currently defined as follows:
[builtin-pseudo-gui]
terminal=no
force-window=yes
idle=once
screenshot-directory=~~desktop/
The pseudo-gui profile exists for compatibility. 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:
[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. deprecated means it's on thin ice, bestie. ๐ญ
๐ OPTIONS ๐
๐ Track Selection ๐
--alang=<languagecode[,languagecode,...]>โ Specify a prioritized list of audio languages to use, as IETF language tags. Equivalent ISO 639-1 two-letter and ISO 639-2 three-letter codes are treated the same. The first tag in the list that matches track's language in the file will be used. A track that matches more subtags will be preferred over one that matches fewer. See also--aid.
This is a string list option. See List Options for details.
Examples
mpv dvd://1 --alang=hu,enchooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available.mpv --alang=jpn example.mkvplays a Matroska file with Japanese audio.
--slang=<languagecode[,languagecode,...]>โ Analogous to--alang, for subtitle tracks. same energy, different track type ๐
This is a string list option. See List Options for details.
Examples
mpv dvd://1 --slang=hu,enchooses the Hungarian subtitle track on a DVD and falls back on English if Hungarian is not available.mpv --slang=jpn example.mkvplays a Matroska file with Japanese subtitles.mpv --slang=pt-BR example.mkvplays a Matroska file with Brazilian Portuguese subtitles if available, and otherwise any Portuguese subtitles.
--vlang=<...>โ Analogous to--alangand--slang, for video tracks. the trio is complete ๐ซถ
This is a string list option. See List Options for details.
--aid=<ID|auto|no>โ Select audio track.autoselects the default,nodisables 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 disables audio playback. silence era, if that's what you want ๐
Note: The track selection options (--aidbut also--sidand the others) sometimes expose behavior that may appear strange. Also, the behavior tends to change around with each mpv release. ngl it's a little chaotic in here, but that's the truth ๐
okay bestie, we are STILL deep in track selection territory and it gets โจspicyโจ from here, so buckle up ๐
The track selection properties will return the option value outside of playback (as expected), but during playback, the affective track selection is returned. For example, with --aid=auto, the aid property will suddenly return 2 after playback initialization (assuming the file has at least 2 audio tracks, and the second is the default). ๐ญ
At mpv 0.32.0 (and some releases before), if you passed a track value for which a corresponding track didn't exist (e.g. --aid=2 and there was only 1 audio track), the aid property returned no. However if another audio track was added during playback, and you tried to set the aid property to 2, nothing happened, because the aid option still had the value 2, and writing the same value has no effect. ๐
With mpv 0.33.0, the behavior was changed. Now track selection options are reset to auto at playback initialization, if the option had tries to select a track that does not exist. The same is done if the track exists, but fails to initialize. The consequence is that unlike before mpv 0.33.0, the user's track selection parameters are clobbered in certain situations. ๐
Also since mpv 0.33.0, trying to select a track by number will strictly select this track. Before this change, trying to select a track which did not exist would fall back to track default selection at playback initialization. The new behavior is more consistent. slay, honestly ๐
Setting a track selection property at runtime, and then playing a new file might reset the track selection to defaults, if the fingerprint of the track list of the new file is different.
Be aware of tricky combinations of all of all of the above: for example, mpv --aid=2 file_with_2_audio_tracks.mkv file_with_1_audio_track.mkv would first play the correct track, and the second file without audio. If you then go back the first file, its first audio track will be played, and the second file is played with audio. If you do the same thing again but instead of using --aid=2 you run set aid 2 while the file is playing, then changing to the second file will play its audio track. This is because runtime selection enables the fingerprint heuristic. ๐ง
Most likely this is not the end. ๐
--sid=<ID|auto|no>โ Display the subtitle stream specified by<ID>.autoselects the default,nodisables subtitles. ๐ธ
--sub is an alias for --sid.
--sid=no or --sub=no disables subtitle decoding.
--vid=<ID|auto|no>โ Select video channel.autoselects the default,nodisables video. ๐
--video is an alias for --vid.
--vid=no or --video=no disables video playback.
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. ๐ฆ
--edition=<ID|auto>โ (Matroska files only) Specify the edition (set of chapters) to use, where0is the first. If set toauto(the default), mpv will choose the first edition declared as a default, or if there is no default, the first edition defined. ๐--track-auto-selection=<yes|no>โ 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 thepauseoption 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.
--subs-with-matching-audio=<yes|forced|no>โ When autoselecting a subtitle track, select it even if the selected audio stream matches you preferred subtitle language (default:yes). If this option is set tono, then no subtitle track that matches the audio language will ever be autoselected by mpv regardless of--slangorsubs-fallback. If set toforced, then only forced subtitles will be selected. ๐--subs-match-os-language=<yes|no>โ When autoselecting a subtitle track, select the track that matches the language of your OS if the audio stream is in a different language if suitable (default track or a forced track under the right conditions). Note that if--slangis set, this will be completely ignored (default:yes). ๐--subs-fallback=<yes|default|no>โ When autoselecting a subtitle track, if no tracks match your preferred languages, select a full track even if it doesn't match your preferred subtitle language (default:default). Setting this todefaultmeans that only streams flagged as default will be selected. โญ--subs-fallback-forced=<yes|no|always>โ When autoselecting a subtitle track, the default value ofyeswill prefer using a forced subtitle track if the subtitle language matches the audio language and matches your list of preferred languages. The special valuealwayswill only select forced subtitle tracks and never fallback on a non-forced track. Conversely,nowill never select a forced subtitle track. ๐ โโ๏ธ
๐ฌ Playback Control ๐ฌ
--start=<relative time>โ 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 positionpp(0-100).#cseeks to chapter numberc. (Chapters start from1.)noneresets 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
--start=+56,--start=00:56โ Seeks to the start time + 56 seconds.--start=-56,--start=-00:56โ Seeks to the end time - 56 seconds.--start=01:10:00โ Seeks to 1 hour 10 min.--start=50%โ Seeks to the middle of the file.--start=30 --end=40โ Seeks to 30 seconds, plays 10 seconds, and exits.--start=-3:20 --length=10โ Seeks to 3 minutes and 20 seconds before the end of the file, plays 10 seconds, and exits.--start='#2' --end='#4'โ Plays chapters 2 and 3, and exits. ๐
--end=<relative time>โ Stop at given time. Use--lengthif the time should be relative to--start. See--startfor valid option values and examples. ๐--length=<relative time>โ Stop after a given time relative to the start time. See--startfor 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. ๐
--rebase-start-time=<yes|no>โ Whether to move the file start time to00:00:00(default:yes). This is less awkward for files which start at a random timestamp, such as transport streams. On the other hand, if there are timestamp resets, the resulting behavior can be rather weird. For this reason, and in case you are actually interested in the real timestamps, this behavior can be disabled withno. ๐ฐ๏ธ--speed=<0.01-100>โ 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 scaletempo2 audio filter.
--pitch=<0.01-100>โ Raise or lower the audio's pitch by the factor given as parameter. Does not affect playback speed. Playing with an altered pitch automatically inserts thescaletempo2audio filter. ๐ต
Since pitch change is achieved by combining pitch-preserving speed change and resampling, the range of pitch change is effectively limited by the min-speed and max-speed parameters of scaletempo2: for example, a min-speed of 0.25 limits the highest pitch factor to 4 (1/0.25). ๐ค
In a standard 12-tone scale system, octaves are separated by a factor of 2 whereas semitones are represented by a factor of 2^(1/12). This means pitches can easily be shifted up or down with a simple multiplier. ๐น
Examples
--pitch=2โ Shifts the pitch up a full octave.--pitch=0.5โ Shifts the pitch down an octave.--pitch=1.498307 (2^(7/12))โ Shifts the pitch up a perfect fifth.--pitch=0.667420 (2^(-7/12))โ Shifts the pitch down a perfect fifth.--pitch=1.059463 (2^(1/12))โ Shifts the pitch up a semitone.--pitch=0.943874 (2^(-1/12))โ Shifts the pitch down a semitone. ๐ถ
--pauseโ Start the player in paused state. โธ๏ธ--shuffleโ Play files in random order. ๐--playlist-start=<auto|index>โ tells mpv which file on the internal playlist to actually start playing. The index is a plain integer, and0means the very first file. The valueautomeans "bestie, let the resume mechanism decide which entry to play" (this is the default). ๐ If you hand it an index that doesn't exist, the behavior is unspecified and might change in future mpv versions โ same deal if the playlist contains further playlists, so fr don't expect any reasonable behavior there. Passing a playlist file to mpv should work with this option though! E.g.mpv playlist.m3u --playlist-start=123will work as expected, as long asplaylist.m3udoes not link to further playlists.
The value no is a deprecated alias for auto.
--playlist=<filename>โ play files according to a playlist file. Supports some common formats. If no format is detected, it gets treated as a list of files separated by newline characters. You may need this option to load plaintext files as a playlist. Note that XML playlist formats are not supported, sorry babe ๐
This option forces --demuxer=playlist to interpret the playlist file. Some playlist formats, notably CUE and optical disc formats, need to use different demuxers and will not work with this option. They still can be played directly, without using this option though โ no cap.
You can play playlists directly, without this option. Before mpv version 0.31.0, this option disabled any security mechanisms that might be in place, but since 0.31.0 it uses the same security mechanisms as playing a playlist file directly. If you trust the playlist file, you can disable any security checks with --load-unsafe-playlists. Because playlists can load other playlist entries, consider applying this option only to the playlist itself and not its entries, using something along these lines:
mpv --{ --playlist=filename --load-unsafe-playlists --}
Warning: The way older versions of mpv played playlist files via--playlistwas not safe against maliciously constructed files. Such files may trigger harmful actions. This has been the case for all versions of mpv prior to 0.31.0, and all MPlayer versions, but unfortunately this fact was not well documented earlier, and some people have even misguidedly recommended the use of--playlistwith untrusted sources. Do NOT use--playlistwith random internet sources or files you do not trust if you are not sure your mpv is at least 0.31.0. ๐ญ In particular, playlists can contain entries using protocols other than local files, such as special protocols likeavdevice://(which are inherently unsafe). ๐
--chapter-merge-threshold=<number>โ the threshold for merging almost-consecutive ordered chapter parts, in milliseconds (default:100). Some Matroska files with ordered chapters have inaccurate chapter end timestamps, causing a tiny gap between the end of one chapter and the start of the next one when they should match. If the end of one playback part is less than the given threshold away from the start of the next one, then mpv keeps playing video normally over the chapter change instead of doing a seek. โจ--chapter-seek-threshold=<seconds>โ the distance in seconds from the beginning of a chapter within which a backward chapter seek will go to the previous chapter (default:5.0). Past this threshold, a backward chapter seek goes to the beginning of the current chapter instead. A negative value means always go back to the previous chapter. ๐ฆ--hr-seek=<no|absolute|yes|default>โ selects 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โ likeabsolute, but enable hr-seeks in audio-only cases. The exact behavior is implementation specific and may change with new releases (default).yesโ use precise seeks whenever possible.alwaysโ same asyes(for compatibility).
--hr-seek-demuxer-offset=<seconds>โ this option exists to work around failures to do precise seeks (as in--hr-seek) caused by bugs or limitations in the demuxers for some file formats. Some demuxers fail to seek to a keyframe before the given target position, going to a later position instead. The value of this option is subtracted from the time stamp given to the demuxer. So if you set this option to1.5and try to do a precise seek to60seconds, the demuxer is told to seek to time58.5, which hopefully reduces the chance that it erroneously goes to some time later than 60 seconds. The downside of setting this option is that precise seeks become slower, as video between the earlier demuxer position and the real target may be unnecessarily decoded. ๐ซถ--hr-seek-framedrop=<yes|no>โ 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
--index=<mode>โ 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 missingrecreateโ 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-unsafe-playlistsโ 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.)
--access-references=<yes|no>โ 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.
--loop-playlist=<N|inf|force|no>,--loop-playlistโ loops playback N times. A value of1plays it one time (default),2two times, etc.infmeans forever.nois the same as1and disables looping. If several files are specified on command line, the entire playlist is looped.--loop-playlistis 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-file=<N|inf|no>,--loop=<N|inf|no>โ loop a single file N times.infmeans forever,nomeans normal playback. For compatibility,--loop-fileand--loop-file=yesare 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 options is that this option performs a seek on loop, instead of reloading the file.
Note:--loop-filecounts the number of times it causes the player to seek to the beginning of the file, not the number of full playthroughs. This means--loop-file=1will end up playing the file twice. Contrast with--loop-playlist, which counts the number of full playthroughs. ๐ญ
--loop is an alias for this option.
--ab-loop-a=<time>,--ab-loop-b=<time>โ set loop points. If playback passes thebtimestamp, it will seek to theatimestamp. Seeking past thebpoint 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. ๐ฆ
--ab-loop-count=<N|inf>โ how many laps should an A-B loop do before mpv stops caring? Set N and the A-B loop points get ignored after N times around. Default:inf, which is giving forever energy, fr fr. ๐
But bestie, hear me out: set this to0and A-B looping is completely ignored. Not even theab-loopcommand can wake it back up. If both loop points are set whileab-loop-countis0, the command will show(disabled)right there in the OSD message. She said no and she meant it. ๐
--ordered-chapters=<yes|no>โ turns on support for Matroska ordered chapters. mpv will go load and search for video segments from other files, and will also respect whatever chapter order the main file specifies. Default:yes. Obsessed. โจ--ordered-chapters-files=<playlist-file>โ loads the given file as a playlist, then tries to use the files inside it as reference files whenever you open a Matroska file that uses ordered chapters. This overrides the normal mechanism, which is just scanning the same directory the main file lives in. ๐ฆ
Super useful when your ordered chapter files aren't sitting on the local filesystem, or when the referenced files live in totally different directories. Main character problem-solving. ๐
Note: a playlist can be as simple as a text file with filenames separated by newlines. That's it. That's the playlist. ๐
--chapters-file=<filename>โ loads chapters from this file instead of using the chapter metadata hiding inside the main file. ๐ธ
It accepts a media file (like mkv) or even a pseudo-format like ffmetadata, and uses its chapters to replace the current file's chapters. Lowkey important: this does not work with OGM or XML chapters directly. ๐
--sstep=<sec>โ skip sec seconds after every single frame. Yes, every frame. ๐ฉท
Note: without --hr-seek, the skipping will snap to keyframes.
--stop-playback-on-init-failure=<yes|no>โ should playback just stop if either audio or video fails to initialize? Default:no. ๐ซถ
With no, playback keeps going in video-only or audio-only mode when one of them gives up. And ngl, this doesn't affect playback of audio-only or video-only files at all โ those are already living their single-track truth. ๐
--play-direction=<forward|+|backward|->โ controls which way the playback goes. Default:forward. โญ
Set it to backward and mpv will attempt to play the file in reverse, with playback time decreasing. If you set this before playback starts, playback will start from the end of the file. If you change it mid-playback, an hr-seek gets issued to flip the direction. ๐ฅ
+ and - are aliases for forward and backward. Simple as that. โจ
Everything after this point is about backward mode specifically. Buckle up, bestie. ๐ญ
Note: backward playback is extremely fragile. It may not always work, it's much slower than forward playback, and it breaks certain other features. How well it works depends mainly on the file you're playing. Generally it'll show good results (or results at all) only if the stars align. Like, cosmically. ๐
mpv โ and honestly most media formats โ were designed for forward playback only. Backward playback is bolted on top of mpv, and it makes a medium effort to make backward playback work. Depending on your use-case, another tool may work way better for you. No shame in that. ๐
Backward playback is not exactly a 1st class feature. Implementation tradeoffs were made, and those tradeoffs are bad for backward playback, but in turn they don't cause disadvantages for normal playback. Various possible optimizations are simply not implemented, in order to keep the complexity down. Normally a media player is highly pipelined (future data is prepped in separate threads so it's ready in realtime when the next stage needs it), but backward playback will essentially stall the pipeline at various random points. Not cute. ๐
For example, intra-only codecs are trivially backward playable, and tools built around them may make efficient use of them (think video editors or camera viewers). mpv won't be efficient in this case, because it uses its generic backward playback algorithm, which on top of everything else 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 the default config sends many small relative seek commands). That's the hack. Use it. ๐
The implementation consists of mostly 3 parts:
- Backward demuxing. This relies on the demuxer cache, so the demuxer cache should (or must โ didn't test it) be enabled, and its size will affect performance. If the cache is too small or too large, quadratic runtime behavior may result. ๐ต
- Backward decoding. The decoder library used (
libavcodec) does not support this. It's emulated by feeding bits of data in forward, putting the result in a queue, returning the queue data to the VO in reverse, and then starting over at an earlier position. This can require buffering an extreme amount of decoded data, and also completely breaks pipelining. ๐ - Backward output. This is relatively simple, because the decoder returns the frames in the needed order. However, this may cause various problems because filters see audio and video going backward. ๐ฆ
Known problems:
- It's fragile. If anything doesn't work, random behavior may occur. In simple cases, the player will just play nonsense and artifacts. In other cases, it may get stuck or heat the CPU. (Exceeding memory usage significantly beyond the user-set limits would be a bug, though.) ๐ฅ
- Performance and resource usage isn't good. In part this is inherent to backward playback of normal media formats, and in part it's due to implementation choices and tradeoffs. ๐
- This is extremely reliant on good demuxer behavior. Although backward demuxing requires no special demuxer support, it is required that the demuxer performs seeks reliably, fulfills some specific requirements about packet metadata, and has deterministic behavior. ๐ธ
- Starting playback exactly from the end may or may not work, depending on seeking behavior and file duration detection. ๐
- Some container formats, audio, and video codecs are not supported due to their behavior. There is no list, and the player usually does not detect them. Certain live streams (including TV captures) may exhibit problems in particular, as well as some lossy audio codecs.
h264 intra-refreshis known not to work due to problems withlibavcodec.WAVand some other raw audio formats tend to have problems โ there are hacks for dealing with them, which may or may not work. ๐ญ - Backward demuxing of subtitles is not supported. Subtitle display still works for some external text subtitle formats. (These are fully read into memory, and only backward display is needed.) Text subtitles that are cached in the subtitle renderer also have a chance to be displayed correctly. ๐
- Some features dealing with playback of broken or hard to deal with files will not work fully (such as timestamp correction). ๐ซถ
- If demuxer low level seeks (i.e. seeking the actual demuxer instead of just within the demuxer cache) are performed by backward playback, the created seek ranges may not join, because not enough overlap is achieved. โญ
- Trying to use this with hardware video decoding will probably exhaust all your GPU memory and then crash a thing or two. Or it will fail because
--hwdec-extra-frameswill certainly be set too low. ๐ - Stream recording is broken.
--stream-recordmay keep working if you backward play within a cached region only. ๐ - Relative seeks may behave weird. Small seeks backward (towards smaller time, i.e.
seek -1) may not really seek properly, and audio will remain muted for a while. Using hr-seek is recommended, which should have none of these problems. โจ - Some things are just weird. For example, while seek commands manipulate playback time in the expected way (provided they work correctly), the framestep commands are transposed. Backstepping will perform very expensive work to step forward by 1 frame. ๐ต
Tuning:
- Remove all
--vf/--affilters you have set. Disable hardware decoding. Disable functions like SPDIF passthrough. ๐งน - Increasing
--video-reversal-buffermight help if reversal queue overflow is reported, which may happen in high bitrate video, or video with large GOP. Hardware decoding mostly ignores this, and you need to increase--hwdec-extra-framesinstead (until you get playback without logged errors). ๐ - The demuxer cache is essential for backward demuxing. Make sure to set
--cache=yes. The cache size might matter. If it's too small, a queue overflow will be logged, and backward playback cannot continue, or it performs too many low level seeks. If it's too large, implementation tradeoffs may cause general performance issues. Use--demuxer-max-bytesto potentially increase the amount of packets the demuxer layer can queue for reverse demuxing (basically it's the--video-reversal-bufferequivalent for the demuxer layer). ๐ฆ - Setting
--vd-queue-enable=yescan help a lot to make playback smooth (once it works). ๐ --demuxer-backward-playback-stepalso factors into how many seeks may be performed, and whether backward demuxing could break due to queue overflow. If it's set too high, the backstep operation needs to search through more packets all the time, even if the cache is large enough. ๐- Setting
--demuxer-cache-waitmay be useful to cache the entire file into the demuxer cache. Set--demuxer-max-bytesto a large size to make sure it can read the entire cache;--demuxer-max-back-bytesshould also be set to a large size to prevent that tries to trim the cache. ๐ - If audio artifacts are audible, even though the AO does not underrun, increasing
--audio-backward-overlapmight help in some cases. ๐ง
--video-reversal-buffer=<bytesize>,--audio-reversal-buffer=<bytesize>โ bestie, these two are for backward decoding. And what's backward decoding, you ask? It decodes forward in little steps, then flips the decoder output around. These options cap the approximate max amount of bytes that can get buffered. The whole point is to stop your player from eating infinite resources โ during normal backward playback it's not supposed to hit the limit, and if it does, it'll drop frames and complain about it. Rude, but fair.
So if you're getting reversal queue overflow errors during backward playback, this is your girl. Bump the size up until the warning disappears. Usually the video buffer overflows first, especially with high resolution video. ๐
Heads up: this does not work correctly if video hardware decoding is used. The video frame size won't include the referenced GPU and driver memory, and some hardware decoders may also be limited by --hwdec-extra-frames.
How big the queue needs to be depends entirely on how the media was encoded, no cap. Audio typically needs a very small buffer, while video can demand excessively large buffers. ๐ซ
(Technically, this allows the last frame to exceed the limit. Also, it doesn't account for other buffered frames, like inside the decoder or the video output.)
And this does not affect demuxer cache behavior at all. Not even a little.
Peep --list-options for defaults and value range. Oh and <bytesize> options accept suffixes such as KiB and MiB. โจ
--video-backward-overlap=<auto|number>,--audio-backward-overlap=<auto|number>โ how many overlapping keyframe ranges to use for backward decoding (default:auto). And yes, "keyframe" here means it in the mpv/ffmpeg specific sense, iykyk. Backward decoding works by forward decoding in small steps. But some codecs literally cannot restart decoding from any packet (even if it's marked as a seek point), which becomes noticeable with backward decoding โ in theory this is a problem with seeking too, but--hr-seek-demuxer-offsetcan fix it for seeking. MDCT based audio codecs in particular 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. Slay, very specific.
--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.
--video-backward-batch=<number>,--audio-backward-batch=<number>โ number of keyframe ranges to decode at once when backward decoding (default:1for video,10for audio). Ngl this is another pointless tuning parameter nobody should use. ๐ It should affect performance only, fr fr. In theory, setting a number higher than1for 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's giving chaotic energy.
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.
--demuxer-backward-playback-step=<seconds>โ 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-directionfor the deets.
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. Not the cute kind of quadratic. ๐
๐ Program Behavior ๐
--help,--hโ show a short summary of options. Short king energy.
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. Go off. ๐
-vโ increment verbosity level, one level for each-vfound on the command line. Stack 'em like bracelets. ๐--version,-Vโ print version string and exit. Bye bestie. ๐--no-configโ do not load default configuration or any user files. This prevents loading of both the user-level and system-widempv.confandinput.conffiles. Other user files are blocked as well, such as resume playback files and cache files. This option only takes effect when used as a command line flag, no cap.
Note: Files explicitly requested by command line options, like--includeor--use-filedir-conf, will still be loaded.
See also: --config-dir.
--list-optionsโ prints all available options. Every single one. Get your reading glasses. ๐--list-propertiesโ print a list of the available properties.--list-protocolsโ print a list of the supported protocols.--log-file=<path>โ opens the given path for writing, and prints log messages to it. Existing files will be truncated, so watch out. The log level is at least-v -v, but can be raised via--msg-levelโ and no, the option cannot lower it below the forced minimum log level. She's committed.
A special case is the macOS bundle: it will create a log file at ~/Library/Logs/mpv.log by default. ๐ฆ
--config-dir=<path>โ 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. That means the global mpv configuration directory as well as per-user directories are ignored, and overrides through environment variables (MPV_HOME) are also ignored. It's giving "my way or the highway". ๐
Note that the cache and state paths (~~/cache, ~~/state) are not considered "configuration" and keep their auto-detection logic. They do their own thing.
Note that the --no-config option takes precedence over this option.
--dump-stats=<filename>โ 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 scriptTOOLS/stats-conv.pycan be used (which currently displays it as a graph). ๐
This option is useful for debugging only. That's it, that's the whole vibe.
--idle=<no|yes|once>โ 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. One and done. โจ
--include=<configuration-file>โ specify configuration file to be parsed after the default ones.--load-scripts=<yes|no>โ if set tono, don't auto-load scripts from the scripts configuration subdirectory (usually~/.config/mpv/scripts/). (Default:yes)--script=<filename>,--scripts=file1.lua:file2.lua:...โ load a Lua script. The second option allows you to load multiple scripts by separating them with the path separator (:on Unix,;on Windows). Bestie, mind your separators.
--scripts is a path list option. See List Options for details.
--script-opt=<key=value>,--script-opts=key1=value1,key2=value2,...โ 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 โ mpv is just the messenger. Values not claimed by any scripts are ignored. ๐ซถ
Each use of the --script-opt option will add another option to the internal list, while --script-opts takes a list of options at once, and overwrites the internal list with it. The latter is a key/value list option. See List Options for details.
--merge-filesโ pretend that all files passed to mpv are concatenated into a single, big file. This uses timeline/EDL support internally. Manifesting one giant file. ๐ธ--profile=<profile1,profile2,...>โ use the given profile(s).--profile=helpdisplays a list of the defined profiles. ๐--reset-on-next-file=<all|option1,option2,...>โ 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. Not us.)
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.
The special name all resets as many options as possible.
This is a string list option. See List Options for details.
โจ Examples โจ
--reset-on-next-file=pauseโ reset pause mode when switching to the next file.--reset-on-next-file=fullscreen,speedโ reset fullscreen and playback speed settings if they were changed during playback.--reset-on-next-file=allโ try to reset all settings that were changed during playback. The full reset, the main character move. ๐
--show-profile=<profile>โ show the description and content of a profile. Lists all profiles if no parameter is provided.--use-filedir-confโ 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. ๐ญ Stay safe out there, bestie.
--ytdl=<yes|no>โ 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 (default:yes). ๐ฅ
If the script can't do anything with an URL, it will do nothing. Respect the boundaries.
This accepts a set of options, which can be passed to it with the --script-opts option (using ytdl_hook- as prefix):
try_ytdl_first=<yes|no>โ set this toyesand mpv will hand your URL to youtube-dl first, instead of the default vibe where it only does that after it fails to open the thing itself. Which one you want lowkey depends on whether most of your URLs even need youtube-dl parsing in the first place. ๐ซถexclude=<URL1|URL2|...โ a|-separated list of URL patterns that mpv should not run through youtube-dl. Matching happens after thehttp(s)://part of the URL. โจ
^ matches the start of the URL, $ matches the end, and bestie you must put % in front of any of these characters if you want to match them literally: ^$()%|,.[]*+-?
URLs get converted to lowercase before matching, fyi.
Examples ๐ธ
--script-opts=ytdl_hook-exclude='^youtube%.com'will exclude any URL that starts withhttp://youtube.comorhttps://youtube.com.--script-opts=ytdl_hook-exclude='%.mkv$|%.mp4$'will exclude any URL that ends with.mkvor.mp4.
Wanna read more lua patterns? They're here: https://www.lua.org/manual/5.1/manual.html#5.4.1
include=<URL1|URL2|...โ the flip side ๐ a|-separated list of URL patterns mpv should try to parse with youtube-dl first, but only whentry_ytdl_firstisno. Matching works exactly likeexclude.
Default:
^%w+%.youtube%.com/|^youtube%.com/|^youtu%.be/|^%w+%.twitch%.tv/|^twitch%.tv/
all_formats=<yes|no>โyesmeans mpv attempts to add all the formats youtube-dl reported (default:no). Each format becomes its own separate track. And the way they do it? They're delay-loaded, so they only actually get opened when you select a track โ which should keep load times as low as if you never turned this on. ๐
It also adds average bitrate metadata when available, which means you can use --hls-bitrate to pick your track. (HLS used to be the only format whose alternative quality streams got exposed like this, hence the option name. iykyk.)
Tracks representing formats that youtube-dl picked as default get the default flag set โ so mpv will generally still select whatever --ytdl-format chose. Cute.
Now, even though this mechanism technically lets you switch streams at runtime, it's genuinely not suitable for that purpose for a bunch of technical reasons. (It's slow. And that can't really be fixed. ๐ญ) In general this option is not useful and was only added to prove it could be done. Not me calling an option useless but here we are.
There are two cases you have to consider when doing quality/bandwidth selection:
- Completely separate audio and video streams (DASH-like). Each stream contains either only audio or only video, so you can mix and combine audio/video bandwidths with zero restriction. This intuitively matches the concept of selecting quality by track โ which is what
all_formatsis supposed to do. - Separate sets of muxed audio and video streams. Each version of the media contains both an audio and a video stream, and they're interleaved. To not waste bandwidth you should only select one of these versions โ because if, say, you select an audio stream, then the video will get downloaded too, even if you selected video from a different stream. ๐
mpv will still represent them as separate tracks, but it sets the title of each track to muxed-N, where N is replaced with the youtube-dl format ID of the originating stream.
Some sites mix 1. and 2., but we assume they do that for compatibility reasons, and there's no reason to use them at all. ๐
force_all_formats=<yes|no>โ if you set this toyes, andall_formatsis alsoyes, mpv tries to represent all youtube-dl-reported formats as tracks, even if it would normally just use the direct URL youtube-dl handed over (default:yes).
Seems like this normally makes a difference when youtube-dl is working on a master HLS playlist.
Set it to no and that specific kind of stream is treated like all_formats is no, and the stream selection youtube-dl did (via --ytdl-format) is used instead.
thumbnails=<all|best|none>โ adds thumbnails as video tracks (default:none).
Thumbnails get downloaded when they're added as tracks, so all can have a noticeable impact on how long it takes to open the video when there's a lot of them. โจ
use_manifests=<yes|no>โ makes mpv use the master manifest URL for formats like HLS and DASH when available, which allows for video/audio selection at runtime (default:no). It's disabled by default for performance reasons, bestie.ytdl_path=youtube-dlโ configure the paths to youtube-dl's executable or a compatible fork's. Separate paths with:on Unix and;on Windows. mpv looks in order for the configured paths inPATHand in mpv's config directory. The defaults are"yt-dlp","yt-dlp_x86"and"youtube-dl". On Windows the suffix extension isn't necessary, but only".exe"is acceptable.
Why do the option names mix _ and -? ๐
I have no idea.
--ytdl-format=<|ytdl|best|worst|mp4|webm|...>
The format selection string that gets passed directly to youtube-dl. The possible values depend on the website and the video โ for a given URL you can find the available formats with the command youtube-dl -F URL. Check youtube-dl's own docs for available aliases. (Default: empty)
An empty value, or ytdl, means mpv doesn't pass a --format option to youtube-dl at all, so its default format selection behavior kicks in. ๐ฆ
--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]
Pass arbitrary options straight to youtube-dl. Parameters and arguments go in as key-value pairs. Options without an argument still have to include the =.
There is no sanity checking, so yes it's possible to break things (i.e. passing invalid parameters to youtube-dl). You've been warned. โ ๏ธ
You can pass a proxy URL for youtube-dl to use while parsing the website โ super useful for geo-restricted URLs. After youtube-dl parsing, some URLs also need a proxy for playback, so this can hand that proxy info to mpv too. Take note: SOCKS proxies aren't supported and https URLs also bypass the proxy. That's a limitation in FFmpeg, not us. ๐
This is a key/value list option. See List Options for details.
Example โจ
--ytdl-raw-options=username=user,password=pass--ytdl-raw-options=force-ipv6=--ytdl-raw-options=proxy=[http://127.0.0.1:3128]--ytdl-raw-options-append=proxy=http://127.0.0.1:3128
--js-memory-report=<yes|no>
Turn on memory reporting for javascript scripts in the stats overlay. It's disabled by default because it has an overhead and increases memory usage. Heads up: this option will only work if it's enabled before mpv is started. ๐
--load-stats-overlay=<yes|no>
Enable the builtin script that shows useful playback information on a key binding (default: yes). By default the i key is used โ and I makes the overlay permanent. Obsessed with a good overlay tbh. ๐
--load-console=<yes|no>
Enable the built-in script that handles textual input (default: yes).
--load-commands=<yes|no>
Enable the built-in script for entering commands in the console (default: yes). The ` key activates it by default.
--load-auto-profiles=<yes|no|auto>
Enable the builtin script that does auto profiles (default: auto). See Conditional auto profiles for details. auto will load the script, but immediately unload it if there are no conditional profiles. Lowkey efficient.
--load-select=<yes|no>
Enable the builtin script that lets you select from lists of items (default: yes). By default its keybindings start with the g key. ๐
--load-context-menu=<yes|no>
Enable the builtin script that implements a context menu. Defaults to yes on platforms where integration with a native context menu is not implemented, and to no on platforms where it is. ๐
--load-positioning=<yes|no>
Enable the builtin script that provides various keybindings to pan videos and images (default: yes).
--player-operation-mode=<cplayer|pseudo-gui>
For enabling "pseudo GUI mode", which means the defaults for some options get changed. This option should not normally be used directly โ only by mpv internally, or by mpv-provided scripts, config files, or .desktop files. See PSEUDO GUI MODE for the details. ๐
๐ธ Watch Later ๐ธ
--save-position-on-quit
Always save the current playback position on quit โ and also when the loadfile command is used to replace the current playlist. When that file gets played again later, the player seeks to the old playback position on start. โจ
This does not happen if playback of a file is stopped in other ways. For example, going to the next file in the playlist will not save the position, and will start playback at the beginning the next time that file is played.
This behavior is disabled by default, but it's always available when quitting the player with Shift+Q. ๐
See RESUMING PLAYBACK.
--watch-later-dir=<path>
The directory where the "watch later" temporary files get stored. ๐
--watch-later-directory is an alias for --watch-later-dir.
If this option is unset, the files get stored in a subdirectory named "watch_later" underneath the local state directory (usually ~/.local/state/mpv/).
--resume-playback=<yes|no>โ bestie, this one picks up right where you left off ๐ It restores your playback position from thewatch_laterconfig subdirectory, which is usually~/.config/mpv/watch_later/. Default isyesโ so yeah, mpv remembers your spot unless you tell it not to. Iconic behavior honestly.--resume-playback-check-mtime=<yes|no>โ only restore that playback position from thewatch_latersubdirectory (usually~/.config/mpv/watch_later/) if the file's modification time is the same as it was when the position got saved. This can stop mpv from skipping forward in files that have the same name but totally different content, no cap. Default:no.--watch-later-options=option1,option2,...โ the options that get saved into "watch later" files if they've been changed since mpv started. Those values get restored next time you play the files. And heads up: the playback position is saved through thestartoption, not this one. โจ
When you remove options, existing watch later data doesn't get touched โ it still applies fully โ but new watch later data just won't contain those options anymore.
Wanna see the list of properties that get restored by default? Run --help=watch-later-options. ๐ซถ
This is a string list option. See List Options for details.
Examples
--watch-later-options-remove=sidโ the subtitle track selection will not be restored.--watch-later-options-remove=volume --watch-later-options-remove=muteโ the volume and mute state won't be saved to watch later files.--watch-later-options=startโ no option will be saved to watch later files, except the playback position.
--write-filename-in-watch-later-configโ prepends the watch later config files with the name of the file they refer to. It's just written as a comment at the top of the file. Simple as that.
Warning: this option may expose privacy-sensitive information and is thus disabled by default. ๐
--ignore-path-in-watch-later-configโ ignore the path (i.e. use filename only) when using the watch later feature. Default:disabled.
๐ธ Watch History ๐ธ
--save-watch-historyโ whether to save which files are played. Then you can select them with the defaultg-hkey binding. So convenient, lowkey obsessed.
Warning: this option may expose privacy-sensitive information and is thus disabled by default. ๐
--watch-history-path=<path>โ the path where the watch history gets stored. Default:~~state/watch_history.jsonl(see FILES).
This file contains one JSON object per line, fr fr. Its time field is the UNIX timestamp for when the file was opened, its path field is the normalized path, and its title field is the title when it was available. ๐
๐ฌ Video ๐ฌ
--vo=<driver>โ specify the video output backend to use. See VIDEO OUTPUT DRIVERS for details and descriptions of the available drivers. ๐--vd=<...>โ specify a priority list of video decoders to use, according to their family and name. See--adfor 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.
--vf=<filter1[=parameter1:parameter2:...],filter2,...>โ specify a list of video filters to apply to the video stream. See VIDEO FILTERS for details and descriptions of the available filters. The option variants--vf-add,--vf-pre, and--vf-clrexist to modify a previously specified list โ but bestie, you shouldn't need those for typical use. ๐--untimedโ do not sleep when outputting video frames. Useful for benchmarks when used with--audio=no. Go fast, no brakes. ๐ฅ--framedrop=<mode>โ skip displaying some frames to keep A/V sync on slow systems, or when playing high framerate video on video outputs that have an upper framerate limit.
The argument selects the drop method, and it can be one of these:
<no>โ disable any frame dropping. Not recommended, for testing only. ๐<vo>โ drop late frames on video output (default). This still decodes and filters all frames, it just doesn't render them on the VO. Drops show up in the terminal status line as theDropped: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 that, 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 thedisplay-resample-desyncmode). 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. โจ
<decoder>โ old, decoder-based framedrop mode. (This is the same as--framedrop=yesin mpv 0.5.x and before.) This tells the decoder to skip frames (unless they're 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 can't be controlled in a predictable manner. Not recommended.
- Even if you do wanna use this, prefer
decoder+vofor better results. - The
--vd-lavc-framedropoption controls what frames to drop.
<decoder+vo>โ enable both modes. Not recommended. Better than justdecodermode though, ngl.
Note: --vo=vdpau has its own code for the vo framedrop mode. Slight differences to other VOs are possible.
--video-latency-hacks=<yes|no>โ 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 doesn't inherently need to do these things anymore. Using this option is known to break other options such as interpolation, so it is not recommended to enable this. ๐ซ
This does:
- Use the demuxer reported FPS for frame dropping. This avoids the player needing to decode 1 frame in advance, lowering total latency in effect. This also means that if the demuxer reported FPS is wrong, or the video filter chain changes FPS (e.g. deinterlacing), then it could drop too many or not enough frames.
- Disable waiting for the first video frame. Normally the player waits for the first video frame to be fully rendered before starting playback properly. Some VOs will lazily initialize stuff when rendering the first frame, so if this isn't done, there's some likeliness that the VO has to drop some frames if rendering the first frame takes longer than needed.
--display-fps-override=<fps>โ 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's 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.
--hwdec=<api1,api2,...|no|auto|auto-copy>โ 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 isn't possible, mpv will fall back on software decoding.
Hardware decoding is not enabled by default, to keep the out-of-the-box configuration as reliable as possible. However, when using modern hardware, hardware video decoding should work correctly, offering reduced CPU usage, and possibly lower power consumption. On older systems, it may be necessary to use hardware decoding due to insufficient CPU resources; and even on modern systems, sufficiently complex content (eg: 4K60 AV1) may require it.
This is a string list option. See List Options for details.
Note: use theCtrl+hshortcut to toggle hardware decoding at runtime. It toggles this option betweenautoandno.
Note: even if enabled, hardware decoding is still only white-listed for some codecs. See --hwdec-codecs to enable hardware decoding in more cases.
Note: if you decide you want to use hardware decoding by default, the general recommendation is to try out decoding with the command line option, and prove to yourself that it works as desired for the content you care about. After that, you can add it to your config file. When testing, you should start by usinghwdec=autoas it will limit itself to choosing from hwdecs that are actively supported by the development team. If that doesn't result in working hardware decoding, you can tryhwdec=auto-unsafeto have it attempt to load every possible hwdec โ but ifautodidn't work, you will probably need to know exactly which hwdec matches your hardware and read up on that entry below. Ifautoproduced the desired results, we recommend just sticking with that and only setting a specific hwdec in your config file if it is really necessary. If you use the Ubuntu package, keep in mind that their/etc/mpv/mpv.confcontainshwdec=vaapi, which is less than ideal as it may not be the right choice for your system, and it may end up using an inefficient wrapper library under the covers. We recommend removing this line or deleting the file altogether. ๐
Which method to choose?
- If you literally only wanna turn hardware decoding on at runtime โ don't set the parameter at all, or drop
hwdec=nointo yourmpv.conf. (super relevant on distros that force-enable it by default, like Ubuntu, bestie ๐ ) Just use the defaultCtrl+hbinding to flip it on at runtime. Iconic, zero config, chef's kiss. โจ - If you're not sure but you want hardware decoding always on by default โ put
hwdec=yesinto yourmpv.conf, and acknowledge that this may cause problems. No cap, it might. ๐ซ - Wanna test which hardware decoding methods you actually have? Pass
--hwdec=auto --hwdec-codecs=alland look at the terminal output. That's the vibe check right there. ๐ - Devs and anyone doing elaborate testing โ you may need any of the other possible option values. Go wild, you're the main character here. ๐
This option takes a comma delimited list of api types, plus some special values that are doing their own little thing:
noโ always use software decoding (this is the default, periodt)autoโ enable any whitelisted hw decoder (see below, iykyk)auto-unsafeโ forcibly enable any hw decoder found (see below, and buckle up)yesโ exactly the same asautoauto-safeโ exactly the same asauto
Note: Special values can be mixed with api names. eg:vaapi,autowill try and use thevaapihwdec, and if that fails, will run through the normalautologic. Mix and match, slay. ๐
โจ Actively supported hwdecs โจ
d3d11vaโ requires--vo=gpuor--vo=gpu-nextwith--gpu-context=d3d11or--gpu-context=angle(Windows 8+ only)d3d11va-copyโ copies video back to system RAM (Windows 8+ only)videotoolboxโ requires--vo=gpuor--vo=gpu-next(macOS 10.8 and up), or--vo=libmpv(iOS 9.0 and up)videotoolbox-copyโ copies video back into system RAM (macOS 10.8 or iOS 9.0 and up)vaapiโ requires--vo=gpu,--vo=gpu-next,--vo=vaapior--vo=dmabuf-wayland(Linux only)vaapi-copyโ copies video back into system RAM (Linux with some GPUs or Windows)nvdecโ requires--vo=gpuor--vo=gpu-next(Any platform CUDA is available)nvdec-copyโ copies video back to system RAM (Any platform CUDA is available)drmโ requires--vo=gpuor--vo=gpu-next(Linux only)drm-copyโ copies video back to system RAM (Linux only)vulkanโ requires--vo=gpu-next(Any platform with Vulkan Video Decoding)vulkan-copyโ copies video back to system RAM (Any platform with Vulkan Video Decoding)
Other hwdecs (only use if you know you have to) ๐
dxva2โ requires--vo=gpuwith--gpu-context=d3d11,--gpu-context=angleor--gpu-context=dxinterop(Windows only)dxva2-copyโ copies video back to system RAM (Windows only)vdpauโ requires--vo=gpuwith--gpu-context=x11, or--vo=vdpau(Linux only)vdpau-copyโ copies video back into system RAM (Linux with some GPUs only)mediacodecโ requires--vo=gpu --gpu-context=androidor--vo=mediacodec_embed(Android only)mediacodec-copyโ copies video back to system RAM (Android only)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, but allows only whitelisted methods that are considered "safe". The idea is that this is a reasonable way to enable hardware decoding by default in a config file (even though, ngl, you shouldn't do that anyway; prefer runtime enabling with Ctrl+h). Unlike auto-unsafe, this will not try to enable unknown or known-to-be-bad methods. On top of that, this may disable hardware decoding in other situations when it's known to cause problems, but currently this mechanism is quite primitive. (Example of 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-unsafe is similar to auto, but without the whitelist. In general, you should never need to use this beyond debugging or development use. Any known unsafe hwdec you want to test can simply be appended to the list option such as --hwdec=auto,unsafe-hwdec. This still depends what VO you are using. See the list above, for which --vo and gpu-context is required for a given hwdec. It will go down the list of available hwdecs until one is successfully initialised. If all of them fail, it will fallback to software decoding. ๐ซก
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), but it only allows whitelisted methods that are considered "safe". 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. โจ
auto-copy-safe is an alias for auto-copy.
auto-copy-unsafe is the same as auto-copy except that it goes through all methods and not just the whitelisted ones that are considered "safe".
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 if you are short on CPU resources. Just so you know, bestie.
Note: Most non-copy methods only work with the OpenGL GPU backend. Currently, only thevaapi,nvdec,cudaandvulkanmethods work with Vulkan.
The vaapi mode, if used with --vo=gpu or --vo=gpu-next most likely works with Intel and AMD GPUs only. It requires the opengl EGL backend if the GPU does not support drm modifiers.
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. This has largely ceased to be a problem with modern hardware, but there is a lot of hardware out there, so caveat emptor. Known problems are discussed below, but the list cannot be considered exhaustive, as even hwdecs that work well on certain hardware generations may be problematic on other ones.
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.
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. ๐
mediacodec is not safe. It forces RGB conversion (not with -copy) and how well it handles non-standard colorspaces is not known. In the rare cases where 10-bit is supported the bit depth of the output will be reduced to 8.
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. For some reason. Bestie. Why. ๐
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. Like, just turn it off and see, bestie. That's the vibe check. ๐
--gpu-hwdec-interop=<auto|all|no|name>โ okay so this one is literally a troubleshooting option for hwdec interop issues. And because it's a debugging option, its semantics may change at any time. ๐ซ So don't build your whole personality around it, yk?
It's useful for the gpu and libmpv VOs, for selecting exactly which hwdec interop context to use. Effectively it can also 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). So like, set it and forget it, babes.
--hwdec-extra-frames=<N>โ how many GPU frames hardware decoding should preallocate (default: see--list-optionsoutput). 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. It's giving โจno thoughts, just vibesโจ but with VRAM.
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. ๐
--hwdec-image-format=<name>โ set the internal pixel format used by hardware decoding via--hwdec(defaultno). The special valuenoselects 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. ๐ฅ
--cuda-decode-device=<auto|0..>โ pick the GPU device used for decoding when using thecudaornvdechwdecs with the OpenGL GPU backend, and with thecuda-copyornvdec-copyhwdecs 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.
--vaapi-device=<device file|adapter name>โ choose the DRM device forvaapi-copy. This should be the path to a DRM device file. (Default:/dev/dri/renderD128)
On Windows this takes adapter name as an input. Will pick the default adapter if unset. Alternatives are listed when the name "help" is given.
--panscan=<0.0-1.0>โ enables pan-and-scan functionality (cropping the sides of e.g. a16:9video to make it fit a4:3display 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.
The difference between --panscan and --video-zoom is that --panscan can only zoom in until either the video width or height fills the window, while --video-zoom can zoom in or out arbitrary amounts, and also works with --video-unscaled. Slay, now you know the difference. ๐
--video-aspect-override=<ratio|no>โ override video aspect ratio, in case aspect information is incorrect or missing in the file being played. Not me fixing your metadata for you. ๐
These values have special meaning:
noโ use the method of the--video-aspect-methodoption (default)0โ disable aspect ratio handling, pretend the video has square pixels (deprecated, use--video-aspect-override=no --video-aspect-method=ignoreinstead)-1โ strictly prefer the container aspect ratio (deprecated, use--video-aspect-override=no --video-aspect-method=containerinstead)
But note that handling of these special values might change in the future. โ ๏ธ So don't get too attached, fr fr.
Examples ๐ธ
--video-aspect-override=4:3or--video-aspect-override=1.3333--video-aspect-override=16:9or--video-aspect-override=1.7777--no-video-aspect-overrideor--video-aspect-override=no
--video-aspect-method=<bitstream|container|ignore>โ this sets the default video aspect determination method (if the aspect is _not_ overridden by the user with--video-aspect-overrideor 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 withbitstream.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.ignoreโ Disable aspect ratio handling, pretend the video has square pixels.
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. Lowkey a detective moment. ๐ต๏ธโโ๏ธ
--video-unscaled=<no|yes|downscale-big>โ 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 todownscale-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 --keepaspect=no is used.
--video-pan-x=<value>,--video-pan-y=<value>โ 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 video fullscreen on a 1920x1080 screen with --video-pan-x=-0.1 would move the video 192 pixels to the left and --video-pan-y=-0.1 would move the video 108 pixels up. Math queen behavior. ๐
This option is disabled if --keepaspect=no is used.
--video-rotate=<0-359|no>โ rotate the video clockwise, in degrees. Ifnois given, the video is never rotated, even if the file has rotation metadata. (The rotation value is added to the rotation metadata, which means the value0would rotate the video according to the rotation metadata.)
When using hardware decoding without copy-back, only 90ยฐ steps work, while software decoding and hardware decoding methods that copy the video back to system memory support all values between 0 and 359. ๐
--video-crop=<[W[xH]][+x+y]>,--video-crop=<x:y>โ crop the video by starting at thex,yoffset forw,hpixels. The crop is applied to the source video rectangle (before anamorphic stretch) by the VO. A crop rectangle that is not within the video rectangle will be ignored. This works with hwdec, unlike the equivalent 'lavfi-crop'. When offset is omitted, the central area will be cropped. Setting the crop to empty one--video-crop=0x0+0+0overrides container crop and disables cropping. Setting the crop to--video-crop=""disables manual cropping and restores the container crop if it's specified. โ๏ธโจ--video-zoom=<value>โ adjust the video display scale factor by the given value. The parameter is given log 2. For example,--video-zoom=0is unscaled,--video-zoom=1is twice the size,--video-zoom=-2is one fourth of the size, and so on. Log scales ate, no cap. ๐
This option is disabled if --keepaspect=no is used.
--video-scale-x=<value>,--video-scale-y=<value>โ multiply the video display size with the given value (default:1.0). If a non-default value is used, this will be different from the window size, so video will be either cut off, or black bars are added.
This value is multiplied with the value derived from --video-zoom and the normal video aspect ratio. This option is disabled if --keepaspect=no is used.
--video-align-x=<-1-1>,--video-align-y=<-1-1>โ when the video is bigger than the window, these move the displayed rectangle to show different parts of the video.--video-align-y=-1would display the top of the video,0would display the center (default), and1would display the bottom.
When the video is smaller than the window and --video-recenter is disabled, these move the video rectangle within the black borders, which are usually added to pad the video to the window if video and window aspect ratios are different. --video-align-y=-1 would move the video to the top of the window (leaving a border only on the bottom), 0 would center it, and 1 would put the video at the bottom of the window. ๐ฆ
If video and screen aspect match perfectly, these options do nothing. Iconic. Do nothing. Periodt. ๐
Unlike --video-pan-x and --video-pan-y, these ones do not yeet past the video's or window's edges, and they don't make the displayed rectangle lowkey drift off after you zoom. โจ
This option gets disabled if you're running --keepaspect=no.
--video-recenter=<yes|no>โ ok so this is asking: when the video gets smaller than the window in some direction, should mpv act like--video-align-xand--video-align-ywere0? ๐
Picture the arc: you zoom in until the video is bigger than the window, you pan around with --video-align-x and/or --video-align-y, then you zoom back out until the video is smaller than the window again โ and this is what snaps it back to the center. iconic behavior honestly.
Default: no.
- **
--video-margin-ratio-left=<val>,--video-margin-ratio-right=<val>,--video-margin-ratio-top=<val>,--video-margin-ratio-bottom=<val>โ set extra video margins on each border (default:0). Each value is a ratio of the window size, using a range0.0-1.0. For example, setting the option--video-margin-ratio-right=0.2at 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 --keepaspect=no 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. (ngl, a lil chaotic of them, but we move ๐ )
--correct-pts=<yes|no>โ--correct-pts=noswitches mpv to a mode where video timing is determined using a fixed framerate value (either using the--container-fps-overrideoption, or using file information). Sometimes, files with very broken timestamps can be played somewhat well in this mode.
bestie, be warned: video filters, subtitle rendering, seeking (including hr-seeks and backstepping), and audio synchronization can be completely broken in this mode. ๐
--container-fps-override=<float>โ override video framerate. Useful if the original value is wrong or missing.
Note: works in --correct-pts=no mode only.
--deinterlace=<yes|no|auto>โ enable or disable deinterlacing (default:no). Interlaced video shows ugly comb-like artifacts, which are visible on fast movement. Enabling this typically inserts thebwdifvideo filter in order to deinterlace the video, or lets the video output apply deinterlacing if supported.
When using auto, mpv will insert a deinterlacing filter if ffmpeg detects that the video frame is interlaced. Be aware that there can be false positives in certain cases, such as when files are encoded as interlaced despite the video not actually being so. This is why auto is not the default value. ๐ญ
Keep in mind that using this filter will conflict with any manually inserted deinterlacing filters, and that this will make video look worse if it's not actually interlaced.
--deinterlace-field-parity=<tff|bff|auto>โ specify the field parity/order when deinterlacing (default:auto). Each frame of an interlaced video is divided into two fields, which are then separately transmitted. Top field represents even lines while bottom field represents odd lines. When deinterlacing the deinterlacer needs to know the correct temporal order of the fields else the video will appear jittery.
auto will automatically try to detect the field order of the video, tff forces top field first while bff forces bottom field first. ๐ธ
--frames=<number>โ 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.
--video-output-levels=<outputlevels>โ 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 levelsfullโ full range (0-255 per component), PC levels
Note: it is advisable to use your graphics driver's color range option instead, if available.
--hwdec-codecs=<codec1,codec2,...|all>โ allow hardware decoding for a given list of codecs only. The special valueallalways 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,vp8,vp9,av1,prores,prores_raw,ffv1,dpx. Note that the hardware acceleration special codecs like h264_vdpau are not relevant anymore, and in fact have been removed from FFmpeg 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.
Note: on some broken drivers (e.g. NVIDIA on Linux), probing for codecs which the GPU does not support can unnecessarily slow down video playback initialization. To alleviate this, explicitly specify a list which only includes the codecs supported on the setup.
Example mpv --hwdec=vdpau --hwdec-codecs=h264,mpeg2video Enable vdpau decoding for h264 and mpeg2 only.
--hwdec-threads=<N>โ number of threads used for hardware decoding (default:4). This, as opposed tovd-queue, enables frame and slice threading in libavcodec. It can help with pipelining the decoding process and improve performance. The exact behavior depends on the hardware decoder API used.
If this is set to 0, the number of threads will be automatically determined by the number of CPU cores available. ๐ง
--hwdec-software-fallback=<yes|no|N>โ 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.1is equivalent toyes.
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.
--vd-lavc-check-hw-profile=<yes|no>โ check hardware decoder profile (default:yes). Ifnois set, the highest profile of the hardware decoder is unconditionally selected, and decoding is forced even if the profile of the video is higher than that. The result is most likely broken decoding, but may also help if the detected or reported profiles are somehow incorrect. ๐ญ--vd-lavc-film-grain=<auto|cpu|gpu>โ enables film grain application on the GPU. If video decoding is done on the CPU, doing film grain application on the GPU can speed up decoding. This option can also help hardware decoding, as it can reduce the number of frame copies done.
By default, it's set to auto, so if the VO supports film grain application, then it will be treated as gpu. If the VO does not support this, then it will be treated as cpu, regardless of the setting. Currently, only gpu-next supports film grain application. โจ
--vd-lavc-dr=<auto|yes|no>โ enable direct rendering (default:auto). If this is set toyes, 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.libmpv: The libmpv render API has optional support.
The auto option will try to guess whether DR can improve performance on your particular hardware. Currently this enables it on AMD or NVIDIA if using OpenGL or unconditionally if using Vulkan.
Using video filters of any kind that write to the image data (or output newly allocated frames) will silently disable the DR code path. ๐
--vd-lavc-bitexactโ only use bit-exact algorithms in all decoding steps (for codec testing).--vd-lavc-fast(MPEG-1/2 and H.264 only) โ enable optimizations which do not comply with the format specification and potentially cause problems, like simpler dequantization, simpler motion compensation, assuming use of the default quantization matrix, assuming YUV 4:2:0 and skipping a few checks to detect damaged bitstreams. ๐--vd-lavc-o=<key>=<value>[,<key>=<value>[,...]]โ pass AVOptions to libavcodec decoder. Note, a patch to make theo=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
--vd-lavc-show-all=<yes|no>โ bestie, do you want to see the broken frames too? default:no. When it'sno, libavcodec is like "nope, not showing you that" and refuses to output frames that got decoded before the first keyframe showed up, plus any frame it clocked as corrupted. Set it toyesif you're nosy. ๐--vd-lavc-skiploopfilter=<skipvalue>โ (H.264, HEVC only) skips the loop filter (aka deblocking ๐ถโ๐ซ๏ธ) while decoding. And here's the tea: since the filtered frame is supposed to be the reference for decoding frames that depend on it, this messes with quality way harder than skipping deblocking on, say, MPEG-2 video. But for high bitrate HDTV at least, you get a huge speedup with basically no visible quality loss. Other codecs that aren't H.264 or HEVC might have partial support for this (often onlyallandnone).
<skipvalue> can be one of these, periodt:
noneโ never skip. never ever.defaultโ skip the useless processing steps (like 0 size packets in AVI, fr fr pointless).nonrefโ skip frames that aren't referenced (i.e. not used to decode other frames, so the error literally cannot "build up"). no cap.bidirโ skip B-Frames.nonkeyโ skip everything except keyframes.allโ skip all the frames. all of them. ๐
--vd-lavc-skipidct=<skipvalue>โ (MPEG-1/2/4 only) skips the IDCT step. heads up: this degrades quality a lot in almost all cases ๐ญ (peepskiploopfilterfor the available skip values).--vd-lavc-skipframe=<skipvalue>โ skips decoding of frames completely. big speedup but jerky motion and sometimes bad artifacts (again, seeskiploopfilterfor the available skip values).--vd-lavc-framedrop=<skipvalue>โ sets the framedropping mode used with--framedrop(and yep,skiploopfilterhas the available skip values).--vd-lavc-threads=<N>โ how many threads to use for decoding. whether threading is even supported depends on the codec (default:0). and0means "autodetect the number of cores on the machine and use that", up to a max of16. you can manually set more than 16 threads, you menace. ๐--vd-lavc-assume-old-x264=<yes|no>โ assume the video was encoded by an old, buggy x264 version (default:no). normally libavcodec autodetects this. but picture this: the bitstream has no x264 version info (or it got skipped somehow), the stream was actually encoded by an old x264 version (build 150 or earlier), and the stream uses 4:4:4 chroma โ then libavcodec will by default show you corrupted video. this option sets the libavcodecx264_buildoption to150, which means: if the stream contains no version info, or wasn't encoded by x264 at all, it assumes it was encoded by the old version. enabling this is pretty safe if you just want your broken files to work, but in theory it can break on streams not encoded by x264, or if a stream encoded by a newer x264 version contains no version info. ๐ซ--vd-apply-croppingโ certain video codecs support cropping, meaning only a sub-rectangle of the decoded frame is meant for display. this option controls how cropping is handled by libavcodec. cropping during decoding has certain limitations when it comes to alignment and hardware decoding. if this option is enabled, the decoder will apply the crop, otherwise the VO handles it. enabled by default. โจ--swapchain-depth=<N>โ allow up toNin-flight frames. this basically controls the frame latency. bumping up the swapchain depth can improve pipelining and prevent missed vsyncs, but it increases visible latency. this option only mandates an upper limit โ the implementation can use a lower latency than requested internally. a setting of1means the VO will wait for every frame to become visible before it starts rendering the next frame. (Default:2)
๐ง Audio ๐ง
--audio-pitch-correction=<yes|no>โ if this is enabled (it is, by default), playing at a speed that isn't normal automatically inserts thescaletempo2audio filter. you can insert other filters besidesscaletempo2and modify their params using Conditional auto profiles:
[af_insert]
profile-cond=speed ~= 1
profile-restore=copy
af-add=scaletempo2=search-interval=50 # Insert filter and params here.
filters set this way replace the scaletempo2 default instead of overlapping with it. and if there are multiple audio filters inserted that can do pitch correction, only the last one in the filter chain gets used. for the specifics of each available filter, go look at the audio filter section. ๐
--audio-device=<name>โ use the given audio device. this is the audio output name (likealsa), then a/, then the audio-output-specific device name. the default value for this option isauto, 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 also be retrieved by API using the audio-device-list property.
and 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. BUT 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
--audio-exclusive=<yes|no>โ enable exclusive output mode. in this mode the system is usually locked out and only mpv can output audio. main character energy, honestly. ๐
this only works for some audio outputs, like wasapi, coreaudio, pipewire and audiounit. other audio outputs silently ignore this option โ they either have no concept of exclusive mode, or the mpv side of the implementation is just missing. ๐
--audio-fallback-to-null=<yes|no>โ if no audio device can be opened, behave as if--ao=nullwas given. this is useful combined with--audio-device: instead of throwing an error when the selected device doesn't exist, the client API user (or a Lua script) could let playback continue normally and check thecurrent-aoandaudio-device-listproperties to make high-level decisions about how to continue. lowkey elegant.--ao=<driver>โ specify the audio output drivers to be used. see AUDIO OUTPUT DRIVERS for the details and descriptions of the available drivers. ๐ถ--af=<filter1[=parameter1:parameter2:...],filter2,...>โ specify a list of audio filters to apply to the audio stream. see AUDIO FILTERS for details and descriptions of the available filters. the option variants--af-add,--af-pre, and--af-clrexist to modify a previously specified list, but bestie you should not need those for typical use. ๐--audio-spdif=<codecs>โ list of codecs for which compressed audio passthrough should be used. 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).
--ad=<decoder1,decoder2,...[-]>โ 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 one's unavailable, the next decoder is used. finally, it tries all other decoders that aren't explicitly selected or rejected by the option.
a - at the end of the list suppresses fallback on other available decoders that aren't on the --ad list. this should not normally be used, because it breaks normal decoder auto-selection! the - mode is deprecated. โ ๏ธ
Examples
--ad=mp3floatโ prefer the FFmpegmp3floatdecoder over all other MP3 decoders.--ad=helpโ list all available decoders.
Warning: enabling compressed audio passthrough (AC3 and DTS via SPDIF/HDMI) with this option is not possible. use --audio-spdif instead.
--volume=<value>โ set the startup volume.0means silence,100means no volume reduction or amplification. negative values can be passed for compatibility, but they're treated as0. ๐
since mpv 0.18.1, this always controls the internal mixer (aka software volume).
--volume-max=<100.0-1000.0>โ set the maximum amplification level in percent (default:130). a value of130will let you adjust the volume up to about double the normal level. turn it up bestie ๐--volume-gain=<db>โ set the volume gain in dB. this gets applied on top of other volume and gain settings.--volume-gain-max=<0.0-150.0>,--volume-gain-min=<-150.0-0.0>โ set the volume gain range in dB (default:-96dB min,12dB max).--replaygain=<no|track|album>โ adjust volume gain according to replaygain values stored in the file metadata. with--replaygain=no(the default), perform no adjustment. with--replaygain=track, apply track gain. with--replaygain=album, apply album gain if present and fall back to track gain otherwise. ๐--replaygain-preamp=<db>โ pre-amplification gain in dB to apply to the selected replaygain gain (default:0).--replaygain-clip=<yes|no>โ bestie, do you want the volume gain to just go ahead and clip? Default is no. And when it's not enabled, mpv is the responsible friend who quietly lowers the gain so clipping never happens. ๐--replaygain-fallback=<db>โ the gain in dB you apply when a file has, like, zero replaygain tags. It's also always applied if the replaygain logic is somehow inactive for whatever reason. Heads up: once this one kicks in, no other replaygain options get applied. That's it, that's the deal. โจ--audio-delay=<sec>โ audio delay in seconds, and yes it takes a positive or negative float. Positive values delay the audio, negative values delay the video. Pick your fighter. ๐ง--mute=<yes|no>โ sets the startup audio mute status (default: no). Lowkey just "am I muted the second I open".
See also: --volume. ๐ซถ
--audio-demuxer=<[+]name>โ which audio demuxer type to use when you're rocking--audio-file. Slap a+in front of the name to force it โ that skips some checks. Give the demuxer name exactly as printed by--audio-demuxer=help. no cap. ๐--ad-lavc-ac3drc=<level>โ picks the Dynamic Range Compression level for AC-3 audio streams.<level>is a float from0to1, where0= no compression at all (that's the default, bestie) and1= full compression (loud passages get more silent, and vice versa, it's giving balance). Values up to6are also accepted, but those are purely experimental, so proceed with caution. This option only does anything if the AC-3 stream actually has the required range compression info. ๐
The standard says DRC is enabled by default, but mpv (and some other players) ignore that for the sake of better audio quality. iconic behavior tbh.
--ad-lavc-downmix=<yes|no>โ whether to ask the decoder for audio channel downmixing (default: no). Some decoders โ AC-3, AAC, DTS, the usual suspects โ can remix audio while decoding. The number of output channels you're requesting gets set with the--audio-channelsoption. Super useful for playing surround audio on a plain stereo system. ๐ถ--ad-lavc-threads=<0-16>โ number of threads to use for decoding. Whether threading is even supported depends on the codec โ as of this writing, it's supported for some lossless codecs only.0means autodetect the number of cores on your machine and use that, up to a maximum of16(default: 1). โจ--ad-lavc-o=<key>=<value>[,<key>=<value>[,...]]โ passes AVOptions to the libavcodec decoder. Also, a lil note: a patch that makes theo=unneeded and passes all unknown options through the AVOption system is welcome. A full list of AVOptions lives in the FFmpeg manual. ๐
This is a key/value list option. See List Options for details.
--ad-spdif-dtshd=<yes|no>,--dtshd=<yes|no>โ if DTS is being passed through, use DTS-HD.
โ ๏ธ Warning: this option, and enabling passthrough via--ad, are deprecated in favor of using--audio-spdif=dts-hd. pls use the new one, bestie, i'm begging ๐
--audio-channels=<auto-safe|auto|layouts>โ controls which audio channels get output (surround vs. stereo, etc.). Here are your possibilities, queen: ๐--audio-channels=auto-safeโ use the system's preferred channel layout. If there isn't one (like when you're accessing a hardware device instead of the system mixer), force stereo. Some audio outputs might just accept any layout and do their own downmixing anyway.
This is the default. โญ
--audio-channels=autoโ send the audio device whatever it accepts, preferring the audio's original channel layout. This can cause issues with HDMI (see the warning below, iykyk). ๐--audio-channels=layout1,layout2,...โ a list of,-separated channel layouts that should be allowed. Technically, this only adjusts the filter chain output to the best matching layout in the list, then passes the result to the audio API. It's possible the audio API will go rogue and select a different channel layout. ๐ญ
Using this mode is recommended for direct hardware output, especially over HDMI (see HDMI warning below).
--audio-channels=<stereo|mono>โ force a downmix to stereo or mono. These are special-cases of the previous item. (See the paragraphs below for the 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, so like, 2 channels refers to stereo, 6 refers to 5.1. ๐๏ธ
See --audio-channels=help output for defined default layouts. That also lists speaker names, which you can use 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 that output. This sometimes triggers decoder-downmix, which might be different from the normal mpv downmix. (Only some decoders support remixing audio โ AC-3, AAC or DTS. You can use --ad-lavc-downmix=no to make the decoder always output its native layout.) One consequence: --audio-channels=stereo triggers decoder downmix, while auto or auto-safe never will, even if they end up selecting stereo. That's because the decision about whether to use decoder downmix happens long before the audio device is even 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, since mpv does not have control over it. Another work-around on some AOs is to use --audio-exclusive=yes to circumvent the system mixer entirely. ๐
โ ๏ธ Warning: usingautocan 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 โ like 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 that can do 7.1 would be served by:--audio-channels=7.1,5.1,stereo
--audio-display=<no|embedded-first|external-first>โ determines whether to display cover art when playing audio files, and with what priority. It'll display the first image found, and additional images are available as video tracks. ๐ผ๏ธnoโ disable display of video entirely when playing audio files.embedded-firstโ display embedded images and external cover art, giving priority to embedded images (this is the default).external-firstโ display embedded images and external cover art, giving priority to external files.
This option has no influence on files with normal video tracks. ๐
--audio-files=<files>โ play audio from an external file while you're watching a video. the ultimate dual-wield ๐ง๐บ
This is a path list option. See List Options for details.
--audio-file=<file>โ CLI/config file only alias for--audio-files-append. Every single time you use this option it adds a new audio track. The details are similar to how--sub-fileworks. โจ--audio-format=<format>โ selects the sample format used for output from the audio filter layer to the sound card. The values<format>can adopt are listed below in the description of the format audio filter. ๐๏ธ--audio-samplerate=<Hz>โ selects the output sample rate to be used (and yeah, sound cards have limits on this, obviously). If the sample frequency you picked differs from the current media's, the internalswresampleaudio filter gets inserted into the audio filter layer to compensate for the difference. ๐--gapless-audio=<no|yes|weak>โ tries to play consecutive audio files with no silence or disruption at the point where the file changes. Default: weak. ๐ตnoโ disable gapless audio. bye.yesโ the audio device is opened using parameters chosen for the first file played, and then kept open for gapless playback. This means if the first file has, say, a low sample rate, then the following files may get resampled to that same low sample rate, resulting in reduced sound quality. ๐ญ If you play files with different parameters, consider using options like--audio-samplerateand--audio-formatto 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 outputs changes, the audio device is closed and reopened. This means you'll normally get gapless audio with files encoded using the same settings, but it 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, as long as the sample formats are convertible. If video is still going on when there's still audio, trying to use gapless is also explicitly given up on. ๐
๐ Note: this feature is implemented in a simple manner and relies on audio output device buffering to keep playback going while moving from one file to another. If playback of the new file starts slowly โ for example because it's played from a remote network location, or because you specified cache settings that need time for the initial cache fill โ then the buffered audio may run out before playback of the new file can even start. ๐ซ
--initial-audio-sync=<yes|no>โ so when you start a video file, or after stuff like seeking, mpv will by default tweak the audio stream so it kicks off at the same timestamp as the video โ either by padding silence at the start or snipping off the first samples. Turn this off and the player acts like the old mpv versions did: video and audio both just go immediately even if their start timestamps are different, and then the video timing gets gradually nudged along if it needs to, to hit correct sync later on. ๐ฌ--audio-file-auto=<no|exact|fuzzy|all>โ loads extra audio files that match the video filename, bestie. The parameter decides how those external audio files get matched. โจnoโ don't auto-load external audio files at all (this is the default).exactโ load the media filename with an audio file extension.fuzzyโ load every audio file containing the media filename.allโ load all audio files in the current directory and in the--audio-file-pathsdirectories.
--audio-exts=ext1,ext2,...โ the audio file extensions to try matching when you're using--audio-file-auto,--autocreate-playlistor--directory-filter-types. ๐ง
This is a string list option. See List Options for details. Use --help=audio-exts to see the default extensions.
--audio-file-paths=<path1:path2:...>โ literally the same idea as the--sub-file-pathsoption, but for auto-loaded audio files. ๐ซถ
This is a path list option. See List Options for details.
--audio-client-name=<name>โ the application name that the player reports to the audio API. Highkey useful if you wanna force a different audio profile (say, with PulseAudio), or set your own application name when you're using libmpv. ๐--audio-set-media-role=<yes|no>โ if you enable this, mpv sets the appropriate media role on supported audio servers, so it can signal whether mpv is playing a video or an audio-only file. This is disabled by default since per-media-role volumes have often caused unexpected and confusing behavior. ๐
Default: no.
--audio-buffer=<seconds>โ sets the audio output minimum buffer. The audio device might actually make a bigger buffer if it feels like it. And if the device makes a smaller one, the extra audio gets buffered in an additional software buffer. ๐
Making this bigger may make soft-volume and other filters react slower, introduce extra issues when you change playback speed, 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).
--audio-stream-silence=<yes|no>โ okay so cash-grab consumer audio hardware (looking at you, A/V receivers ๐) often ignores the initial audio sent over HDMI. This can happen every single time audio over HDMI is stopped and resumed. To compensate, you can enable this option so mpv doesn't stop and restart audio on seeks, and instead fills the gaps with silence. Same energy when pausing: audio isn't stopped, silence just plays while paused. Note that if no audio track is selected, the audio device will still be closed immediately. โจ
Not all AOs support this.
Warning: This modifies certain subtle player behavior, like A/V-sync and underrun handling. Enabling this option is strongly discouraged. ๐
--audio-wait-open=<secs>โ this one makes sense for use with--audio-stream-silence=yes. If you give this option, the player waits the given amount of seconds after opening the audio device before sending actual audio data to it. Useful if your expensive hardware discards the first 1 or 2 seconds of audio data sent to it. And if--audio-stream-silence=yesisn't set, this option will likely just waste time. ๐ญ
โจ Subtitles โจ
Note: Changing styling and position does not work with all subtitles. Image-based subtitles (DVD, Bluray/PGS, DVB) can't be changed, for fundamental reasons. Subtitles in ASS format are normally not changed intentionally, but overriding them can be controlled with --sub-ass-override.
--sub-demuxer=<[+]name>โ forces the subtitle demuxer type for--sub-file. Give the demuxer name exactly as printed by--sub-demuxer=help. ๐ฆ--sub-lavc-o=<key>=<value>[,<key>=<value>[,...]]โ passes AVOptions to the libavcodec decoder. Ngl, a patch to make theo=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.
--sub-delay=<sec>โ delays primary subtitles by<sec>seconds. Can be negative. โฑ๏ธ--secondary-sub-delay=<sec>โ delays secondary subtitles by<sec>seconds. Can be negative too.--sub-files=<file-list>,--sub-file=<filename>โ adds 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. ๐
--secondary-sid=<ID|auto|no>โ selects a secondary subtitle stream. This is similar to--sid. If a secondary subtitle is selected, it'll be rendered as toptitle (i.e. on the top of the screen) alongside the normal subtitle by default, and it gives you 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 picking a bitmap subtitle as your secondary subtitle will result in overlapping subtitles. Also, 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 --sub-ass=no 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 --sub-ass=no to disable styling in the main subtitle stream.
--sub-scale=<0-100>โ 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.
--sub-scale-signs=<yes|no>โ when set toyes, also applies--sub-scaleto typesetting (or "signs"). When this is set tono,--sub-scaleis only applied to dialogue. The distinction between dialogue and typesetting is done on a best effort basis and is not infallible (default:no). ๐จ--sub-scale-by-window=<yes|no>โ whether to scale subtitles with the window size (default:yes). If this is disabled while--sub-scale-with-windowis set toyes, changing the window size won't change the subtitle font size. ๐ช
Affects plain text subtitles only (or ASS if --sub-ass-override is set high enough).
--sub-scale-with-window=<yes|no>โ makes the subtitle font size relative to the window (default:yes). If this is disabled while--sub-scale-by-windowis set toyes, the subtitle font size is scaled relative to the video size instead. ๐
Affects plain text subtitles only (or ASS if --sub-ass-override is set high enough).
Note: By default, the subtitle font size is scaled with the window size. To make the font size constant, set only--sub-scale-by-windowtono. To make the font size scale with video size instead, set only--sub-scale-with-windowtono. It's not meaningful to set both options tono.
--sub-ass-scale-with-window=<yes|no>โ like--sub-scale-with-window, but affects subtitles in ASS format only. And like--sub-scale, this can break ASS subtitles. ๐ญ
Default: no.
--embeddedfonts=<yes|no>โ use fonts embedded in Matroska container files and ASS scripts (default:yes). These fonts can be used for SSA/ASS subtitle rendering. ๐ฅ--sub-pos=<0-150>โ specify the position of subtitles on the screen. The value is the vertical position of the subtitle in % of the screen height.100is the original position, which is often not the absolute bottom of the screen, but sits with some margin between the bottom and the subtitle. Values above100move the subtitle further down. โฌ๏ธ
Warning: Text subtitles (as opposed to image subtitles) may be cut off if the value of the option is above100. This is a libass restriction. This affects ASS subtitles as well, and may lead to incorrect subtitle rendering in addition to the problem above. Using--sub-margin-ycan achieve this in a better way.
--secondary-sub-pos=<0-150>โ specify the position of secondary subtitles on the screen. Similar to--sub-pos, but for secondary subtitles. ๐--sub-speed=<0.1-10.0>โ multiplies 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.
--sub-ass-style-overrides=<[Style.]Param=Value[,...]>โ override some style or script info parameters. ๐
This is a string list option. See List Options for details.
Examples
--sub-ass-style-overrides=FontName=Arial,Default.Bold=1--sub-ass-style-overrides=PlayResY=768
Note: using this option may lead to incorrect subtitle rendering. ๐
--sub-hinting=<none|light|normal|native>โ sets the font hinting type, bestie. type can be any of these:noneโ no hinting (default) โจlightโ FreeType autohinter, light modenormalโ FreeType autohinter, normal modenativeโ the font's native hinter
Warning: enabling hinting can lead to mispositioned text (like in situations where it's supposed to match up with the video background ๐ญ), or it can reduce the smoothness of animations with some badly authored ASS scripts. the recommendation is literally to not use this option unless you really need it. fr fr.
--sub-line-spacing=<value>โ sets the line spacing value for the SSA/ASS renderer. that's the whole thing. ๐--sub-shaper=<simple|complex>โ picks which text layout engine libass uses, choose your fighter:simpleโ uses Fribidi only. fast ๐โ๏ธ but doesn't render some languages correctlycomplexโ uses HarfBuzz. slower ๐ but wider language support
complex is the default. and ngl, if libass hasn't been compiled against HarfBuzz, it just silently reverts to simple. no warning, no drama. ๐คทโ๏ธ
--sub-ass-prune-delay=<-1|seconds>โ sets the delay for automatic pruning of events from memory in libass. when it's enabled, subtitle events get yeeted from memory once their end timestamp is older than the delay you chose.-1โ disables automatic pruning (default).- seconds โ how many seconds after an event is no longer displayed should the pruning happen.
0prunes events as soon as they're off screen. ๐
Note: this breaks sub-seek and subtitle rendering when you flip play-direction from forward to backward at runtime, for events that were already "seen" and need to be rendered again โ but only if those events got pruned. so like, iykyk. ๐
--sub-glyph-limit=<value>โ sets the maximum number of cached glyphs in the libass cache for the subtitle track.0means libass uses its own default value.
Default: 0.
--sub-bitmap-max-size=<value>โ sets the maximum bitmap cache size in the libass cache for the subtitle track.0means libass uses its default value. this one takes values in MB.
Default: 0.
--sub-ass-styles=<filename>โ loads all the SSA/ASS styles it can find in the file you point at, and uses 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. ๐ญ
--sub-ass-override=<no|yes|scale|force|strip>โ controls whether user style overrides get applied. heads up tho: all of these overrides try to be somewhat smart about figuring out whether a subtitle counts as a "sign", and they try to be as non-destructive as possible. so gentle. so mindful. so considerate. ๐ซถ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.scaleโ likeyes, but also applies--sub-scale(default).forceโ likeyes, but also forces all--sub-*options. can break rendering easily ๐. certain options aren't overridden if they can potentially be too destructive.stripโ radically strips all ASS tags and styles from the subtitle. this is equivalent to the old--no-ass/--no-sub-assoptions.
this also controls some bitmap subtitle overrides, plus HTML tags in formats like SRT, despite the name of the option. the name is a little misleading, we know. ๐
--secondary-sub-ass-override=<no|yes|scale|force|strip>โ controls whether user secondary substyle overrides get applied. works exactly like--sub-ass-override.
Default: strip.
--sub-ass-force-marginsโ enables placing toptitles and subtitles in black borders when they're available, if the subtitles are in the ASS format.
Default: no.
--sub-use-marginsโ enables placing toptitles and subtitles in black borders when they're available, if the subtitles are in a plain text format (or ASS if--sub-ass-overrideis set high enough).
Default: yes.
--sub-ass-use-video-data=<none|aspect-ratio|all>โ controls which info about the video stream gets passed to libass. any option other thanallis incompatible with standard ASS as defined by VSFilter โ and VSFilter's behavior is what most subtitle scripts and renderers target, libass included. video stream properties are needed to accurately emulate VSFilter semantics, and withholding them will likely result in broken subtitle rendering for most files. so like, only change this selectively if it's actually required on a per-file basis. ๐noneโ don't forward any video stream information.aspect-ratioโ only forward aspect ratio; fallbacks are used for other properties. this makes behavior consistent across different video resolutions.allโ forward all available information, notably including storage resolution.
for certain kinds of broken ASS files which got repurposed across several video resolutions without either setting LayoutRes headers or adjusting affected effects, it may be desirable to withhold storage resolution information from libass to ensure consistent rendering across resolutions. among others this affects 3D rotations and blurs. when you encounter such files, try setting aspect-ratio.
even more broken files on anamorphic video might also exhibit stretching unless aspect ratio information is also faked โ in this case you can try using none. this has never an effect on non-anamorphic video.
Default: all
--sub-ass-video-aspect-override=<no|ratio>โ allows passing any arbitrary aspect ratio to libass instead of the video's actual aspect ratio. zero aspect ratio is identical tono.
this has no effect if sub-ass-use-video-data is set to none.
--sub-vsfilter-bidi-compat=<yes|no>โ sets implicit bidi detection toltrinstead ofautoto match ASS' default. this also disables libass' incompatible extensions. currently that includes bracket pair matching according to the revised Unicode Bidirectional Algorithm introduced in Unicode 6.3, and it also affects how BiDi runs are split and processed, plus soft linewrapping of Unicode text.
this affects plaintext (non-ASS) subtitles only. Default: no.
--sub-ass-vsfilter-color-compat=<basic|full|force-601|no>โ mangles colors like (xy-)vsfilter does (default:basic). storytime, bestie ๐: 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 handed the frame to the video output, which would use BT.709 for conversion to RGB. the result? 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-subs=<yes|no>โ stretches 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-image-subs-to-screen=<yes|no>โ stretches DVD and other image subtitles to the screen, ignoring the video margins. this has a similar effect to--sub-use-marginsfor 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.
--image-subs-video-resolution=<yes|no>โ overrides the image subtitle resolution with the video resolution (default:no). normally, the subtitle canvas is fit into the video canvas (e.g. letterboxed). setting this option uses the video size as subtitle canvas size. can be useful to test broken subtitles, which often happen when the video was transcoded, while attempting to keep the old subtitles.--image-subs-hdr-peak=<sdr|video|10-10000>โ controls the image subtitle diffuse white level in cd/mยฒ (nits) for HDR output (default:sdr).sdris 203 cd/mยฒ for standard SDR white, whilevideouses video metadata. (--vo=gpu-nextonly)
this also affects image subtitle brightness in HDR tone mapping with --blend-subtitles=<yes|video>.
--sub-hdr-peak=<sdr|10-10000>โ bestie, this one controls the text subtitle and OSD diffuse white level in cd/mยฒ (nits) for HDR output. Default?sdr. Andsdris203 cd/mยฒfor standard SDR white. (--vo=gpu-nextonly) ๐
It also affects text subtitle brightness in HDR tone mapping with --blend-subtitles=<yes|video>. โจ
--sub-ass=<yes|no>โ Render ASS subtitles natively. Default:yes. โจ
Note: This has been deprecated by--sub-ass-override=strip. You also may need--embeddedfonts=noto get the same behavior. Also, using--sub-ass-override=styleshould give better results without breaking subtitles too much. ๐ญ
If --sub-ass=no 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 --sub-ass=no 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. ๐
--sub-auto=<no|exact|fuzzy|all>โ Load additional subtitle files matching the video filename. The parameter specifies how external subtitle files are matched.exactis enabled by default. ๐ฆnoโ Don't automatically load external subtitle files.exactโ Load the media filename with subtitle file extension and possibly language suffixes (default).fuzzyโ Load all subs containing the media filename.allโ Load all subs in the current and--sub-file-pathsdirectories.
--sub-auto-exts=ext1,ext2,...โ Subtitle extensions to try and match when using--sub-auto. Note that modifying this list will also affect what mpv recognizes as subtitles when using drag and drop. ๐
This is a string list option. See List Options for details. Use --help=sub-auto-exts to see default extensions.
--sub-codepage=<codepage>โ You can use this option to specify the subtitle codepage.uchardetwill be used to guess the charset. (If mpv was not compiled withuchardet, thenutf-8is 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:
- if the specific codepage has a
+, use that codepage - if the data looks like UTF-8, assume it is UTF-8
- if
--sub-codepageis set to a specific codepage, use that - run
uchardet, and if successful, use that - otherwise, use
UTF-8-BROKEN
Examples
--sub-codepage=latin2โ Use Latin 2 if input is not UTF-8.--sub-codepage=+cp1250โ Always force recoding tocp1250.
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. ๐
Note: This works for text subtitle files only. Other types of subtitles (in particular subtitles in mkv files) are always assumed to be UTF-8. ๐
--sub-stretch-durations=<yes|no>โ Stretch a subtitle duration so it ends when the next one starts. Should help with subtitles which erroneously have zero durations. ๐ซถ
Note: Only applies to text subtitles. โจ
--sub-fix-timing=<yes|no>โ Adjust subtitle timing to remove minor gaps or overlaps between subtitles. ๐
See also: --sub-fix-timing-threshold and --sub-fix-timing-keep.
--sub-fix-timing-threshold=<amount>โ Set the threshold in milliseconds for fixing subtitle timing (default:210). If the gap between two subtitle events is smaller than this, the gap is removed. โญ--sub-fix-timing-keep=<amount>โ Set the minimum duration in milliseconds for subtitle events to be considered for timing fixes (default:400). If a subtitle event has a duration smaller than this, its timing is not changed. ๐--sub-forced-events-only=<yes|no>โ Enabling this displays only forced events within subtitle streams. Only some bitmap subtitle formats (such as DVD or PGS) are capable of having a mixture of forced and unforced events within the stream. Enabling this on text subtitles will cause no subtitles to be displayed (default:no). ๐--sub-fps=<rate>โ 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. ๐ฆ
--sub-gauss=<0.0-3.0>โ Apply Gaussian blur to image subtitles (default:0). This can help to make pixelated DVD/Vobsubs look nicer. A value other than0also switches to software subtitle scaling. Might be slow. ๐ญ
Note: Never applied to text subtitles. ๐
--sub-grayโ Convert image subtitles to grayscale. Can help to make yellow DVD/Vobsubs look nicer. ๐
Note: Never applied to text subtitles. ๐
--sub-file-paths=<path-list>โ 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:
/path/to/video//path/to/video/sub//path/to/video/subtitles/- the sub configuration subdirectory (usually
~/.config/mpv/sub/)
This is a path list option. See List Options for details. โจ
--sub-visibility=<yes|no>โ Can be used to disable display of subtitles, but still select and decode them. ๐--secondary-sub-visibility=<yes|no>โ Can be used to disable display of secondary subtitles, but still select and decode them. ๐--sub-clear-on-seekโ (Obscure, rarely useful.) Can be used to play broken mkv files with duplicate ReadOrder fields. ReadOrder is the first field in a Matroska-style ASS subtitle packets. It should be unique, andlibassuses it for fast elimination of duplicates. This option disables caching of subtitles across seeks, so after a seeklibasscan't eliminate subtitle packets with the same ReadOrder as earlier packets. Note that enabling this option can result in broken subtitle behavior if you are not actually playing one of the aforementioned broken mkv files. ๐--teletext-page=<-1-999>โ Select a teletext page number to decode. ๐บ
This works for dvb_teletext subtitle streams, and if FFmpeg has been compiled with support for it.
Values 1-999 are for individual pages. Special value 0 (default) matches all subtitle pages. Special value -1 matches all pages.
Note that page 100 is the default start page of actual teletext. It is also the former default value of this option.
See the libzvbi-teletext section in FFmpeg documentation for details.
Default: 0 โจ
--sub-past-video-endโ After the last frame of video, if this option is enabled, subtitles will continue to update based on audio timestamps. Otherwise, the subtitles for the last video frame will stay onscreen. ๐ฌ
Default: disabled ๐
--sub-font=<name>โ Specify font to use for subtitles that do not themselves specify a particular font. The default issans-serif. ๐
Examples
--sub-font='Bitstream Vera Sans'--sub-font='Comic Sans MS'
Note: The--sub-fontoption (and many other style related--sub-options) are ignored when ASS-subtitles are rendered, unless--sub-ass=nois specified. This used to support fontconfig patterns. Starting with libass0.13.0, this stopped working. ๐ญ
--sub-font-size=<size>โ Specify the sub font size. The unit is the size in scaled pixels at a window height of720. The actual pixel size is scaled with the window height: if the window height is larger or smaller than720, the actual size of the text increases or decreases as well. ๐ฅ
Default: 38 โญ
--sub-blur=<0..20.0>โ Gaussian blur factor applied to the sub font border.0means no blur applied (default). ๐ธ--sub-bold=<yes|no>โ Format text on bold. ๐ช--sub-italic=<yes|no>โ Format text on italic. ๐--sub-outline-color=<color>โ See--sub-color. Color used for the sub font outline. ๐จ
--sub-border-color is an alias for --sub-outline-color. โจ
--sub-back-color=<color>โ See--sub-color. Color used for sub text background. ๐๏ธ
--sub-shadow-color is an alias for --sub-back-color. โจ
--sub-outline-size=<size>โ Size of the sub font outline in scaled pixels (see--sub-font-sizefor details). A value of0disables outlines. ๐
--sub-border-size is an alias for --sub-outline-size.
Default: 1.65 ๐
--sub-border-style=<outline-and-shadow|opaque-box|background-box>โ The style of the border. ๐ผ๏ธoutline-and-shadow: draw outline and shadow. The size of the outline is determined by--sub-outline-size, and the offset of the shadow is determined by--sub-shadow-offset. The outline is colored by--sub-outline-color, and the shadow is colored by--sub-back-color. This corresponds toBorderStyle=1in the ASS spec.
opaque-boxโ draws the outline AND the shadow as opaque boxes that hug each line of text super tight, no gaps, no chill. The margin of the outline opaque box comes from--sub-outline-size, and the offset of the shadow opaque box comes from--sub-shadow-offset. The outline opaque box gets its color from--sub-outline-color, and the shadow opaque box gets its color from--sub-back-color. And yes bestie, despite the whole "opaque" name situation, this box can absolutely be semi-transparent. That's just its name, not its personality. This corresponds toBorderStyle=3in the ASS spec. ๐background-boxโ draws a background box that bounds all the lines of text together, one big cozy rectangle. The background box is colored by--sub-back-color, and its margin is determined by--sub-shadow-offset. The outline behaves exactly like it does in theoutline-and-shadowstyle. This corresponds toBorderStyle=4, which is a libass-specific extension, iykyk. โจ
Default: outline-and-shadow.
Predefined profiles are available to enable the optimized background-box style for OSD and subtitles. So you don't even have to do the work yourself, iconic.
Profiles ๐
--profile=sub-boxโ applies thebackground-boxstyle to subtitles ๐--profile=osd-boxโ applies thebackground-boxstyle to the OSD, including stats and console ๐ซถ--profile=boxโ applies thebackground-boxstyle to both subtitles and OSD, the full package deal ๐
--sub-color=<color>โ sets the color used for unstyled text subtitles. The color goes in the formr/g/b, where each component is a number from0.0to1.0. You can also add transparency withr/g/b/a, where alpha0means fully transparent and1.0means opaque. If you skip the alpha component, the color is 100% opaque, no secrets here. ๐ฅ
If you pass a single number to the option, it sets the sub to gray, and the form gray/a lets you specify alpha on top of that.
Examples โจ
--sub-color=1.0/0.0/0.0set sub to opaque red--sub-color=1.0/0.0/0.0/0.75set sub to opaque red with 75% alpha--sub-color=0.5/0.75set sub to 50% gray with 75% alpha
Alternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value from 0 (00) to 255 (FF). For example, #FF0000 is red. Alpha is given with #AARRGGBB.
Examples ๐
--sub-color='#FF0000'set sub to opaque red--sub-color='#C0808080'set sub to 50% gray with 75% alpha
--sub-margin-x=<size>โ left and right screen margin for the subs, in scaled pixels (peep--sub-font-sizefor the details). This option sets how far the sub sits from the left, and also how far from the right border long sub text gets broken. No more text escaping off the edge of your screen, we love boundaries. ๐ฆ
Default: 19
--sub-margin-y=<size>โ top and bottom screen margin for the subs, in scaled pixels (again,--sub-font-sizehas the deets). This one sets the vertical margins of unstyled text subtitles. And listen, if you just wanna raise the vertical subtitle position, use--sub-posinstead, that's literally what it's for. ๐ธ
Default: 34
--sub-align-x=<left|center|right>โ controls which corner of the screen text subtitles get aligned to (default:center).
Never applied to ASS subtitles, except in --sub-ass=no mode. Same energy: this does not apply to image subtitles either. Not every sub gets the same treatment, it's giving selective. ๐
--sub-align-y=<top|center|bottom>โ vertical position (default:bottom). Details, go read--sub-align-x, it's all there bestie. ๐--sub-justify=<auto|left|center|right>โ controls how multi line subs get justified, regardless of where they're aligned (default:auto, which justifies as defined by--sub-align-x). Left justification is the recommended one because it makes subs easier to read โ your eyes literally have an easier time, no cap. ๐--sub-ass-justify=<yes|no>โ applies justification as defined by--sub-justifyon ASS subtitles, but only if--sub-ass-overrideis not set tono. Default:no.--sub-shadow-offset=<size>โ displacement of the sub text shadow, in scaled pixels (see--sub-font-sizefor details). A value of0disables shadows entirely. Poof, gone. ๐
Default: 0.
--sub-spacing=<size>โ horizontal sub font spacing in scaled pixels (yep,--sub-font-sizeagain). This value gets added to the normal letter spacing. Negative values are allowed, so you can really squeeze those letters together if that's your vibe. ๐
Default: 0.
--sub-filter-sdh=<yes|no>โ applies a filter that removes subtitle additions for the deaf or hard-of-hearing (SDH). It's intended for English, but it may partly work for other languages too. The whole intention is that you can leave it always enabled, so heads up: it may not remove every single added part. ๐ง
It removes speaker labels (like MAN:) and any text enclosed within symbols like parentheses or brackets, as specified by the --sub-filter-sdh-enclosures option. Note that parenthesis (full width parenthesis and the normal variant) are a special case โ only upper case text gets removed there. Want more filtering? That's what --sub-filter-sdh-harder is for.
Default: no.
--sub-filter-sdh-harder=<yes|no>โ do harder SDH filtering (only if it's been enabled by--sub-filter-sdh). This one will also remove speaker labels and text within parentheses using both lower and upper case letters. It does not play around. ๐ฅ
Default: no.
--sub-filter-sdh-enclosures=<string>โ specify pairs of characters that--sub-filter-sdhwill use to potentially remove text. This is a string list option. See List Options for details. Text enclosed within each specified pair gets removed. Note that parenthesis pairs (normal and full width) are treated as a special case and require--sub-fitler-sdh-harderto be removed. ๐ญ
Default: (),[],๏ผ๏ผ
--sub-filter-regex-...=...โ set a list of regular expressions to match on text subtitles, and remove any lines that match (default: empty). This is a string list option. See List Options for details. Normally you should use--sub-filter-regex-append=<regex>, where each use of the option appends a new regular expression, without you having to fight escaping problems. Your sanity: preserved. ๐ซถ
List items are matched in order. If a regular expression matches, the process stops right there and the subtitle line is discarded. The text matched against is, by default, the Text field of ASS events (if the subtitle format is different, it is always converted). This may include formatting tags. Matching is case-insensitive, but how that's done depends on the libc, and most likely works in ASCII only. It does not work on bitmap/image subtitles. And it's unavailable on inferior OSes (requires POSIX regex support). ๐
Example ๐
--sub-filter-regex-append=opensubtitles\.org filters
some ads.
Technically, using a list for matching is redundant, since you could just use a single combined regular expression. But it helps with diagnosis, ease of use, and temporarily disabling or enabling individual filters. So it's staying.
Warning: This is experimental. The semantics most likely will change, and if you use this, you should be prepared to update the option later. Ideas include replacing the regexes with a very primitive and small subset of sed, or some method to control case-sensitivity. You've been warned, bestie.
--sub-filter-jsre-...=...โ same as--sub-filter-regexbut with JavaScript regular expressions. Shares/is affected by all--sub-filter-regex-*control options (see below), and is also experimental. Requires only JavaScript support. โญ--sub-filter-regex-plain=<yes|no>โ whether to first convert the ASSTextfield to plain-text (default:no). This strips ASS tags and applies ASS directives, like\Nto new-line. If the result is multi-line, then the regexp anchors^and$match each line, but still any match discards all lines. All or nothing energy. ๐--sub-filter-regex-warn=<yes|no>โ log dropped lines with warning log level, instead of verbose (default:no). Helpful for testing. ๐ฅ--sub-filter-regex-enable=<yes|no>โ whether to enable regex filtering (default:yes). Note that if no regexes are added to the--sub-filter-regexlist, setting this option toyeshas no effect. It's meant to easily disable or enable filtering temporarily, like a little on/off switch for your vibe check. ๐--sub-create-cc-track=<yes|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 (which mpv displays as subtitle tracks using the codeceia_608). The CC track is marked"default"and selected according to the normal subtitle track selection rules. You can then use--sidto 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. Just sitting there, empty, main character with no lines. ๐ญ
--sub-font-provider=<auto|none|fontconfig>โ which libass font provider backend to use (default:auto).autowill attempt to use the native font provider: fontconfig on Linux, CoreText on macOS, DirectWrite on Windows.fontconfigforces fontconfig, if libass was built with support (if not, it behaves likenone).
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.) Strict queen. ๐
--sub-fonts-dir=<path>โ font files in this directory are used by mpv/libass for subtitles. Useful if you do not want to install fonts to your system. Note that files in this directory are loaded into memory before being used by mpv โ so if you have a lot of fonts, consider usingfonts.conf(see FILES section) to include additional mpv user settings. ๐ฆ
If this option is not specified, ~~/fonts will be used by default.
๐ช Window ๐ช
--title=<string>โ sets the window title, bestie. It's used for the video window, and if it possibly can, it also sets the audio stream title. โจ
Properties get expanded here. (Peep Property Expansion.)
โ ๏ธ Warning: this can absolutely eat your CPU alive depending on which properties you use. Changing the window title is often a slow operation, and if the title changes every single frame, your playback is gonna get ruined. ๐ Not the vibe.
--screen=<default|0-32>โ when you've got multiple monitors (aka one desktop spanning a bunch of displays), this tells mpv which screen to put the video on. ๐ฅ๏ธ
Note (X11)
This does not work properly with every window manager, sadly. In those cases you can try --geometry to place the window explicitly, and it's also possible your window manager has its own native features for controlling which screens app windows land on. ๐ซถ
Note (Wayland)
Fr fr this one doesn't actually work on wayland, because window placement isn't allowed there. But setting it does influence mpv's initial guess at finding an output, which can be useful for stuff like --geometry or --autofit that depend on the monitor resolution. ๐ธ
Also see --fs-screen.
--screen-name=<string>โ same multi-monitor situation, except this one picks the screen based on the screen name from the video backend. Same caveats as--screenapply here too. And heads up: this option gets ignored and does literally nothing if--screenis explicitly set. ๐--fullscreen,--fsโ fullscreen playback. That's it, that's the whole thing. ๐--fs-screen=<all|current|0-32>โ multi-monitor again, but this one decides which screen to go fullscreen on. If you usecurrent, mpv falls back on whatever you gave it with thescreenoption. ๐ฅ๏ธโจ
Note (X11)
This only works properly with window managers that understand the EWMH _NET_WM_FULLSCREEN_MONITORS hint.
Note (macOS)
all does not work on macOS and will behave like current. ๐ญ
Also see --screen.
--fs-screen-name=<string>โ multi-monitor, fullscreen, but based on the screen name from the video backend. Same caveats as--fs-screen. Ignored and does nothing if--fs-screenis explicitly set. ๐--keep-open=<yes|no|always>โ do not terminate when you're playing or seeking past the end of the file and there's no next file to play (and--loopisn't in use). Instead, it pauses the player. And when you try to seek beyond the end of the file, the player attempts to seek to the last frame. ๐ซถ
Normally this acts like set pause yes on EOF, unless --keep-open-pause=no is set.
Here's what the arguments do:
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-openwith no arguments.alwaysโ likeyes, but it also applies to files before the last playlist entry. Which means playback will never automatically advance to the next file. ๐ค
Note: this option is not respected when you use--frames. And explicitly skipping to the next file, if the binding usesforce, will terminate playback too. Also, if errors or unusual circumstances happen, the player can quit anyway. ๐
Since mpv 0.6.0, this doesn't pause if there's a next file in the playlist, or if the playlist is looped. Approximately, it'll pause when the player would normally exit โ but in practice there are corner cases where that's not true (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.) ๐ง
--keep-open-pause=<yes|no>โ if you set this tono, then instead of pausing when--keep-openis active, mpv just stops at end of file and keeps playing forward when you seek backwards โ until it hits the end and stops again. Default:yes. โญ--image-display-duration=<seconds|inf>โ if the current file is an image, play it for the given number of seconds (default:5).infmeans the file is kept open forever (until the user stops playback manually). ๐ผ๏ธ๐
Unlike --keep-open, the player is not paused โ it just continues playback until the time has elapsed. (It shouldn't 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, like 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.
When you're viewing images, the playback time is not tracked on the command line output, and the image frame is not duplicated when encoding. To force the player into "dumb mode" and actually count out seconds, or to duplicate the image when encoding, you need --demuxer=lavf --demuxer-lavf-o=loop=1, and use --length or --frames to stop after a particular time. ๐ฅ
--force-window=<yes|no|immediate>โ makes a video output window even when there's no video at all. Super handy when you're pretending mpv is a GUI application. Currently the window always has the size960x540, and it's subject to--geometry,--autofit, and similar options. ๐ช
โ ๏ธ Warning: the window is created only after initialization (so that default window placement still works if the video size differs from the--force-windowdefault window size). This can be a problem if initialization doesn't work perfectly โ like opening URLs with a bad network connection, or opening broken video files. Theimmediatemode can be used to create the window always on program start, but that may cause other issues. ๐ญ
--taskbar-progress=<yes|no>โ (Windows only) enable/disable playback progress rendering in the taskbar (Windows 7 and above). Enabled by default. ๐--snap-windowโ (Windows only) snap the player window to screen edges. โจ--drag-and-drop=<no|auto|replace|append|insert-next>โ controls the default drag and drop behavior on platforms that support it.autoobeys whatever the underlying os/platform hands mpv. Typically, holding shift during the drag and drop appends the item to the playlist. Otherwise, it completely replaces it.replace,append, andinsert-nextalways force replacing, appending to, and inserting next into the playlist respectively. Andnodisables all drag and drop behavior. ๐ฆ--ontopโ makes the player window stay on top of other windows. On Windows, if you combine this with fullscreen mode, it causes mpv to be treated as an exclusive fullscreen window that bypasses the Desktop Window Manager. ๐--ontop-level=<window|system|desktop|level>โ (macOS only) sets the level of an on-top window (default:window). ๐windowโ on top of all other windows.systemโ on top of system elements like Taskbar, Menubar and Dock.desktopโ on top of the Desktop behind windows and Desktop icons.levelโ a level as integer.
--focus-on=<never|open|all>,โ (macOS only) focuses the video window and makes it the front most window on specific events (default:open). ๐neverโ never focus the window on open or new file load events.openโ focus the window on creation, eg when a vo is initialised.allโ focus the window on open and new file load event.
--window-corners=<default|donotround|round|roundsmall>โ (Windows only) sets the preference for window corner rounding. ๐defaultโ let the system decide whether or not to round window cornersdonotroundโ never round window cornersroundโ round the corners if appropriateroundsmallโ round the corners if appropriate, with a small radius
--border=<yes|no>โ play video with window border and decorations. Since this is on by default, use--no-borderto disable the standard window decorations. ๐--title-bar=<yes|no>โ (Windows and X11 only) play video with the window title bar. Since this is on by default, use--title-bar=noto hide the title bar. The--borderoption takes precedence. โญ--on-all-workspacesโ (X11 and macOS only) show the video window on all virtual desktops. ๐--geometry=<[W[xH]][+-x+-y][/WS]>,--geometry=<x:y>โ adjust the initial window position or size.WandHset the window size in pixels.xandyset 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--geometryoption format, in which e.g.+10-50means "place 10 pixels from the left border and 50 pixels from the lower border" and--20+-10means "place 20 pixels beyond the right and 10 pixels beyond the top border". A trailing/followed by an integer denotes on which workspace (virtual desktop) the window should appear (X11 only). ๐โจ
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 (macOS)
On macOS, the origin of the screen coordinate system sits at the bottom-left corner. so like, 0:0 will drop the window at the bottom-left of your screen ๐
Note (X11): this option does not work properly with all window managers. some of them are just gonna do their own thing, no cap ๐
Note (Wayland): Wayland does not allow a client to position itself, so this option will only affect the window size. that's literally it ๐ญ
Examples โจ
50:40โ places the window at x=50, y=40.50%:50%โ places the window in the middle of the screen.100%:100%โ places the window at the bottom right corner of the screen.50%โ sets the window width to half the screen width. window height is set so the window has the video aspect ratio.50%x50%โ forces the window width and height to half the screen width and height. will show black borders to compensate for the video aspect ratio (with most VOs and with--keepaspect=yes).50%+10+10/2โ sets the window to half the screen widths, and positions it 10 pixels below/left of the top left corner of the screen, on the second workspace.
see also --autofit and --autofit-larger for fitting the window into a given size without changing aspect ratio ๐ซถ
--autofit=<[W[xH]]>โ sets the initial window size to a maximum size given by WxH, and it does not change the window's aspect ratio. the size is measured in pixels, or if a number is followed by a%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 gets reduced until it fits into the size you asked for. periodt ๐
window position is not taken into account, and it's not modified by this option either (the window manager may still place the window differently depending on size, that's just a WM thing). use --geometry to change the window position โ its effects are applied after this option.
see --geometry for details on 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
70%โ make the window width 70% of the screen size, keeping aspect ratio.1000โ set the window width to 1000 pixels, keeping aspect ratio.70%x60%โ make the window as large as possible, without being wider than 70% of the screen width, or higher than 60% of the screen height.
--autofit-larger=<[W[xH]]>โ behaves exactly like--autofit, except it sets the maximum size of the window.
Example
90%x80%โ if the video is larger than 90% of the screen width or 80% of the screen height, make the window smaller until either its width is 90% of the screen, or its height is 80% of the screen.
--autofit-smaller=<[W[xH]]>โ behaves exactly like--autofit, except it sets the minimum size of the window (just like--autofit-largersets the maximum).
Example
500x500โ make the window at least 500 pixels wide and 500 pixels high (depending on the video aspect ratio, the width or height will be larger than 500 in order to keep the aspect ratio the same).
--window-scale=<factor>โ resize the video window to a multiple (or fraction) of the video size. this option is applied before--autofitand other options are applied (so they override this option). changing this option while the window is maximized can unmaximize the window depending on the OS and window manager. if the window does not unmaximize, the multiplier will be applied if the user unmaximizes the window later. ๐
for example, --window-scale=0.5 would show the window at half the video size.
--window-minimized=<yes|no>โ whether the video window is minimized or not. setting this will minimize, or unminimize, 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).
--window-maximized=<yes|no>โ whether the video window is maximized or not. setting this will maximize, or unmaximize, the video window if the current VO supports it. see--window-minimizedfor further remarks.--cursor-autohide=<number|no|always>โ make the mouse cursor automatically hide after a given number of milliseconds (default:1000ms).nowill disable cursor autohide.alwaysmeans the cursor will stay hidden. ๐ซฅ--cursor-autohide-fs-onlyโ if this option is given, the cursor is always visible in windowed mode. in fullscreen mode, the cursor is shown or hidden according to--cursor-autohide.--force-rgba-osd-renderingโ change how some video outputs render the OSD and text subtitles. this does not change the appearance of the subtitles and only has performance implications. for VOs which support native ASS rendering (likegpu,vdpau,direct3d), this can be slightly faster or slower, depending on GPU drivers and hardware. for other VOs, this just makes rendering slower ๐ญ--force-renderโ forces mpv to always render frames regardless of the visibility of the window. currently only affects X11, Wayland andmacvkVOs since they are the only ones that have this optimization (i.e. everything else always renders regardless of visibility).--force-window-positionโ forcefully move mpv's video output window to the default location whenever there is a change in video parameters, video stream or file. this used to be the default behavior. currently only affects X11,macvkand SDL VOs.--auto-window-resize=<yes|no>โ by default, mpv will automatically resize itself if the video's size changes (i.e. advancing forward in a playlist). setting this tonodisables this behavior so the window size never changes automatically. this option does not have any impact on the--autofitor--geometryoptions.--keepaspect=<yes|no>โ--keepaspect=nowill always stretch the video to window size, and will disable the window manager hints that force the window aspect ratio. (ignored in fullscreen mode.)--keepaspect-window=<yes|no>โ--keepaspect-window=yes(the default) will lock the window size to the video aspect.--keepaspect-window=nodisables this behavior, and will instead add black bars if window aspect and video aspect mismatch. whether this actually works depends on the VO backend. (ignored in fullscreen mode.)--monitoraspect=<ratio>โ set the aspect ratio of your monitor or TV screen. a value of0disables a previous setting (e.g. in the config file). overrides the--monitorpixelaspectsetting if enabled. โจ
see also --monitorpixelaspect and --video-aspect-override.
Examples
--monitoraspect=4:3or--monitoraspect=1.3333--monitoraspect=16:9or--monitoraspect=1.7777
--hidpi-window-scale=<yes|no>โ scale the window size according to the backing DPI scale factor from the OS (default:no). for example, if the OS DPI scaling is set to 200%, mpv's window size will be multiplied by 2.--native-fs=<yes|no>โ (macOS only) uses the native fullscreen mechanism of the OS (default:yes).--show-in-taskbar=<yes|no>โ (Windows and X11 only) show mpv in the taskbar (default:yes). if set tono, mpv will no longer appear in taskbars and tasklists in supported window managers, and may be excluded from Alt+Tab window switching. ๐ซฃ--monitorpixelaspect=<ratio>โ set the aspect of a single pixel of your monitor or TV screen (default:1). a value of1means square pixels (correct for (almost?) all LCDs). see also--monitoraspectand--video-aspect-override.--stop-screensaver=<yes|no|always>โ turns off the screensaver (or screen blanker and similar mechanisms) at startup and turns it on again on exit (default:yes). when usingyes, the screensaver will re-enable when playback is not active.alwayswill always disable the screensaver. note that stopping the screensaver is only possible if a video output is available (i.e. there is an open mpv window). this is not supported on all video outputs, platforms, or desktop environments. ๐
before mpv 0.33.0, the X11 backend ran xdg-screensaver reset in 10 second intervals when not paused in order to support screensaver inhibition in some environments. this functionality was removed in 0.33.0, but it is possible to call the xdg-screensaver command line program from a user script instead.
--wid=<ID|-1>โ 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.
an ID of value -1 is interpreted specially, and mpv will detach from the currently attached window to its own window. ๐ฆ
On X11, that ID gets read as a Window on X11. And here's the tea: unlike MPlayer/mplayer2, mpv always makes its own window, and it just sets the wid window as the parent. That window is always gonna get resized to cover the parent fully. Oh and the value 0? Special. mpv draws directly on the root window. iconic ๐
On win32, the ID is an HWND. Pass it as a value cast to uint32_t (all Windows handles are 32-bit), and bestie this matters โ mpv will not accept negative values. mpv makes its own window and sets the wid window as parent, same as with X11. And 0 again is special: mpv draws on top of the desktop wallpaper and below the desktop icons. layers, we love layers โจ
On Android, the ID is an android.view.Surface. Pass it as a value cast to intptr_t. Use it with --vo=mediacodec_embed and --hwdec=mediacodec for direct rendering using MediaCodec, or with --vo=gpu --gpu-context=android (with or without --hwdec=mediacodec).
Note: On win32, if a desktop wallpaper transition happens (like setting a desktop slideshow of multiple images in Windows settings) and an ID value 0 is used, Windows may sometimes destroy the window mpv is attached to. ๐ญ mpv will just treat this as a quit signal in this case. To prevent this from happening, set a static desktop wallpaper โ a single image or pure color. fr fr, do it.
--window-dragging=<yes|no>โ Move the window when you click on it and move the mouse pointer (default:yes). Drag it like it owes you money ๐ซถ--x11-name=<string>โ Set the window instance name for X11-based video output methods.--x11-netwm=<yes|no|auto>โ (X11 only) Control the use of NetWM protocol features.
This may or may not help with broken window managers. It provides some functionality that was implemented by the now removed --fstype option. Actually, the devs don't even know to which degree this option was needed, so feedback is welcome โ they're literally asking, tell them ๐
Specifically, yes will force use of NetWM fullscreen support, even if it's 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. โ ๏ธ
--x11-bypass-compositor=<yes|no|fs-only|never>โ If set toyes, then ask the compositor to unredirect the mpv window (default:fs-only). This uses the_NET_WM_BYPASS_COMPOSITORhint.
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. periodt.
--x11-present=<no|auto|yes>โ Whether or not to use presentation statistics from X11's presentation extension (default:auto).
mpv asks X11 for present events which it then may use for more accurate frame presentation. This only has an effect if --video-sync=display-... is being used.
The auto option enumerates XRandr providers for autodetection. If amd, radeon, intel, or nouveau (the standard x86 Mesa drivers) is found, presentation feedback is enabled. Other drivers are not assumed to work, so they are not enabled automatically.
yes or no can still be passed regardless to enable/disable this mechanism in case there is good/bad behavior with whatever your combination of hardware/drivers/etc. happens to be. โจ
--x11-wid-title=<yes|no>โ Whether or not to set the window title when mpv is embedded on X11 (default:no).
๐ฟ Disc Devices ๐ฟ
--cdda-device=<path>โ Specify the CD device for CDDA playback. The default device path depends on the OS. See the OPTICAL DRIVES section. ๐--dvd-device=<path>โ Specify the DVD device or.isofilename. You can also specify a directory that contains files previously copied directly from a DVD (with e.g.vobcopy). The default device path depends on the OS. See the OPTICAL DRIVES section.
Example
mpv dvd:// --dvd-device=/path/to/dvd/
--bluray-device=<path>โ Specify the Blu-ray disc location. Must be a directory with Blu-ray structure. The default device path depends on the OS. See the OPTICAL DRIVES section.
Example
mpv bd:// --bluray-device=/path/to/bd/
--cdda-...โ These options can be used to tune the CD Audio reading feature of mpv. the little CD corner of mpv, we stan--cdda-speed=<value>โ Set CD spin speed. ๐--cdda-paranoia=<0-2>โ Set paranoia level. Values other than0seem to break playback of anything but the first track. ๐จ0โ disable checking (default)1โ overlap checking only2โ full data correction and verification
--cdda-sector-size=<value>โ Set atomic read size.--cdda-overlap=<value>โ Force minimum overlap search during verification to<value>sectors.--cdda-toc-offset=<value>โ Add<value>sectors to the values reported when addressing tracks. May be negative.--cdda-skip=<yes|no>โ (Never) accept imperfect data reconstruction.--cdda-cdtext=<yes|no>โ Print CD text. This is disabled by default, because it ruins performance with CD-ROM drives for unknown reasons. mystery behavior, honestly on brand--dvd-speed=<speed>โ Try to limit DVD speed (default:0, no change). DVD base speed is1385kB/s, so an 8x drive can read at speeds up to11080kB/s. Slower speeds make the drive more quiet. For watching DVDs,2700kB/s should be quiet and fast enough. mpv resets the speed to the drive default value on close. Values of at least100mean speed in kB/s. Values less than100mean multiples of1385kB/s, i.e.--dvd-speed=8selects11080kB/s.
Note: You need write access to the DVD device to change the speed. ๐
--dvd-angle=<ID>โ Some DVDs contain scenes that can be viewed from multiple angles. This option tells mpv which angle to use (default:1).--bluray-angle=<ID>โ Some Blu-ray discs contain scenes that can be viewed from multiple angles. This option tells mpv which angle to use (default:1). pick your angle, main character ๐
๐ Equalizer ๐
--brightness=<-100-100>โ Adjust the brightness of the video signal (default:0). Not supported by all video output drivers.--contrast=<-100-100>โ Adjust the contrast of the video signal (default:0). Not supported by all video output drivers.--saturation=<-100-100>โ Adjust the saturation of the video signal (default:0). You can get grayscale output with this option. Not supported by all video output drivers.--gamma=<-100-100>โ Adjust the gamma of the video signal (default:0). Not supported by all video output drivers.--hue=<-100-100>โ Adjust the hue of the video signal (default:0). You can get a colored negative of the image with this option. Not supported by all video output drivers. ๐ฆ
๐ฆ Demuxer ๐ฆ
--demuxer=<[+]name>โ Force demuxer type. Use a'+'before the name to force it; this will skip some checks. Give the demuxer name as printed by--demuxer=help.--demuxer-lavf-analyzeduration=<value>โ Maximum length in seconds to analyze the stream properties.--demuxer-lavf-probe-info=<yes|no|auto|nostreams>โ Whether to probe stream information (default:auto). Technically, this controls whether libavformat'savformat_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).
--demuxer-lavf-probescore=<1-100>โ Minimum required libavformat probe score. Lower values will require less data to be loaded (makes streams start faster), but makes file format detection less reliable. Can be used to force auto-detected libavformat demuxers, even if libavformat considers the detection not reliable enough. (Default:26.)--demuxer-lavf-allow-mimetype=<yes|no>โ Allow deriving the format from the HTTP MIME type (default:yes). Set this tonoin case playing things from HTTP mysteriously fails, even though the same files work from local disk. mystery fail = set it to no, bestie
This is default in order to reduce latency when opening HTTP streams.
--demuxer-lavf-format=<name>โ Force a specific libavformat demuxer.--demuxer-lavf-hacks=<yes|no>โ By default, some formats will be handled differently from other formats by explicitly checking for them. Most of these compensate for weird or imperfect behavior from libavformat demuxers. Passingnodisables these. For debugging and testing only. ๐งช--demuxer-lavf-o=<key>=<value>[,<key>=<value>[,...]]โ 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
--demuxer-lavf-probesize=<value>โ Maximum amount of data to probe during the detection phase. In the case of MPEG-TS this value identifies the maximum number of TS packets to scan.--demuxer-lavf-buffersize=<value>โ how big the stream read buffer is that we hand to libavformat, in bytes (default:32768). Want lower latency? Shrinking this could do it. โ ๏ธ caveat though: libavformat might just reallocate the buffer internally on its own, or not even fully use all of it. So like, it's a suggestion, not a promise. ๐--demuxer-lavf-linearize-timestamps=<yes|no|auto>โ try to smooth out timestamp resets in demuxed streams (default:auto). Bestie, be aware: this was only ever tested on single audio streams. Whether it behaves for video is unknown โ and probably it won't. Also, heads up, the implementation is slightly incorrect either way, and it'll introduce a discontinuity of about 1 codec frame size. ๐ญ
The auto mode turns this on for OGG audio streams, which covers that super common and super annoying case of OGG web radio streams. Some of them reset timestamps to 0 every single time a new song starts, which breaks mpv's seekable cache โ and the cache literally cannot deal with timestamp resets. Note that FFmpeg/libavformat's seeking API can't handle this either. It's likely that if you enable this option it breaks that even more, while if you disable it you can at least seek within the first song in the stream. And honestly, if the seek lands outside of mpv's cache, you're not getting anything useful either way. ๐
--demuxer-lavf-propagate-opts=<yes|no>โ pass FFmpeg-level options down to recursively opened connections (default:yes). This is needed because FFmpeg will apply these settings to nested AVIO contexts automatically, all on its own. On the other hand it could break in certain situations โ it's the FFmpeg API, you just can't win. ๐
This affects in particular the --timeout option and anything you passed with --demuxer-lavf-o.
If this option is ever deemed unnecessary in the future, it'll be removed without notice. So don't get too attached.
--demuxer-mkv-subtitle-preroll=<yes|index|no>โ try harder to show embedded soft subtitles when you seek somewhere. Normally the subtitle at the seek target just... doesn't show up, because of how some container file formats are designed. Subtitles only appear if you seek before or exactly to the position where a subtitle first appears. And to make it worse, subtitles are often timed to appear a tiny amount before the associated video frame โ so seeking to the video frame typically doesn't demux the subtitle at that position. Rude. ๐ค
Turning this on makes the demuxer start reading data a bit before the seek target so the subtitles show up correctly. But ngl, it makes seeking slower, and it's 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; this option only changes behavior with relative or imprecise seeks.
You can use --demuxer-mkv-subtitle-preroll-secs to say how much data the demuxer is allowed to pre-read at most, hunting for subtitle packets that may overlap. Set it to 0 and you've effectively disabled the preroll mechanism. Set it very large and seeking gets very slow โ an extremely large value would completely reread the whole file from start to seek target on every single seek, and seeking can get slower and 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 ones muxed with newer mkvmerge versions, have info embedded that can determine which subtitle packets overlap with a seek target. In those cases mpv reduces the amount of data read to a minimum. (It'll still read all data between the cluster containing the first wanted subtitle packet and the seek target, though.) If you pick the index choice โ which is the default โ then prerolling only happens if that info is actually available. When that method is used, the max 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 one is higher).
See also --hr-seek-demuxer-offset. That option can achieve a similar effect, but only if hr-seek is active. It works with any demuxer, but it makes seeking much slower, since it has to decode audio and video data instead of just skipping over it. ๐
--demuxer-mkv-subtitle-preroll-secs=<value>โ see--demuxer-mkv-subtitle-preroll.--demuxer-mkv-subtitle-preroll-secs-index=<value>โ see--demuxer-mkv-subtitle-preroll.--demuxer-mkv-probe-start-time=<yes|no>โ check the start time of Matroska files (default:yes). It literally just reads the first cluster timestamps and assumes that's the start time. Technically it also reads the first timestamp, which may bump latency up by one frame โ and that can actually matter for live streams. ๐--demuxer-mkv-probe-video-duration=<yes|no|full>โ when opening the file, seek to the end of it, check what timestamp the last video packet has, and report that as the file duration. This is strictly for compatibility with Haali only. In this mode opening might be slower (especially over http), or behavior with broken files might be much worse. So don't use this option. fr fr.
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 when there's no index present (like with partial files).
--demuxer-mkv-crop-compat=<yes|no>โ enable compatibility mode for files that don't fully comply with the Matroska specification (default:yes). ๐ซถ
Most files containing cropping metadata need this mode to display correctly.
With this enabled, crop metadata gets applied before the video's aspect ratio is calculated, making sure it's cropped accordingly. With it disabled, the image gets cropped first and then stretched to match DisplayWidth and DisplayHeight.
Per the Matroska specification, the Pixel Aspect Ratio (PAR) should be calculated after cropping. But the majority of files do not adhere to this rule, since doing so would cause incompatibility with crop-unaware players. Plus MKVToolNix doesn't automatically adjust DisplayWidth and DisplayHeight when cropping metadata is applied โ so most files created with it also fail to conform to the spec. Iconic behaviour, honestly. ๐
See for more details: <https://github.com/ietf-wg-cellar/matroska-specification/pull/947> <https://gitlab.com/mbunkus/mkvtoolnix/-/issues/2389> <https://github.com/mpv-player/mpv/pull/13446>
--demuxer-rawaudio-channels=<value>โ number of channels (or channel layout) if--demuxer=rawaudiois used (default:stereo).--demuxer-rawaudio-format=<value>โ sample format for--demuxer=rawaudio(default:s16le). Use--demuxer-rawaudio-format=helpto get a list of all the formats. ๐--demuxer-rawaudio-rate=<value>โ sample rate for--demuxer=rawaudio(default:44 kHz).--demuxer-rawvideo-fps=<value>โ rate in frames per second for--demuxer=rawvideo(default:25.0).--demuxer-rawvideo-w=<value>,--demuxer-rawvideo-h=<value>โ 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
--demuxer-rawvideo-format=<value>โ color space (fourcc) in hex or string for--demuxer=rawvideo(default:YV12).--demuxer-rawvideo-mp-format=<value>โ color space by internal video format for--demuxer=rawvideo. Use--demuxer-rawvideo-mp-format=helpfor a list of possible formats.--demuxer-rawvideo-codec=<value>โ set the video codec instead of selecting the rawvideo codec when using--demuxer=rawvideo. It uses the same values as codec names in--vd(but it does not accept decoder names).--demuxer-rawvideo-size=<value>โ frame size in bytes when using--demuxer=rawvideo.
--demuxer-max-bytes=<bytesize>โ this controls how much the demuxer is allowed to buffer ahead. Normally the demuxer tries to read ahead as much as necessary, or as much as--demuxer-readahead-secsasks for. This option lets you cap the maximum readahead, which limits excessive readahead when you've got broken files or desynced playback. The demuxer stops reading additional packets the moment one of the limits is hit. (The limits still can be slightly overstepped for technical reasons โ it's not that precise.)
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. โจ
--demuxer-max-back-bytes=<bytesize>โ this controls how much past data the demuxer is allowed to preserve. Only useful if the cache is enabled.
Unlike the forward cache, there's no control over how many seconds actually get cached โ it'll simply use as much memory as this option allows. Setting this to 0 strictly disables any back buffer, but that leads to a situation where the forward seek range starts after the current playback position (because 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, or --demuxer-donate-buffer is set to no. This still limits 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. Not me getting the short end of the stick ๐)
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. That's your bestie for checking what the actual numbers are, iykyk.
--demuxer-donate-buffer=<yes|no>โ do we let the back buffer nibble on part of the forward buffer? Default isyes, and honestly it's giving generous. โจ If you set it toyes, that "donation" behavior from the--demuxer-max-back-bytesdescription kicks in โ meaning the back buffer can gobble up memory up to the sum of the forward and back buffer options, minus the active size of the forward buffer. If you set it tono, the options strictly limit the forward and back buffer sizes separately, no sharing, no crossover, periodt.
Heads up: if the end of the file is reached, the buffered data stays the same, even if you seek back within the cache. Why? Because the back buffer is only reduced when new data is read. That's just how it is bestie. ๐ญ
--demuxer-seekable-cache=<yes|no|auto>โ a debugging option controlling whether seeking can use the demuxer cache (default:auto). Normally you literally never need to touch this; the defaultautodoes the right thing and enables cache seeking if--cacheis set toyes(or is impliedyesif--cache=auto). It's giving hands-off. ๐ If enabled, short seek offsets will not trigger a low level demuxer seek โ which means, for example, slow network round trips or FFmpeg seek bugs can be avoided. Slay. If a seek can't happen within the cached range, a low level seek gets triggered instead. 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. ๐ The special valueautomeansyesin the same situation as--cache-secsis used (i.e. when the stream appears to be a network stream or the stream cache is enabled).--demuxer-thread=<yes|no>โ run the demuxer in a separate thread and let it prefetch a certain amount of packets (default:yes). Having this on leads to smoother playback, enables features like prefetching, and prevents a stuck network from freezing the whole 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. Like, fr fr, leave it alone. ๐
--demuxer-termination-timeout=<seconds>โ how many seconds the player should wait to shut down 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. No mercy.--demuxer-readahead-secs=<seconds>โ if--demuxer-threadis 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 enabling the cache (such as--cache=yes, or if the input is considered a network stream and--cache=autois used) makes this option mostly ignored. (--cache-secswill override this. Technically, the maximum of both options is used.) The main purpose of this option is to limit the readahead for local playback, since a large readahead value is not overly useful in this case. (This value tends to be fuzzy, because many file formats don't store linear timestamps. It's giving vibes-based. ๐ซ๏ธ)--demuxer-hysteresis-secs=<seconds>โ once the demuxer limit is reached (--demuxer-max-bytes,--demuxer-readahead-secsor--cache-secs), this value can be used to specify a hysteresis before the demuxer will buffer ahead again. This specifies the maximum number of seconds from the current playback position that needs to be remaining in the cache before the demuxer will continue buffering ahead. ๐ธ For example, with a value of 10 seconds specified, the demuxer will buffer ahead up to the demuxer limit and won't start buffering ahead again until there is only 10 seconds of content left in the cache. This can provide significant power savings and reduce load by making the demuxer only buffer ahead in chunks at a time rather than buffering ahead nonstop to keep the cache filled. Eco queen behavior honestly. ๐ If you want to save power and reduce load, configure this to a small number that's much lower than--cache-secsor--demuxer-readahead-secs. If it takes a long time to buffer anything at all for a given stream (like when reading from a very slow disk is involved), then the hysteresis value should be larger to compensate. The default value is0seconds, which disables the caching hysteresis. A value of10seconds probably works well for most usecases. โญ--prefetch-playlist=<yes|no>โ prefetch the 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. Sorry bestie, that's just the tea. โ This does not affect HLS streams (.m3u8URLs). Such a stream by itself is internally a playlist of data segments, but is treated as a single media item by mpv. HLS prefetching depends on the demuxer cache settings and is on by default. 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. ๐--force-seekable=<yes|no>โ if the player thinks that the media is not seekable (e.g. playing from a pipe, or it's an http stream with a server that doesn't support range requests), seeking will be disabled. This option can forcibly enable it. For seeks within the cache, there's a good chance of success. ๐ฅ--demuxer-cache-wait=<yes|no>โ before starting playback, read data until either the end of the file was reached, or the demuxer cache has reached maximum capacity. Only once this is done does playback start. This intentionally happens before the initial seek triggered with--start. This does not change any runtime behavior after the initial caching. This option is useless if the file cannot be cached completely. ๐--rar-list-all-volumes=<yes|no>โ 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.rarfile 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. Not me calling out libarchive but here we are. ๐--directory-mode=<auto|lazy|recursive|ignore>โ when opening a directory, open subdirectories lazily, recursively or not at all. The default isauto, which behaves likerecursivewith--shuffle, and likelazyotherwise. ๐--directory-filter-types=<video,audio,image,archive,playlist>โ media file types to filter when opening a directory. If the list is empty, all files are added to the playlist. (Default:video,audio,image,archive,playlist) ๐ This is a string list option. See List Options for details.--autocreate-playlist=<no|filter|same>โ when opening a local file, act as if the parent directory is opened and create a playlist automatically. ๐noโ load a single file (default).filterโ create a playlist from the parent directory with files matching--directory-filter-types.sameโ create a playlist from the parent directory with files matching the same category as the currently loaded file. One of the*-extsis selected based on the input file and only files with matching extensions are added to the playlist. If the input file itself is not matched to any extension list, the playlist is not autogenerated.
โจ Input โจ
--native-keyrepeat=<yes|no>โ use system settings for keyrepeat delay and rate, instead of--input-ar-delayand--input-ar-rate(default:no). Whether this applies depends on the VO backend and how it handles keyboard input. Does not apply to terminal input. ๐ง--native-touch=<yes|no>โ (Windows only) for platforms which send emulated mouse inputs for touch-unaware clients, such as Windows, use system native touch events, instead of receiving them as emulated mouse events (default:no). This is required for multi-touch support for these platforms. ๐ซถ Note that this option has no effect on other platforms: either native touch is not supported by mpv, or the platform does not give an option to receive emulated mouse inputs (so native touch is always enabled, e.g. Wayland).--input-ar-delayโ delay in milliseconds before we start to autorepeat a key (default:200). Set it to0to disable. โฑ๏ธ--input-ar-rateโ number of key presses to generate per second on autorepeat (default:40).--input-conf=<filename>โ specify an input configuration file other than the default location in the mpv configuration directory (usually~/.config/mpv/input.conf). ๐ธ--input-default-bindings=<yes|no>โ turns on the default-level ("weak") key bindings (default:yes). These are the bindings that config files likeinput.confcan override, so they're like... the soft-launch of keybindings, bestie. Right now it affects the builtin key bindings, plus keys that scripts bind usingmp.add_key_bindingโ but notmp.add_forced_key_binding, because that one overridesinput.confand is giving main character energy. ๐--input-builtin-bindings=<yes|no>โ enable loading of built-in key bindings during start-up (default:yes). This option only applies during (lib)mpv initialization, and if you disable it, it will not be possible to enable them later. May be useful to libmpv clients. ๐ซถ--input-builtin-dragging=<yes|no>โ enable the built-in window-dragging behavior (default:yes). Setting it tonodisables the built-in dragging behavior. Note that unlike thewindow-draggingoption, this option only affects VOs which support thebegin-vo-draggingcommand, and does not disable window dragging initialized with the command. so specific, so iconic โจ--input-cmdlistโ prints all commands that can be bound to keys. That's it. That's the whole vibe. ๐--input-commands=<cmd1,cmd2,...>โ define a list of commands for mpv to run. The syntax is the same format asinput.confbut without the key binding argument at the beginning. When this option is set at startup, the commands will run after audio and video playback are about to begin if applicable (in idle mode with no file, it will run immediately). When changing values at runtime, the commands will also run as soon as possible. It's a string list option โ see List Options for details.- Example
--input-commands="playlist-play-index 1,set ao-volume 40"
That sets the playlist index to 1 and the ao-volume to 40. two birds, one flag, periodt. ๐ฆ
--input-doubleclick-time=<milliseconds>โ time in milliseconds to recognize two consecutive button presses as a double-click (default:300). click click, we love a quick double tap ๐--input-keylistโ prints all keys that can be bound to commands. yes bestie, the other half of--input-cmdlist, they're a duo ๐--input-key-fifo-size=<2-65000>โ specify the size of the FIFO that buffers key events (default:7). If it is too small, some events may be lost. ๐ญ The main disadvantage of setting it to a very large value is that if you hold down a key triggering some particularly slow command, then the player may be unresponsive while it processes all the queued commands. so like, don't max it out unless you want a laggy lil guy--input-testโ input test mode. Instead of executing commands on key presses, mpv will show the keys and the bound commands on the OSD. Has to be used with a dummy video, and the normal ways to quit the player will not work (key bindings that normally quit will be shown on OSD only, just like any other binding). SeeINPUT.CONF. lowkey a fun lil sandbox ๐ง--input-terminal=<yes|no>โ--input-terminal=noprevents the player from reading key events from standard input. Useful when reading data from standard input. This is automatically enabled when-is found on the command line. There are situations where you have to set it manually, e.g. if you open/dev/stdin(or the equivalent on your system), use stdin in a playlist, or intend to read from stdin later on via theloadfileorloadlistinput commands. ๐ฅ--input-ipc-server=<filename>โ 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. sockets?? named pipes?? she's fluent in both, no cap ๐
--input-ipc-client=fd://<N>โ connect a single IPC client to the given FD. This is somewhat similar to--input-ipc-server, except no socket is created, and instead the passed FD is treated like a socket connection received fromaccept(). In practice, you could pass either a FD created bysocketpair(), or a pipe. In both cases, you must make sure that the FD is actually inherited by mpv (do not set thePOSIX CLOEXECflag).
The player quits when the connection is closed.
This is somewhat similar to the removed --input-file option, except it supports only integer FDs, and cannot open actual paths.
- Example
--input-ipc-client=fd://123
Note: To use this option on Windows, the fd must refer to a wrapped (created by _open_osfhandle) named pipe server handle with a client already connected. The named pipe must be created duplex with overlapped IO and inheritable handles. The program communicates with mpv through the client handle.
Warning: Writing to theinput-ipc-serveroption at runtime will start another instance of an IPC client handler for theinput-ipc-clientoption, because initialization is bundled, and this thing is stupid. This is a bug. Writing toinput-ipc-clientat runtime will start another IPC client handler for the new value, without stopping the old one, even if the FD value is the same (but the string is different e.g. due to whitespace). This is not a bug. ๐
--input-gamepad=<yes|no>โ enable/disable SDL2 Gamepad support. Disabled by default. ๐ฎ--input-cursor=<yes|no>โ permit mpv to receive pointer events reported by the video output driver. Necessary to use the OSC. Support depends on the VO in use. ๐ฑ๏ธโจ--input-cursor-passthrough=<yes|no>โ tell the backend windowing system to allow pointer events to passthrough the mpv window. This allows windows under mpv to instead receive pointer events as if the mpv window was never there. invisible window era, we love to see it ๐ซฅ--input-media-keys=<yes|no>โ on systems where mpv can choose between receiving media keys or letting the system handle them, this option controls whether mpv should receive them.
Default: yes (except for libmpv). macOS and Windows only, because elsewhere mpv doesn't have a choice โ the system decides whether to send media keys to mpv. For instance, on X11 or Wayland, system-wide media keys are not implemented. Whether media keys work when the mpv window is focused is implementation-defined. โฏ๏ธ
--input-preprocess-wheel=<yes|no>โ preprocessWHEEL_*events so that while scrolling on the horizontal or vertical direction, the events aren't generated for another direction even when the two directions are scrolled together (default:yes).
This preprocessing can be beneficial for preventing accidentally seeking while changing the volume by scrolling on a touchpad with the default keybind. Due to the deadzone mechanism used, disabling the preprocessing allows for diagonal scrolling (such as panning) and potentially reduces input latency.
Note that disabling the preprocessing does not affect any filtering done by the OS/driver before these events are delivered to mpv, if any. ๐
--input-right-alt-gr=<yes|no>โ (macOS and Windows only) Use the right Alt key as Alt Gr to produce special characters. If disabled, count the right Alt as an Alt modifier key. Enabled by default.--input-vo-keyboard=<yes|no>โ 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. ๐
--input-touch-emulate-mouse=<yes|no>โ When multi-touch support is enabled (either required by the platform, or enabled by--native-touch), emulate mouse move and button presses for the touch events (default:yes). This is useful for compatibility for mouse key bindings and scripts which read mouse positions for platforms which do not support--native-touch=no(e.g. Wayland). ๐๐ฑ๏ธ--input-tablet-emulate-mouse=<yes|no>โ Emulate mouse move and button presses for tablet events (default:yes).
Wayland only. โ๏ธ
--input-dragging-deadzone=<N>โ Begin the built-in window dragging when the mouse moves outside a deadzone ofNpixels while the mouse button is being held down (default:3). This only affects VOs which support thebegin-vo-draggingcommand. ๐ซณ--input-ime=<yes|no>โ Enable keyboard input via an active input method (IME) connected to the VO. (default:no). The input popup window, if there is any, is always positioned at the top left of the window. Whether pre-edit text is drawn depends on the platform. You may need to configure your IME to display the pre-edit inside of the input popup window if you cannot read the pre-edit text in the mpv window. ๐ธ
Wayland and Windows only. This option is not applicable to terminal input.
Note: Enabling IME can cause problems with key bindings, because mpv cannot detect any key presses when they go into the IME pre-edit area. It is recommended to enable IME on demand only for the duration while text input is expected.
The builtin console and input selector enable IME for the duration of accepting text input. โจ๏ธ๐
โจ OSD โจ
ok so the OSD is the On-Screen Display, aka all the little text and bars that float over your video, and bestie there are so many knobs to twiddle. let's go ๐
--osc=<yes|no>โ do we load the on-screen-controller or not? (default: yes). it's giving remote-control energy.--osd-bar=<yes|no>โ turn the OSD bar display on or off (default: yes).
you can set this per-command in input.conf using osd- prefixes, peek at Input Command Prefixes for that. and if you want the OSD fully gone, use --osd-level=0 instead, no cap.
--osd-on-seek=<no,bar,msg,msg-bar>โ what shows up on the OSD while you're seeking. default is bar ๐
same deal, per-command config in input.conf via osd- prefixes, see Input Command Prefixes.
--osd-duration=<time>โ how long OSD messages hang around, in ms (default: 1000).--osd-font=<name>โ the font for the OSD. default is sans-serif.
Examples
--osd-font='Bitstream Vera Sans'--osd-font='Comic Sans MS'(a bold choice, we support it ๐)
--osd-font-size=<size>โ OSD font size. deets live in--sub-font-size.
Default: 30
--osd-msg1=<string>โ shows this string as a message on the OSD at OSD level 1 (visible by default). it's visible by default, and stays that way as long as nothing else covers it and you don't change the OSD level (see--osd-level). it expands properties, check Property Expansion. โจ--osd-msg2=<string>โ same vibe as--osd-msg1but for OSD level 2. if it's an empty string (the default), you get the playback time instead.--osd-msg3=<string>โ again like--osd-msg1but for OSD level 3. empty string (default) means you get playback time, duration, and a lil extra info.
this is what powers the show-progress command (mapped to P by default), and what shows when seeking if you enabled it with --osd-on-seek or with osd- prefixes in input.conf (see Input Command Prefixes).
fun fact: --osd-status-msg is the legacy equivalent (with one tiny difference, keep reading).
--osd-status-msg=<string>โ show a custom string during playback instead of the standard status text. this overrides the status text used for--osd-level=3, when you use theshow-progresscommand (mapped toPby default), and when seeking if enabled with--osd-on-seekorosd-prefixes ininput.conf(see Input Command Prefixes). expands properties, see Property Expansion.
โ ๏ธ this option got replaced by--osd-msg3. the only difference: this one implicitly includes${osd-sym-cc}. and it's ignored if--osd-msg3isn't empty. lowkey deprecated, bestie.
--osd-playing-msg=<string>โ pop a message on the OSD when playback starts. the string expands for properties, so like--osd-playing-msg='file: ${filename}'shows the messagefile:then a space then the currently playing filename. ๐ฌ
See Property Expansion.
--osd-playing-msg-duration=<time>โ sets how longosd-playing-msgsticks around, in ms. if it's unset,osd-playing-msgjust stays for the duration ofosd-durationinstead.--osd-playlist-entry=<title|filename|both>โ show the media title, the filename, or both. if the media-title isn't available, it only shows the filename.
Default: title.
--osd-bar-align-x=<-1-1>โ position of the OSD bar.-1is far left,0is centered,1is far right. fractional values (like0.5) are allowed, slay.--osd-bar-align-y=<-1-1>โ position of the OSD bar.-1is top,0is centered,1is bottom. fractional values (like0.5) are allowed.--osd-bar-w=<1-100>โ width of the OSD bar as a percentage of screen width (default: 75). a value of50means the bar is half the screen wide. math ate ๐--osd-bar-h=<0.1-50>โ height of the OSD bar as a percentage of screen height (default: 3.125).--osd-bar-outline-size=<size>โ size of the OSD bar outline in scaled pixels (see--sub-font-sizefor details).
heads up: --osd-bar-border-size is an alias for --osd-bar-outline-size.
Default: 0.5.
--osd-bar-marker-scale=<0-100>โ factor for the OSD bar marker size, relative to the OSD bar outline size.
Default: 1.3.
--osd-bar-marker-min-size=<size>โ minimum OSD bar marker size.
Default: 1.6.
--osd-bar-marker-style=<none|triangle|line>โ the OSD bar marker style.noneโ don't draw markers.triangleโ draw markers as triangles (default).lineโ draw markers as lines.
--osd-blur=<0..20.0>โ Gaussian blur factor applied to the OSD font border.0means no blur (that's the default). soft-focus aesthetic โจ--osd-bold=<yes|no>โ format text bold.--osd-italic=<yes|no>โ format text italic.--osd-outline-color=<color>โ see--sub-color. the color used for the OSD font outline.
also: --osd-border-color is an alias for --osd-outline-color.
--osd-back-color=<color>โ see--sub-color. the color used for OSD text background.
also: --osd-shadow-color is an alias for --osd-back-color.
--osd-outline-size=<size>โ size of the OSD font outline in scaled pixels (see--sub-font-sizefor details). a value of0disables outlines entirely.
also: --osd-border-size is an alias for --osd-outline-size.
Default: 1.65
--osd-border-style=<outline-and-shadow|opaque-box|background-box>โ see--sub-border-style. the style used for the OSD text border.--osd-color=<color>โ the color used for the OSD. see--sub-colorfor details. ๐--osd-selected-color=<color>โ the color of the selected item in lists. see--sub-colorfor details.--osd-selected-outline-color=<color>โ the outline color of the selected item in lists. see--sub-colorfor details.--osd-fractionsโ show OSD times with fractions of seconds (millisecond precision). obsessed, it's genuinely useful for seeing the exact timestamp of a video frame. ๐ฅ--osd-level=<0-3>โ which mode the OSD starts in.0โ OSD completely disabled (subtitles only)1โ enabled (shows up only on user interaction)2โ enabled + current time visible by default3โ enabled +--osd-status-msg(current time and status by default)
--osd-margin-x=<size>โ left and right screen margin for the OSD, in scaled pixels (see--sub-font-sizefor details).
this sets how far the OSD is from the left, and also how far from the right border long OSD text gets broken.
Default: 16
--osd-margin-y=<size>โ top and bottom screen margin for the OSD, in scaled pixels (see--sub-font-sizefor details).
this one's the vertical margins of the OSD.
Default: 16
--osd-align-x=<left|center|right>โ which corner of the screen the OSD aligns to (default: left).--osd-align-y=<top|center|bottom>โ vertical position (default: top). deets in--osd-align-x.--osd-scale=<factor>โ OSD font size multiplier, multiplied with the--osd-font-sizevalue.--osd-scale-by-window=<yes|no>โ scale the OSD with the window size? (default: yes). if you disable this,--osd-font-sizeand every other OSD option using scaled pixels are always in actual pixels. the effect is that resizing the window won't change the OSD font size at all.
๐ Note: for scripts that draw user interface elements, it's recommended to respect the value of this option when deciding whether the elements scale with window size or not. be a good citizen, bestie.
--osd-shadow-offset=<size>โ displacement of the OSD shadow in scaled pixels (see--sub-font-sizefor details). a value of0disables shadows.
Default: 0.
--osd-spacing=<size>โ horizontal OSD/sub font spacing in scaled pixels (see--sub-font-sizefor details). this value gets added to the normal letter spacing. negative values are allowed.
Default: 0.
--video-osd=<yes|no>โ enable OSD rendering on the video window (default: yes). this exists for situations where you'd rather have terminal OSD. if you just want to kill 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 --osc=no.
โ ๏ธ this option is somewhat experimental and could get replaced by another mechanism in the future. watch this space ๐ซถ
--osd-font-provider=<...>โ see--sub-font-providerfor details and accepted values. note that unlike subtitles, the OSD never uses embedded fonts from media files. periodt.--osd-fonts-dir=<path>โ see--sub-fonts-dirfor details. defaults to~~/fonts.--osd-glyph-limit=<value>โ max number of cached glyphs in the libass cache for the OSD.0means libass uses its own default value.
Default: 0.
--osd-bitmap-max-size=<value>โ max bitmap cache size in the libass cache for the OSD.0means libass uses its default. this one accepts values in MB.
Default: 0.
--osd-prune-delay=<-1|seconds>โ delay for automatic pruning of events from memory in libass. disabled by default. see also--sub-ass-prune-delay. ๐งน--osd-shaper=<simple|complex>โ the text layout engine libass uses for the OSD. Default: complex. see also--sub-shaper.
๐ธ Screenshot ๐ธ
--screenshot-format=<type>โ the image file type used for saving screenshots.
available choices:
pngโ PNGjpgโ JPEG (default)jpegโ JPEG (alias forjpg)webpโ WebPjxlโ JPEG XLavifโ AVIF
--screenshot-tag-colorspace=<yes|no>โ tag screenshots with the appropriate colorspace (default: yes).
๐ note that not every format supports this. when it's unsupported, or when you've disabled this option, screenshots get converted to sRGB before being written. no cap.
--screenshot-high-bit-depth=<yes|no>โ if possible, write screenshots with a bit depth similar to the source video (default: yes). this is interesting especially for PNG, because it sometimes triggers writing 16 bit PNGs with huge file sizes. it'll also include an unused alpha channel in the resulting files if 16 bit is used. ๐ big file energy.--screenshot-template=<template>โ okay bestie this is the naming situation for your screenshots ๐ It's the filename template, no file extension, and it can hold format specifiers that get swapped in the moment you snap a shot. Default vibe ismpv-shot%n, which gives you stuff likempv-shot0012.png. iconic.
The template can start with a relative or absolute path, so you can pick exactly which directory your screenshots land in.
Heads up: if the final filename points at a file that already exists, mpv will not overwrite it. The screenshot either doesn't get saved, or โ if your template has %n in it โ it gets saved under a brand new, freshly generated filename. no cap.
Allowed format specifiers, let's get into it:
%[#][0X]nโ a sequence number, padded with zeros to length X (default:04). So passing%04ngives you0012on the 12th screenshot โจ The number increments every time a screenshot is taken, or if the file already exists. X has to be in the range 0-9. With the optional#sign, mpv uses the lowest available number โ like, if you take three screenshots0001,0002,0003and then delete the first two, the next two won't be0004and0005, they'll be0001and0002again. recycling queen ๐ธ%fโ filename of the currently played video.%Fโ same as%f, but with the file extension stripped, dot included.%xโ directory path of the currently played video. If the video isn't on the filesystem (but like,http://), this expands to an empty string.%X{fallback}โ same as%x, but if the video file isn't on the filesystem, it returns the fallback string inside the{...}.%pโ current playback time, in the same format as the OSD uses. The result looks like"HH:MM:SS". So if the video is at 5 minutes and 34 seconds,%pbecomes"00:05:34".%Pโ similar to%p, but extended with the playback time in milliseconds. Formatted as"HH:MM:SS.mmm", where"mmm"is the millisecond part of the playback time.
Note: this is a simple way of getting unique per-frame timestamps. (Frame numbers would be more intuitive, but they're not easily implementable because container formats usually use timestamps for identifying frames.)
%wXโ specify the current playback time using the format string X.%pis like%wH:%wM:%wS, and%Pis like%wH:%wM:%wS.%wT.
Valid format specifiers:
%wHโ hour (padded with 0 to two digits)%whโ hour (not padded)%wMโ minutes (00-59)%wmโ total minutes (includes hours, unlike%wM)%wSโ seconds (00-59)%wsโ total seconds (includes hours and minutes)%wfโ like%ws, but as float%wTโ milliseconds (000-999)
%tXโ specify the current local date/time using the format X. This one uses the UNIXstrftime()function internally, and inserts the result of passing"%X"tostrftime. So like,%tminserts the number of the current month. You have to use multiple%tXspecifiers to build a full date/time string, periodt.%{prop[:fallback text]}โ insert the value of the input propertyprop. E.g.%{filename}is the same as%f. If the property doesn't exist or isn't available, an error text gets inserted, unless a fallback is specified.%%โ replaced with the%character itself.
--screenshot-dir=<path>โ store screenshots in this directory ๐ This path gets joined with the filename generated by--screenshot-template. But if the template filename is already absolute, the directory is ignored, sorry babe.
--screenshot-directory is an alias for --screenshot-dir.
If the directory doesn't exist, it gets created on the first screenshot. If it's not a directory, an error is generated when trying to write a screenshot.
This option is not set by default, so screenshots go to the directory mpv was started from. In pseudo-gui mode (peep PSEUDO GUI MODE), it's set to the desktop. ๐
--screenshot-jpeg-quality=<0-100>โ set the JPEG quality level. Higher means better quality. Default is90.--screenshot-jpeg-source-chroma=<yes|no>โ write JPEG files with the same chroma subsampling as the video (default:yes). If disabled, the libjpeg default is used.--screenshot-png-compression=<0-9>โ set the PNG compression level. Higher means better compression. This affects the file size of the written screenshot AND how long it takes to write it. Too high compression might eat enough CPU time to interrupt playback ๐ญ The default is7.--screenshot-png-filter=<0-5>โ set the filter applied before PNG compression.0is none,1is"sub",2is"up",3is"average",4is"Paeth", and5is"mixed". This affects how much compression you can achieve. For most images,"mixed"gets the best compression ratio, which is why it's the default ๐--screenshot-webp-lossless=<yes|no>โ write lossless WebP files.--screenshot-webp-qualityis ignored if this is set. Default isno.--screenshot-webp-quality=<0-100>โ set the WebP quality level. Higher means better quality. Default is75.--screenshot-webp-compression=<0-6>โ set the WebP compression level. Higher means better compression, but takes more CPU time. Note that this also affects the screenshot quality when used with lossy WebP files. Default is4.--screenshot-jxl-distance=<0-15>โ set the JPEG XL Butteraugli distance. Lower means better quality. Lossless is0.0, and1.0is approximately equivalent to JPEG quality 90 for photographic content. Use0.1for "visually lossless" screenshots. The default is1.0.--screenshot-jxl-effort=<1-9>โ set the JPEG XL compression effort. Higher effort (usually) means better compression, but takes more CPU time. The default is4.--screenshot-avif-encoder=<encoder>โ specify the AV1 encoder to be used by libavcodec for encoding avif screenshots.
Default: libaom-av1
--screenshot-avif-pixfmt=<format>โ specify the pixel format for the libavcodec encoder. Defaults to empty, which lets mpv pick one close to the source format.--screenshot-avif-opts=key1=value1,key2=value2,...โ specifies libavcodec options for the selected encoder. For more info, consult the FFmpeg documentation.
Default: usage=allintra,crf=0,cpu-used=8
Note: the default is only guaranteed to work with the libaom-av1 encoder. The above options may not be valid and/or optimal for other encoders.
This is a key/value list option. See List Options for details.
Example:
"--screenshot-avif-opts=crf=23,aq-mode=complexity"
sets the crf to 23 and quantization (aq-mode) to complexity based.
--screenshot-sw=<yes|no>โ whether to use software rendering for screenshots (default:no).
If set to no, the screenshot is rendered by the current VO (only vo_gpu or vo_gpu_next currently). The advantage is that this will (probably) always show up as in the video window, because the same code is used for rendering. But since the renderer needs to be reinitialized, this can be slow and interrupt playback ๐ฌ
If set to yes, the software scaler is used to convert the video to RGB (or whatever the target screenshot requires). In this case, conversion runs in a separate thread and will probably not interrupt playback. The software renderer may lack some capabilities, like HDR rendering. If window mode is used, the image will also be scaled in software, which may not accurately reflect the actual visible result.
๐ Software Scaler ๐
--sws-scaler=<name>โ specify the software scaler algorithm to be used with--vf=scale. This also affects video output drivers that lack hardware acceleration, e.g.x11. See also--vf=scale.
To get a list of available scalers, run --sws-scaler=help.
Default: bicubic.
--sws-lgb=<0-100>โ software scaler Gaussian blur filter (luma). See--sws-scaler.--sws-cgb=<0-100>โ software scaler Gaussian blur filter (chroma). See--sws-scaler.--sws-ls=<-100-100>โ software scaler sharpen filter (luma). See--sws-scaler.--sws-cs=<-100-100>โ software scaler sharpen filter (chroma). See--sws-scaler.--sws-chs=<h>โ software scaler chroma horizontal shifting. See--sws-scaler.--sws-cvs=<v>โ software scaler chroma vertical shifting. See--sws-scaler.--sws-bitexact=<yes|no>โ unknown functionality (default:no). Consult libswscale source code ๐ซฃ As far as the libswscale API goes, the primary purpose of this is to produce exactly the same output for the same input on all platforms (output has the same "bits" everywhere, thus "bitexact"). Typically disables optimizations.--sws-fast=<yes|no>โ 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. Also see --sws-allow-zimg.
--sws-allow-zimg=<yes|no>โ allow using zimg (if the component using the internal swscale wrapper explicitly allows so) (default:yes). In this case, zimg may be used, if the internal zimg wrapper supports the input and output formats. It will silently or noisily fall back to libswscale if one of these conditions doesn't apply ๐
If zimg is doing the work, bestie, then all those other --sws- options are literally just sitting there being ignored, and the --zimg- ones take over instead. ๐
If the internal component that's riding the swscale wrapper hooks up its logging the right way, you'll get a verbose-priority log message telling you whether zimg is actually being used. iykyk.
Most things that need software conversion can use this. no cap.
Note: lowkey important โ zimg can be slower than libswscale. Usually it's faster on x86 platforms, but slower on ARM (because ARM-specific optimizations just aren't there, bestie ๐ญ). The mpv zimg wrapper uses unoptimized repacking for some formats, and for that part zimg cannot be blamed, fr fr.
--zimg-scaler=<point|bilinear|bicubic|spline16|spline36|lanczos>โ which zimg luma scaler to use (default:lanczos). โจ--zimg-scaler-param-a=<default|float>,--zimg-scaler-param-b=<default|float>โ set the scaler parameters. By default these are the special stringdefault, which maps to a scaler-specific default value. Ignored if the scaler isn't tunable. ๐lanczosโ--zimg-scaler-param-ais the number of taps.bicubicโaandbare the bicubicbandcparameters.
--zimg-scaler-chroma=...โ same as--zimg-scaler, for for chroma interpolation (default:bilinear).--zimg-scaler-chroma-param-a,--zimg-scaler-chroma-param-bโ same as--zimg-scaler-param-a/--zimg-scaler-param-b, for chroma.--zimg-dither=<no|ordered|random|error-diffusion>โ dithering (default:random).--zimg-threads=<auto|integer>โ set the max number of threads to use for scaling (default:auto).autouses the number of logical cores on the current machine. Heads up though: the scaler may use fewer threads (or even just 1 thread) depending on stuff. Passing a value of1disables threading and always scales the image in a single operation. Higher thread counts waste resources, but make it typically faster.
Note that some zimg git versions had bugs that will corrupt the output if threads are used. ๐
--zimg-fast=<yes|no>โ allow optimizations that help with performance, but reduce quality (default:yes). Currently, this may simplify gamma conversion operations.
๐ง Audio Resampler ๐ง
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). Just mpv's own thing, okay? ๐ซถ
--audio-resample-filter-size=<length>โ length of the filter with respect to the lower sampling rate. (default:16)--audio-resample-phase-shift=<count>โ log2 of the number of polyphase entries. (...,10->1024,11->2048,12->4096, ...) (default:10->1024)--audio-resample-cutoff=<cutoff>โ cutoff frequency (0.0-1.0), default set depending upon filter length.--audio-resample-linear=<yes|no>โ if set then filters will be linearly interpolated between polyphase entries. (default:no)--audio-normalize-downmix=<yes|no>โ 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, bestie โ no universal answer. ๐ 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.--audio-resample-max-output-size=<length>โ 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. ๐
--audio-swresample-o=<string>โ set AVOptions on theSwrContextorAVAudioResampleContext. These should be documented by FFmpeg. This is a key/value list option. See List Options for details.
๐ฅ๏ธ Terminal ๐ฅ๏ธ
--quietโ 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-quietand--msg-level.--really-quietโ display even less output and status messages than with--quiet. like, genuinely less.--terminal=<yes|no>โ--terminal=nodisables any use of the terminal andstdin/stdout/stderr. This completely silences any message output. Unlike--really-quiet, this disables input and terminal initialization as well. โจ--msg-color=<yes|no>โ enable colorful console output on terminals (default:yes). aesthetic matters ๐--msg-level=<module1=level1,module2=level2,...>โ control verbosity directly for each module. Theallmodule 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=traceto 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 theMPV_VERBOSEenvironment variable; see ENVIRONMENT VARIABLES for details.
Available levels:
noโ complete silence ๐คซfatalโ fatal messages onlyerrorโ error messageswarnโ warning messagesinfoโ informational messagesstatusโ status messages (default)vโ verbose messagesdebugโ debug messagestraceโ 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.
--term-osd=<auto|no|force>โ 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 activenoโ disable terminal OSDforceโ use terminal OSD even if video output active Theautomode also enables terminal OSD if--video-osd=nowas set.
--term-osd-bar=<yes|no>โ enable printing a progress bar under the status line on the terminal. (Disabled by default.)--term-osd-bar-chars=<string>โ customize the--term-osd-barfeature. 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:[-+-].--term-playing-msg=<string>โ print out a string after starting playback. The string is expanded for properties, e.g.--term-playing-msg='file: ${filename}'will print the stringfile:followed by a space and the currently played filename. See Property Expansion.--term-status-msg=<string>โ print out a custom string during playback instead of the standard status line. Expands properties. See Property Expansion.--term-title=<string>โ set the terminal title. Currently, this simply concatenates the escape sequence setting the window title with the provided (property expanded) string. This will mess up if the expanded string contain bytes that end the escape sequence, or if the terminal does not understand the sequence. The latter probably includes the regrettable win32. ๐ Expands properties. See Property Expansion.--msg-moduleโ prepend module name to each console message.--msg-timeโ prepend timing information to each console message. The time is in seconds since the player process was started (technically, slightly later actually), using a monotonic time source depending on the OS. This isCLOCK_MONOTONICon sane UNIX variants. ๐ง
๐๏ธ Cache ๐๏ธ
--cache=<yes|no|auto>โ decide whether to use network cache settings (default:auto). If enabled, use up to--cache-secsfor the cache size (but still limited to--demuxer-max-bytes), and make the cached data seekable (if possible). If disabled,--cache-pauseand related are implicitly disabled. Theautochoice enables this depending on whether the stream is thought to involve network accesses or other slow media (this is an imperfect heuristic โ just being honest โ).
Before mpv0.30.0, this used to accept a number, which specified the size of the cache in kilobytes. Use e.g.--cache --demuxer-max-bytes=123kinstead.
--cache-secs=<seconds>โ how many seconds of audio/video to prefetch if the cache is active. This overrides the--demuxer-readahead-secsoption if and only if the cache is enabled and the value is larger. The default value is set to something very high, so the actually achieved readahead will usually be limited by the value of the--demuxer-max-bytesoption. Setting this option is usually only useful for limiting readahead. โจ--cache-on-disk=<yes|no>โ 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. 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 metadata 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. okay that's a lot of cache lore but we move โจ
--demuxer-cache-dir=<path>โ the directory where the temporary files get made, bestie ๐. If you don't set this, the cache lives in the system's cache directory (usually~/.cache/mpv).
Currently, this is used for --cache-on-disk only.
--cache-pause=<yes|no>โ should the player auto-pause when the cache runs dry and stalls decoding/playback? Default isyes๐ซถ. If it's on, it'll pause and then unpause once more data shows up, aka "buffering".--cache-pause-wait=<seconds>โ how many seconds the packet cache should have buffered before playback starts again after entering "buffering" (default:1). This is your dial for how long the player rebuffers when--cache-pauseis enabled and the demuxer underruns. ngl there's a lil catch: if the time you give is higher than the max set with--cache-secsor--demuxer-readahead-secs, or if prefetching ends early for some other reason (like file end, or hitting the maximum configured cache size), then playback resumes earlier. ๐--cache-pause-initial=<yes|no>โ enter "buffering" mode before starting playback (default:no). This one's for making playback start all smooth, at the cost of waiting a bit to prefetch network data (controlled by--cache-pause-wait, obvi). Like, a super common vibe is that playback starts, but the network caches immediately underrun when it tries to decode more data as playback progresses. ๐ญ
Another thing that can happen: the network prefetching is so CPU demanding (because of demuxing in the background) that playback drops frames at first. In those cases, it helps to enable this option, and set --cache-secs and --cache-pause-wait to roughly the same value. ๐
This option also triggers when playback is restarted after seeking.
--demuxer-cache-unlink-files=<immediate|whendone|no>โ 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 ๐ง.immediateUnlink cache files right after they were created. The cache files won't be visible anymore, even though they're in use. This guarantees they're removed from disk when the player terminates, even if it crashes.whendoneDelete cache files after they are closed.noDon't delete cache files. They will consume disk space without having a use. ๐ซ
Currently, this is used for --cache-on-disk only.
--stream-buffer-size=<bytesize>โ size of the low level stream byte buffer (default:128KB). This sits as a buffer between the demuxer and low level I/O (e.g. sockets). Generally it can be very small, and the main purpose is similar to what the internal bufferFILEin the C standard library does. โจ
Half of the buffer is always used for guaranteed seek back, which is important for unseekable input.
There are known cases where setting a large buffer can help performance:
- mp4 files.
libavformatmay 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.
--vd-queue-enable=<yes|no>,--ad-queue-enableโ enable running the video/audio decoder on a separate thread (default:no). If enabled, the decoder runs on a separate thread, and a frame queue gets put between the decoder and the higher level playback logic. The size of that frame queue is defined by the other options below. ๐
This is probably quite pointless. libavcodec already has multithreaded decoding (enabled by default), which makes this largely unnecessary. It might help in some corner cases with high bandwidth video that is slow to decode (in these cases libavcodec would block the playback logic, while using a decoding thread would distribute the decoding time evenly without affecting the playback logic). In other situations, it will simply make seeking slower and use significantly more memory. ๐
The queue size is restricted by the other --vd-queue-... options. The final queue size is the minimum as indicated by the option with the lowest limit. Each decoder/track has its own queue that may use the full configured queue size.
Most queue options can be changed at runtime. --vd-queue-enable itself (and the audio equivalent) update only if decoding is completely reinitialized. However, setting --vd-queue-max-samples=1 should almost lead to the same behavior as --vd-queue-enable=no, so that value can be used for effectively runtime enabling/disabling the queue. ๐
This should not be used with hardware decoding. It is possible to enable this for audio, but it makes even less sense.
--vd-queue-max-bytes=<bytesize>,--ad-queue-max-bytesโ maximum approximate allowed size of the queue. If it's exceeded, decoding will be stopped. The maximum size can be exceeded by about 1 frame.
See --list-options for defaults and value range. <bytesize> options accept suffixes such as KiB and MiB.
--vd-queue-max-samples=<int>,--ad-queue-max-samplesโ maximum number of frames (video) or samples (audio) of the queue. The audio size may be exceeded by about 1 frame.
See --list-options for defaults and value range.
--vd-queue-max-secs=<seconds>,--ad-queue-max-secsโ maximum number of seconds of media in the queue. The special value0means no limit is set. The queue size may be exceeded by about 2 frames. Timestamp resets may lead to random queue size usage. ๐ตโ๐ซ
See --list-options for defaults and value range.
๐ Network ๐
--user-agent=<string>โ use<string>as the user agent for HTTP streaming.--cookies=<yes|no>โ support cookies when making HTTP requests. Disabled by default.--cookies-file=<filename>โ read HTTP cookies from<filename>. The file is assumed to be in Netscape format. ๐ช--http-header-fields=<field1,field2>โ set custom HTTP fields when accessing an 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
--http-proxy=<proxy>โ URL of the HTTP/HTTPS proxy. If this is set, thehttp_proxyenvironment is ignored. Theno_proxyenvironment variable is still respected. This option is silently ignored if it does not start withhttp://. Proxies are not used for https URLs. Setting this option does not try to make the ytdl script use the proxy.--tls-ca-file=<filename>โ certificate authority database file for use with TLS. (Silently fails with older FFmpeg versions.)--tls-verifyโ verify peer certificates when using TLS (e.g. withhttps://...). (Silently fails with older FFmpeg versions.) ๐--tls-cert-fileโ a file containing a certificate to use in the handshake with the peer.--tls-key-fileโ a file containing the private key for the certificate.--referrer=<string>โ specify a referrer path or URL for HTTP requests.--network-timeout=<seconds>โ specify the network timeout in seconds (default:60seconds). This affects at least HTTP. The special value0uses the FFmpeg 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. ๐
--rtsp-transport=<lavf|udp|udp_multicast|tcp|http>โ select RTSP transport method (default:tcp). This selects the underlying network transport when playingrtsp://...URLs. The valuelavfleaves the decision tolibavformat. โจ--hls-bitrate=<no|min|max|<rate>>โ okay so when you're playing HLS streams, this one decides which streams get picked by default. Bestie, the params are:noโ don't do anything special, it'll typically just grab the first audio/video streams it can find.minโ pick the streams with the lowest bitrate.maxโ same vibe, but highest bitrate. (This is the default.)
Also! If the option is a number, then the stream with the highest rate that's equal to or below your value gets selected.
Heads up: the bitrate is whatever the server says it is, and there's literally no guarantee it's actually meaningful. It's giving "trust me bro" ๐ซ
๐ DVB ๐
--dvbin-prog=<string>โ this defines the program to tune to. Usually you'd just specify it with a stream URI like"dvb://ZDF HD", but you can tune to a different channel by writing to this property at runtime. Also peepdvbin-channel-switch-offsetfor more useful channel switching functionality. ๐--dvbin-card=<0-15>โ specifies using card number0-15(default:0).--dvbin-file=<filename>โ tells mpv to read the channels list from <filename>. The default lives in the mpv configuration directory (usually~/.config/mpv) with the filenamechannels.conf.{sat,sat1,ter,ter1,cbl,atsc,isdbt}(based on your card type) orchannels.confas a last resort. For cards supporting multiple delivery systems of the same kind, i.e. DVB-T/T2 or DVB-S/S2, T2/S2 is assumed, unless the file extension ister1orsat1. Please note that using a specific file name with card type is recommended, since the legacy channel format is not fully standardized so autodetection of the delivery system may fail otherwise. For DVB-S/2 cards, a VDR 1.7.x format channel list is recommended as it allows tuning to DVB-S2 channels, enabling subtitles and decoding the PMT (which largely improves the demuxing). Classic mplayer format channel lists are still supported (without these improvements), and for other card types, only limited VDR format channel list support is implemented (patches welcome ๐). For channels with dynamic PID switching or incompletechannels.conf,--dvbin-full-transponderor the magic PID8192are recommended.--dvbin-timeout=<seconds>โ maximum number of seconds to wait when trying to tune a frequency before giving up (default:30). No waiting around forever, we're not doing that. โฐ--dvbin-full-transponder=<yes|no>โ applies no filters on program PIDs, only tunes to the frequency and passes the full transponder to the 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 thechannels.conf. It's also recommended to use this for channels which switch PIDs on-the-fly, e.g. for regional news.
Default: no
--dvbin-channel-switch-offset=<integer>โ this value is not meant for setting via configuration, it's used in channel switching. Aninput.confcan 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
โจ GPU renderer options โจ
The following video options are currently all specific to --vo=gpu, --vo=libmpv and --vo=gpu-next, which are the only VOs that implement them. Periodt. ๐
--scale=<filter>โ the filter function to use when upscaling video. The options are giving:bilinearโ bilinear hardware texture filtering (fastest, very low quality). This is the default when using thefastprofile.lanczosโ Lanczos scaling. Provides good balance between quality and performance. This is the default forscale. The number of taps can be controlled withscale-radius, but is best left unchanged.
(This filter is an alias for sinc-windowed sinc)
ewa_lanczosโ elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled withscale-radius. Increasing the radius makes the filter sharper but adds more ringing.
(This filter is an alias for jinc-windowed jinc)
ewa_lanczossharpโ a slightly sharpened version ofewa_lanczos. This is the default when using thehigh-qualityprofile. Blur value determined by method originally developed by Nicolas Robidoux for Image Magick, see: <https://www.imagemagick.org/discourse-server/viewtopic.php?p=89068#p89068>ewa_lanczos4sharpestโ very sharp scaler, but also slightly slower thanewa_lanczossharp. Prone to ringing, so it's recommended to combine this with an anti-ringing shader. On--vo=gpu-next, setting this filter enables built-in anti-ringing, so no extra action needs to be taken.
For more details, see: <https://www.imagemagick.org/discourse-server/viewtopic.php?p=128587#p128587>
mitchellโ Mitchell-Netravali. Piecewise cubic filter with a support of radius2.0. Provides a balanced compromise of all scaling artifacts. This filter has both B and C set to1/3. The B and C parameters can be controlled with--scale-param1and--scale-param2.hermiteโ Hermite spline. Similar tobicubicbut with B set to0.0. This filter has the special property of having a support of radius1.0, making it very fast in comparison, but prone to blocking. This is the default for--dscale.catmull_romโ Catmull-Rom spline. Similar tomitchell, but with B and C set to0.0and0.5respectively. This filter is sharper thanmitchell, but prone to ringing.oversampleโ a version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This can also be used for frame mixing, where it is commonly known as "smoothmotion" (see--tscale).linearโ a--tscalefilter.
There are some more filters, but most are not as useful. For a complete list, pass help as value, e.g.:
mpv --scale=help
--cscale=<filter>โ as--scale, but for interpolating chroma information. If the image is not subsampled, this option is ignored entirely. If this option is unset, the filter implied by--scalewill be applied.--dscale=<filter>โ like--scale, but apply these filters on downscaling instead. ๐ฆ--tscale=<filter>โ the filter used for interpolating the temporal axis (frames). This is only used if--interpolationis enabled. The only valid choices for--tscaleare separable convolution filters (use--tscale=helpto get a list). The default isoversample.
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.
--scale-param1=<value>,--scale-param2=<value>,--cscale-param1=<value>,--cscale-param2=<value>,--dscale-param1=<value>,--dscale-param2=<value>,--tscale-param1=<value>,--tscale-param2=<value>โ set filter parameters. By default, these are set to the special stringdefault, which maps to a scaler-specific default value. Ignored if the filter is not tunable. Currently, this affects the following filter parameters:bicubicโ spline parameters (B and C). Defaults toB=1andC=0.gaussianโ scale parameter (t). Increasing this makes the result blurrier. Defaults to1.oversampleโ minimum distance to an edge before interpolation is used. Setting this to0will always interpolate edges, whereas setting it to0.5will never interpolate, thus behaving as if the regular nearest neighbour algorithm was used. Defaults to0.0.
--scale-blur=<value>,--cscale-blur=<value>,--dscale-blur=<value>,--tscale-blur=<value>โ kernel scaling factor (also known as a blur factor). Decreasing this makes the result sharper, increasing it makes it blurrier (default0). If set to0, the kernel's preferred blur factor is used. Note that setting this too low (eg.0.5) leads to bad results. It's generally recommended to stick to values between0.8and1.2.--scale-clamp=<0.0-1.0>,--cscale-clamp,--dscale-clamp,--tscale-clampโ specifies a weight bias to multiply into negative coefficients. Specifying--scale-clamp=1has the effect of removing negative weights completely, thus effectively clamping the value range to[0-1]. Values between0.0and1.0can be specified to apply only a moderate diminishment of negative weights. This is especially useful for--tscale, where it reduces excessive ringing artifacts in the temporal domain (which typically manifest themselves as short flashes or fringes of black, mostly around moving edges) in exchange for potentially adding more blur. The default for--tscale-clampis1.0, the others default to0.0.--scale-taper=<value>,--scale-wtaper=<value>,--dscale-taper=<value>,--dscale-wtaper=<value>,--cscale-taper=<value>,--cscale-wtaper=<value>,--tscale-taper=<value>,--tscale-wtaper=<value>โ okay so this is the kernel/window taper factor โจ and basically the higher you crank it, the more flattened your filter function gets. Range is0to1. A0โ which is the default, bestie, we love a default โ means no flattening at all, and a1makes the filter completely flat (aka it's giving box function energy ๐ ). Anything in between means some chunk of it is flat and the actual filter function gets squeezed into whatever space is left over. Squished. Cozy. ๐ซถ--scale-radius=<value>,--cscale-radius=<value>,--dscale-radius=<value>,--tscale-radius=<value>โ sets the radius for tunable filters. Gotta be a float number between0.5and16.0, no exceptions ๐. If you don't specify one it defaults to the filter's preferred radius. Heads up: this does not work for every scaler and VO combo, so vibe check your setup first.
And also โ depending on filter implementation details and the video scaling ratio, the radius that actually gets used might be different (most likely increased a lil bit). So like, it's a suggestion. ๐
--scale-antiring=<value>,--cscale-antiring=<value>,--dscale-antiring=<value>,--tscale-antiring=<value>โ sets the antiringing strength โญ. The whole point is it tries to eliminate ringing, but ngl it can introduce other artifacts in the process (tradeoffs, always tradeoffs ๐ญ). Must be a float between0.0and1.0. Default is0.0, which means antiringing is fully disabled.
Note that this doesn't affect the special filters bilinear and bicubic_fast, and it doesn't affect any polar (EWA) scalers either. โ
But on --vo=gpu-next, it does also affect polar (EWA) scalers. And certain filter aliases may implicitly enable antiringing regardless of this setting (peep --scale for that ๐).
Note: when downscaling with separable (orthogonal) filters, setting--dscale-antiringto anything other than0.0(the default) will reduce scaler quality and produce aliasing artifacts. On--vo=gpu-next,--dscale-antiringis disabled for separable (orthogonal) filters. So like, don't do it, bestie. ๐
--scale-window=<window>,--cscale-window=<window>,--dscale-window=<window>,--tscale-window=<window>โ (Advanced users only ๐ง) pick a custom windowing function for the kernel. Defaults to the filter's preferred window if you don't set it. Wanna see the whole menu of supported windowing functions? Run--scale-window=helpand it'll show you the lineup โจ.--scale-wparam=<window>,--cscale-wparam=<window>,--cscale-wparam=<window>,--tscale-wparam=<window>โ (Advanced users only again ๐ง) this configures the parameter for the window function that--scale-windowetc. gives you. By default these are set to the special stringdefault, which maps to a window-specific default value. It's ignored if the window isn't tunable. Right now it affects these window parameters:kaiserโ window parameter (alpha). Defaults to6.33.blackmanโ window parameter (alpha). Defaults to0.16.gaussianโ scale parameter (t). Increasing this makes the window wider. Defaults to1.
--scaler-resizes-onlyโ disables the scaler if the video image isn't being resized. In that case,bilineargets used instead of whatever you set with--scale. And honestly? Bilinear will reproduce the source image perfectly if no scaling is happening, so it's fine. Enabled by default. Note that this option never affects--cscale. ๐--correct-downscalingโ when you're using convolution based filters, this extends the filter size when downscaling. Increases quality, but reduces performance while downscaling. Enabled by default.
It'll perform slightly sub-optimally for anamorphic video (but still better than without it, don't worry) since it extends the size to match only the milder of the scale factors between the axes.
Note: this option is ignored when using bilinear downscaling with --vo=gpu.
--linear-downscalingโ scale in linear light when downscaling ๐. It should only be used with an--fbo-formatthat has at least 16 bit precision. This option has no effect on HDR content. Enabled by default.--linear-upscalingโ scale in linear light when upscaling โจ. Just like--linear-downscaling, it should only be used with an--fbo-formatthat has at least 16 bits precision. This is not usually recommended except for testing or specific purposes. Users are advised to either enable--sigmoid-upscalingor keep both options disabled (i.e. scaling in gamma light). Pick a lane bestie ๐--sigmoid-upscalingโ when upscaling, use a sigmoidal color transform to avoid emphasizing ringing artifacts. Enabled by default. This is incompatible with and replaces--linear-upscaling. (Note that sigmoidization also requires linearization, so the LINEAR rendering step fires in both cases anyway ๐ฅ)
Wanna know more about sigmoidization? See: <https://imagemagick.org/Usage/resize/#resize_sigmoidal>
--sigmoid-centerโ the center of the sigmoid curve used for--sigmoid-upscaling. Must be a float between0.0and1.0. Defaults to0.75if you don't specify it.--sigmoid-slopeโ the slope of the sigmoid curve used for--sigmoid-upscaling. Must be a float between1.0and20.0. Defaults to6.5if you don't specify it.--interpolationโ reduces stuttering caused by mismatches between the video fps and the display refresh rate (also known as judder). Iconic fix, honestly.
Warning: this requires setting the--video-syncoption to one of thedisplay-modes, or it will be silently disabled. This was not required before mpv0.14.0. ๐ญ
Basically it attempts to interpolate the missing frames by convoluting the video along the temporal axis โณ. The filter it uses can be controlled with the --tscale setting.
--interpolation-threshold=<0..1,-1>โ threshold below which frame ratio interpolation gets disabled (default:0.01). It's calculated asabs(disphz/vfps - 1) < threshold, wherevfpsis the speed-adjusted video FPS, anddisphzis 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-resampleto make video run synchronously to the display FPS, or if you change thespeedproperty.)
The default is intended to enable interpolation in scenarios where retiming with --video-sync=display-* can't adjust the speed of the video enough for smooth playback. Example: if a video is 60.00 FPS and your display refresh rate is 59.94 Hz, interpolation will never be activated, since the mismatch is within 1% of the refresh rate. The default also handles the scenario where mpv can't determine the container FPS, like during certain live streams, and it may dynamically toggle interpolation on and off. In that scenario, the default would be to not use interpolation, but rather to let --video-sync=display-* retime the video to match the display refresh rate. Peep --video-sync-max-video-change for more on how mpv retimes video ๐.
Also note: 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 entirely.
--interpolation-preserveโ preserves the previous frames' interpolated results even when renderer parameters change โ with the exception of options related to cropping and video placement, which always invalidate the cache. Enabling this makes dynamic updates of renderer settings slightly smoother, at the cost of slightly higher latency in response to such changes. Defaults toon. (Only affects--vo=gpu-nextโ note that--vo=gpualways invalidates interpolated frames.)--opengl-pboโ enables use of PBOs โจ. On some drivers this can be faster, especially if the source video size is huge (like, so called "4K" video ๐). On other drivers it might be slower or cause latency issues. It's giving gamble, ngl.--dither-depth=<N|no|auto>โ sets the dither target depth toN. Default:auto.noโ disable any dithering done by mpv.autoโ automatic selection. On--vo=gpu: detected depth, or8bpc otherwise. On--vo=gpu-next: detected depth, or8bpc (for SDR target).8โ dither to 8 bit output.
Note that the on-the-wire bit depth cannot be detected except when using gpu-api=d3d11. Explicitly setting the value to your display's bit depth is recommended, because dithering performed by some LCD panels can be of low quality ๐.
--dither-size-fruit=<2-8>โ sets the size of the dither matrix (default:6). The actual size of the matrix is(2^N) x (2^N)for an option value ofN, so a value of6gives a size of64x64. The matrix is generated at startup time, and a large matrix can take rather long to compute (seconds ๐ญ).
Used in --dither=fruit mode only.
--dither=<fruit|ordered|error-diffusion|no>โ selects the dithering algorithm (default:fruit). (Normally, the--dither-depthoption controls whether dithering is enabled at all.)
The error-diffusion option requires compute shader support. It also requires a large amount of shared memory to run, and the size of that depends on both the kernel (see the --error-diffusion option below) and the height of the video window. It will fallback to fruit dithering if there isn't enough shared memory to run the shader. Respect the hustle ๐
--temporal-ditherโ enables temporal dithering. (Only active if dithering is enabled in general.) This changes between 8 different dithering patterns on each frame by changing the orientation of the tiled dithering matrix โจ. Unfortunately, this can lead to flicker on LCD displays, since these have a high reaction time. So like, yikes.--temporal-dither-period=<1-128>โ determines how often the dithering pattern is updated when--temporal-ditheris in use.1(the default) will update on every video frame,2on every other frame, etc.--error-diffusion=<kernel>โ the error diffusion kernel to use when--dither=error-diffusionis set.simpleโ propagate error to only two adjacent pixels. Fastest, but low quality.sierra-liteโ fast with reasonable quality. This is the default. Slay ๐
floyd-steinbergโ the most iconic error diffusion kernel, fr fr. the blueprint. ๐atkinsonโ lowkey built different from the other kernels, because only a fraction of the errors get propagated during dithering. a classic use case is saving a dithered screenshot (in window mode) ๐ซถ. this kernel spits out a slightly smaller file, and the dithering quality is still reasonable, no cap.
There are other kernels too (use --error-diffusion=help to list them ๐) but bestie, most of them are much slower and demand an even bigger amount of shared memory. Among these kernels, burkes hits a good balance between performance and quality, and honestly it's probably the one you want to try first. โญ
--gpu-debugโ turns on GPU debugging โจ. what that actually means depends on the API type. for OpenGL it callsglGetError(), and requests a debug context. for Vulkan it enables validation layers. very "let me see everything" of it.--opengl-swapinterval=<n>โ the interval, in displayed frames, between two buffer swaps.1= VSYNC on,0= VSYNC off. defaults to1if you don't specify anything. ๐
heads up though โ this depends on proper OpenGL vsync support. on some platforms and drivers it only works reliably in fullscreen mode ๐ญ. it may also need driver-specific hacks if you're running multiple monitors, just to make sure mpv syncs to the right one. compositing window managers can lead to bad results too, and so can missing or incorrect display FPS info (see --display-fps-override). it's giving fragile, ngl.
--egl-config-id=<ID>โ (EGL only) picks the EGLConfig with a specificEGL_CONFIG_ID. rendering surfaces and contexts will be created using this EGLConfig. you can use--msg-level=vo=traceto get a list of the available configs. ๐--egl-output-format=<auto|rgb8|rgba8|rgb10|rgb10_a2|rgb16|rgba16|rgb16f|rgba16f|rgb32f|rgba32f>โ (EGL only) picks a specific EGL output format to use for OpenGL rendering. this option is mutually exclusive with--egl-config-id."auto"is the default, and it'll pick the first usable config based on the order given by the driver. ๐
not all formats are available! if you select an unavailable format, that's a fatal error ๐. no take-backs.
Note: there's no reliable API to query desktop bit depth in EGL. you can manually set this option according to the bit depth of your display. this option also affects the auto-detection of --dither-depth.
Note: unlike--d3d11-output-format, this option also takes effect with--vo=gpu-next.
--vulkan-device=<device name|UUID>โ the name or UUID of the Vulkan device to use for rendering and presentation. use--vulkan-device=helpto see the list of available devices and their names and UUIDs ๐. if you leave it unspecified, the first enumerated hardware Vulkan device gets used.--vulkan-swap-mode=<mode>โ controls the presentation mode of the vulkan swapchain. similar to the--opengl-swapintervaloption.autoโ use the preferred swapchain mode for the vulkan context. (Default) โจfifoโ non-tearing, vsync blocked. basically "VSync on".fifo-relaxedโ tearing, vsync blocked. late frames will tear instead of stuttering. ๐ซmailboxโ non-tearing, not vsync blocked. basically "triple buffering".immediateโ tearing, not vsync blocked. basically "VSync off".
--vulkan-queue-count=<1..8>โ controls the number ofVkQueuesused for rendering (limited by how many your device actually supports). in theory, using more queues could enable some parallelism between frames (when you're using a--swapchain-depthhigher than1), but it can also slow things down on hardware where there's no true parallelism between queues ๐ฌ. (Default:1)--vulkan-async-transferโ enables the use of async transfer queues on supported vulkan devices. using them lets transfer operations like texture uploads and blits happen concurrently with the actual rendering, which improves overall throughput and power consumption ๐ฅ. enabled by default, and it should be relatively safe. slay.--vulkan-async-computeโ enables the use of async compute queues on supported vulkan devices. in theory this allows out-of-order scheduling of compute shaders with graphics shaders, letting the hardware do more effective work while it's waiting for pipeline bubbles and memory operations ๐. not beneficial on all GPUs, though. worth noting: if async compute is enabled, and the device supports more compute queues than graphics queues (bound by the restrictions set by--vulkan-queue-count), mpv will internally try to prefer compute shaders over fragment shaders wherever possible โจ. enabled by default โ although Nvidia users may want to disable it. ๐--vulkan-display-display=<n>โ the index of the display, on the selected Vulkan device, to present on when using thedisplayvkGPU context. use--vulkan-display-display=helpto see the list of available displays. if left unspecified, the first enumerated display gets used. ๐ฅ๏ธ--vulkan-display-mode=<n>โ the index of the display mode, of the selected Vulkan display, to use when using thedisplayvkGPU context. use--vulkan-display-mode=helpto see the list of available modes. if left unspecified, the first enumerated mode gets used.--vulkan-display-plane=<n>โ the index of the plane, on the selected Vulkan device, to present on when using thedisplayvkGPU context. use--vulkan-display-plane=helpto see the list of available planes. if left unspecified, the first enumerated plane gets used.--d3d11-exclusive-fs=<yes|no>โ switches the D3D11 swap chain fullscreen state to'fullscreen'when fullscreen video is requested. also known as "exclusive fullscreen" or "D3D fullscreen" in other apps. gives mpv full control of rendering on the swap chain's screen ๐ . off by default.--d3d11-warp=<yes|no|auto>โ use WARP (Windows Advanced Rasterization Platform) with the D3D11 GPU backend (default:auto). this is a high performance software renderer. by default it's only used when the system has no hardware adapters that support D3D11. while the extended GPU features will work with WARP, they can be very slow ๐.--d3d11-output-mode=<auto|window|composition>โ use a specific output mode for creating the D3D11 swapchain."composition"will not create a window. if you want to use the D3D11 GPU backend in WinUI applications, you need to set this to"composition"."window"will create a window and use the DWM to present the video."auto"is the same as"window". after creating the swapchain, you can get the swapchain address (anint64type value) by getting thedisplay-swapchainproperty. ๐--d3d11-feature-level=<12_1|12_0|11_1|11_0|10_1|10_0|9_3|9_2|9_1>โ select a specific feature level when using the D3D11 GPU backend. by default the highest available feature level is used. this option can be used to pick a lower feature level, which is mainly useful for debugging. most extended GPU features will not work at9_xfeature levels ๐ญ.--d3d11-flip=<yes|no>โ 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 isn't supported (for example, on Windows 7 without the platform update), mpv will automatically fall back to the older bitblt presentation model. no stress.
flip-model needs presentation needs to be disabled for background transparency to work. โจ
--d3d11-sync-interval=<0..4>โ schedule each frame to be presented for this number of VBlank intervals. (default:1) setting to1enables VSync, setting to0disables it.--d3d11-adapter=<adapter name|help>โ select a specific D3D11 adapter to use for D3D11 rendering. will pick the default adapter if unset. alternatives are listed when the namehelpis given. ๐
it checks for matches based on the start of the string, case insensitive. so if the description of the adapter starts with the vendor name, you can use that as your selection parameter. ๐
hardware decoders that use the D3D11 rendering abstraction's helper functionality to receive a device โ like D3D11VA or DXVA2's DXGI mode โ will be affected by this choice.
--d3d11-output-format=<auto|rgba8|bgra8|rgb10_a2|rgba16f>โ select a specific D3D11 output format to use for D3D11 rendering."auto"is the default, and it'll pick eitherrgba8orrgb10_a2depending on the configured desktop bit depth.rgba16fandbgra8are 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. so on older systems it will only automatically use the rgba8 output format.
Note: for --vo=gpu-next, this is used as a best-effort hint and libplacebo has the last say on which format is utilized. periodt.
--d3d11-output-csp=<auto|srgb|linear|pq|bt.2020>โ select a specific D3D11 output color space to use for D3D11 rendering."auto"is the default, and it selects the color space of the desktop the swap chain is located on. ๐
values other than "srgb" and "pq" have had issues in testing, so they're mostly there for manual testing. ๐
Note: swap chain color space configuration is only available from an API available from Windows 10. so on older systems, it just won't work. ๐
--d3d11va-zero-copy=<yes|no>โ okay so by default, when you're doing hardware decoding with--gpu-api=d3d11, the video image gets copied (GPU-to-GPU bestie, the drama) from the decoder surface over to a shader resource. Turn this on and mpv skips that copy entirely by sampling straight off the decoder image. Performance up, power usage down โจ but plot twist: the image can get sampled wrong along the bottom and right edges because of padding, and it can poke driver bugs, since Direct3D 11 technically does not allow sampling from a decoder surface (even though most drivers are out here supporting it anyway ๐).
Currently only relevant for --gpu-api=d3d11.
--wayland-app-id=<string>โ sets the client app id for Wayland-based video output methods (default:mpv). It's giving name tag but for your compositor ๐--wayland-configure-bounds=<auto|yes|no>โ controls whether mpv opts into the configure bounds event if the compositor sends one (default:auto). This caps the initial size of the mpv window to some maximum the compositor has in mind. Most of the time it just stops the mpv window from being bigger than the actual monitor when it first renders ๐ฆ With the default value ofauto, configure-bounds will silently be ignored if any autofit or geometry type option is also set.--wayland-content-type=<auto|none|photo|video|game>โ if your compositor supports it, mpv sends a hint through the content-type protocol, basically telling the compositor what kind of content is on screen.auto(default) will automatically switch between telling the compositor the content is a photo, a video, or possibly none, depending on internal heuristics ๐--wayland-edge-pixels-pointer=<value>โ defines the size of an edge border (default:16) that kicks off client side resize events in the wayland contexts with the mouse. Only active if there are no server side decorations from the compositor ๐--wayland-edge-pixels-touch=<value>โ defines the size of an edge border (default:32) that kicks off client side resize events in the wayland contexts with touch events โจ--wayland-internal-vsync=<no|auto|yes>โ controls whether to use mpv's internal vsync for Wayland-based video outputs (default:auto). Mainly useful for benchmarking wayland VOs when you pair it withvideo-sync=display-desync,--audio=no, and--untimed=yes๐ฅ The specialautovalue will disable the internal vsync if the compositor supports the fifo protocol and version 2 of the presentation time protocol when using--gpu-api=vulkan. In any other situation, it's exactly the same asyes.--wayland-present=<yes|no>โ enables use of wayland's presentation time protocol for more accurate frame presentation, if the compositor supports it (default:yes). This only does anything if--video-sync=display-...is being used ๐--spirv-compiler=<compiler>โ controls which compiler translates GLSL into SPIR-V. Only relevant for--gpu-api=d3d11with--vo=gpu. The possible choices right now are:autoโ use the first available compiler. (Default)shadercโ use libshaderc, which is an API wrapper around glslang. Generally the most preferred, if it's available ๐
Note: this option is deprecated, since there's literally only one usable value. It may get removed in the future ๐ซถ
--glsl-shader=<file>,--glsl-shaders=<file-list>โ custom GLSL hooks, babes. This is the flexible way to add custom fragment shaders that can be injected at almost any point in the rendering pipeline and can access all the previous intermediate textures ๐
Each use of the --glsl-shader option adds 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, plus the non-metadata lines after it, defines a single block. There are currently two types of blocks: HOOKs and TEXTUREs ๐
๐ TEXTURE blocks (the metadata setup era)
A TEXTURE block can set the following options:
TEXTURE <name>(required) โ the name of this texture. Hooks can then bind the texture under this name usingBIND. This has to be the first option of the texture block, no cap โจSIZE <width> [<height>] [<depth>](required) โ the dimensions of the texture. Height and depth are optional. The type of texture (1D, 2D or 3D) depends on how many components you specify ๐ฆFORMAT <name>(required) โ the texture format for the samples. The supported texture formats get listed in debug logging when the gpu VO initializes (look forTexture formats:). Usually this follows OpenGL naming conventions. For example,rgb16gives you 3 channels with normalized 16 bit components. One little oddity: float formats. Likergba16fhas 16 bit internal precision, but the texture data is handed over as 32 bit floats, and the driver converts the data on texture upload ๐
Even though format names follow a common naming convention, not all of them are available on all hardware, drivers, GL versions, and so on. Vibe check your setup first ๐
FILTER <LINEAR|NEAREST>โ the min/magnification filter used when sampling from this texture.BORDER <CLAMP|REPEAT|MIRROR>โ the border wrapping mode used when sampling from this texture.
Following the metadata is a string of bytes in hexadecimal notation that define the raw texture data, corresponding to the format specified by FORMAT, all on a single line with no extra whitespace ๐
๐ฅ HOOK blocks (where the magic actually happens)
A HOOK block can set the following options:
HOOK <name>(required) โ the texture to hook into. Can appear multiple times inside a metadata block, up to a predetermined limit. See below for the list of hookable textures ๐DESC <title>โ a user-friendly description of the pass. This is the name used when representing this shader in the list of passes for the propertyvo-passes.BIND <name>โ loads a texture (either coming from mpv or from aTEXTUREblock) and makes it available to the pass. When binding textures from mpv, this also sets up macros to make accessing it properly easier. See below for a list. By default, no textures are bound. The special nameHOOKEDcan be used to refer to the texture that triggered this pass ๐SAVE <name>โ gives the name of the texture to save the result of this pass into. By default this is set to the special nameHOOKED, which has the effect of overwriting the hooked texture ๐WIDTH <szexpr>,HEIGHT <szexpr>โ specifies the size of the resulting texture for this pass. szexpr refers to an expression in RPN (reverse polish notation), using the operators+ - * / > < !, floating point literals, and references to sizes of existing textures (such asMAIN.widthorCHROMA.height),OUTPUT, orNATIVE_CROPPED(size of an input texture cropped after pan-and-scan, video-align-x/y, video-pan-x/y, etc. and possibly prescaled). By default these are set toHOOKED.wandHOOKED.h, respectively โจWHEN <szexpr>โ specifies a condition that needs to be true (non-zero) for the shader stage to be evaluated. If it fails, it will silently be omitted. (Note that a shader stage like this which has a dependency on an optional hook point can still cause that hook point to be saved, which has some minor overhead) ๐ซถOFFSET <ox oy | ALIGN>โ indicates a pixel shift (offset) introduced by this pass. These pixel offsets get accumulated and corrected during the next scaling pass (cscaleorscale). The default values are0 0, which means no shift. Note that offsets are ignored when not overwriting the hooked texture ๐
A special value of ALIGN will attempt to fix the existing offset of HOOKED by aligning 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 ๐
COMPONENTS <n>โ specifies how many components of this pass's output are relevant and should be stored in the texture, up to 4 (rgba). By default this value equals the number of components inHOOKED.COMPUTE <bw> <bh> [<tw> <th>]โ specifies that this shader should be treated as a compute shader, with the block size bw and bh. The compute shader gets dispatched with however many blocks are necessary to completely tile over the output. Within each block there will betw*ththreads, 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 =32and tw, th =8running on a 500x500 texture would dispatch 16x16 blocks (rounded up), each with 8x8 threads ๐
Okay so compute shaders in mpv? They do NOT play by the same rules as fragment shaders, bestie, and the difference is lowkey the whole vibe. Instead of defining a vec4 hook that spits out an output sample, you go straight to defining a void hook that writes into a fixed writeonly image unit named out_image (mpv is the one who binds it, not you) using imageStore. And because there are literally no vertices to help you translate texture coordinates, mpv hands you a special function, NAME_map(id), which maps from the texel space of the output image over to the texture coordinates for all the bound textures. So NAME_pos is equivalent to NAME_map(gl_GlobalInvocationID) โ although ngl, that only really makes sense if (tw,th) == (bw,bh). ๐
โจ What each bound texture gives you โจ
Every bound mpv texture (bound via BIND) makes the following definitions available to that shader pass, where NAME is the name of the bound texture:
vec4 NAME_tex(vec2 pos)โ the sampling function you use to access the texture at a certain spot (in texture coordinate space, range[0,1]). It handles all the necessary normalization conversions for you, so you don't have to. ๐ซถvec4 NAME_texOff(vec2 offset)โ samples the texture at a certain offset in pixels. Works likeNAME_texbut it also takes care of the necessary rotations, so sampling at likevec2(-1,0)is always one pixel to the left. periodt.vec2 NAME_posโ the local texture coordinate of that texture, range[0,1].vec2 NAME_sizeโ the (rotated) size in pixels of the texture.mat2 NAME_rotโ the rotation matrix associated with this texture. (It rotates pixel space into texture coordinates.)vec2 NAME_ptโ the (unrotated) size of a single pixel, range[0,1].float NAME_mulโ the coefficient that needs to be multiplied into the texture contents in order to normalize it to the range[0,1].sampler NAME_rawโ the raw bound texture itself. Using this should be avoided unless it is absolutely necessary. Like, fr fr, it's the "break glass in case of emergency" option.
Normally, bestie, you 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 you must take care to respect NAME_mul and NAME_rot. No skipping that, okay? ๐ค
๐ The globally available uniforms ๐
On top of all those per-texture definitions, these uniforms are also globally available:
float randomโ a random number in the range[0-1], different per frame. ๐ฒint frameโ a simple count of frames rendered. It increases by one per frame and never resets (regardless of seeks).vec2 input_sizeโ the size in pixels of the input image (possibly cropped and prescaled).vec2 target_sizeโ the size in pixels of the visible part of the scaled (and possibly cropped) image.vec2 tex_offsetโ texture offset introduced by user shaders or options likepanscan,video-align-x/y,video-pan-x/y.
๐ Hook points (the legal ones) ๐
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. So here's the list of the legal hook points:
RGB,LUMA,CHROMA,ALPHA,XYZ(resizable) โ source planes (raw). Which of these actually fire depends on the image format of the source.CHROMA_SCALED,ALPHA_SCALED(fixed) โ source planes (upscaled). These only fire on subsampled content.NATIVE(resizable) โ the combined image, in the source colorspace, before conversion to RGB.MAINPRESUB(resizable) โ the image, after conversion to RGB, but before--blend-subtitles=videois applied.
Note: with--vo=gpu,MAINandMAINPRESUBare separate shader stages, and this allows rendering overlays directly onto the pre-scaled video stage.--vo=gpu-nextdoes not support this feature, and as such, theMAINPRESUBshader stage does not exist. It is still valid to refer to this name in shaders, but it gets handled identically toMAIN. ๐
MAIN(resizable) โ the main image, after conversion to RGB but before upscaling.LINEAR(fixed) โ linear light image, before scaling. This only fires when--linear-upscaling,--linear-downscalingor--sigmoid-upscalingis in effect.SIGMOID(fixed) โ sigmoidized light, before scaling. This only fires when--sigmoid-upscalingis in effect.PREKERNEL(fixed) โ the image immediately before the scaler kernel runs.POSTKERNEL(fixed) โ the image immediately after the scaler kernel runs.SCALED(fixed) โ the final upscaled image, before color management.OUTPUT(fixed) โ the final output image, after color management but before dithering and drawing to screen.
Only the textures labelled resizable may be transformed by the pass. And when you overwrite a texture marked fixed, the WIDTH, HEIGHT and OFFSET must be left at their default values. Don't be messy about it. ๐
๐ THE OPTIONS (part 37, we're still going) ๐
--glsl-shader=<file>โ CLI/config file only alias for--glsl-shaders-append. That's it, that's the whole thing.--glsl-shader-opts=param1=value1,param2=value2,...โ specifies the options to use for tunable shader parameters. You can target specific named shaders by prefixing the shader name with a/, e.g.shader/param=value. Without a prefix, parameters affect all shaders. The shader name is the base part of the shader filename, without the extension. (--vo=gpu-nextonly)
Some parameters are filled in automatically if the shader requests them. Currently the following parameters are available:
PTSโ PTS of the current frame in seconds.chroma_offset_xโ chroma offset to the reference plane in x direction.chroma_offset_yโ chroma offset to the reference plane in y direction.min_lumaโ minimum luminance value (in cd/mยฒ).max_lumaโ maximum luminance value (in cd/mยฒ).max_cllโ Maximum Content Light Level (in cd/mยฒ).max_fallโ Maximum Frame Average Light Level (in cd/mยฒ).scene_max_rโ maximum scene light level of the red channel (in cd/mยฒ).scene_max_gโ maximum scene light level of the green channel (in cd/mยฒ).scene_max_bโ maximum scene light level of the blue channel (in cd/mยฒ).scene_avgโ average scene light level (in cd/mยฒ).max_pq_yโ maximum PQ luminance (in PQ, 0-1).avg_pq_yโ average PQ luminance (in PQ, 0-1).
--debandโ enable the debanding algorithm. This greatly reduces the amount of visible banding, blocking and other quantization artifacts, at the expense of very slightly blurring some of the finest details. In practice it's virtually always an improvement โ the only reason you'd disable it is performance. So like, keep it on, bestie. โจ--deband-iterations=<0..16>โ the number of debanding steps to perform per sample. Each step reduces a bit more banding, but it takes time to compute. Heads up though: the strength of each step falls off very quickly, so high numbers (>4) are practically useless. (Default1)--deband-threshold=<0..4096>โ the debanding filter's cut-off threshold. Higher numbers increase the debanding strength dramatically but progressively diminish image details. (Default48)--deband-range=<1..64>โ 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. (Default16)
If you bump up --deband-iterations, you should probably decrease this to compensate. iykyk ๐ฆ
--deband-grain=<0..4096>โ adds some extra noise to the image. This significantly helps cover up remaining quantization artifacts. Higher numbers add more noise. (Default32)--corner-rounding=<0..1>โ if set to a value above0.0, the output will be rendered with rounded corners, as if an alpha transparency mask had been applied. The value indicates the relative fraction of the side length to round โ a value of1.0rounds the corners as much as possible. (--vo=gpu-nextonly) ๐--sharpen=<value>โ if set to a value other than0, enable an unsharp masking filter. Positive values will sharpen the image (but add more ringing and aliasing). Negative values will blur the image. If your GPU is powerful enough, consider alternatives like theewa_lanczossharpscale filter, or the--scale-bluroption. (Only for--vo=gpu)--opengl-glfinishโ callsglFinish()before swapping buffers (default: disabled). Slower, but might improve results when doing framedropping. Can completely ruin performance. The details depend entirely on the OpenGL driver, so it's giving chaos. ๐ญ--opengl-waitvsyncโ callsglXWaitVideoSyncSGIafter 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.--opengl-dwmflush=<no|windowed|yes|auto>โ (Windows only) callsDwmFlushafter swapping buffers on Windows (default:auto). It also setsSwapInterval(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
windowedshould be enough, since full screen may bypass the DWM.
--angle-d3d11-feature-level=<11_0|10_1|10_0|9_3>โ picks a specific feature level when you're using the ANGLE backend with D3D11. Default? The highest available feature level, bestie. This one lets you drop down to a lower feature level, which is mostly a debugging thing. Lowkey important: OpenGL ES 3.0 is only supported at feature level10_1or higher. Most extended OpenGL features will not work at lower feature levels (similar to--gpu-dumb-mode).
Windows with ANGLE only.
--angle-d3d11-warp=<yes|no|auto>โ use WARP (Windows Advanced Rasterization Platform) when using the ANGLE backend with D3D11 (default:auto). It's a high performance software renderer, no cap. By default it's used when the Direct3D hardware does not support Direct3D 11 feature level9_3. And yes โ the extended OpenGL features will work with WARP, but they can be very slow. ๐
Windows with ANGLE only.
--angle-egl-windowing=<yes|no|auto>โ use ANGLE's built in EGL windowing functions to create a swap chain (default:auto). If you set it tonoand the D3D11 renderer is in use, ANGLE's built in swap chain will not be used and a custom swap chain optimized for video rendering gets created instead. If it'sauto, a custom swap chain is used for D3D11 and the built in swap chain is used for D3D9. Mainly for debugging purposes, in case the custom swap chain has poor performance or just doesn't work. ๐ญ
If set to yes, the --angle-flip option will have no effect.
Windows with ANGLE only.
--angle-flip=<yes|no>โ 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, just so you know. 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.
--angle-renderer=<d3d9|d3d11|auto>โ forces a specific renderer when using the ANGLE backend (default:auto). Inautomode this will pick D3D11 for systems that support Direct3D 11 feature level9_3or higher, and D3D9 otherwise. This is mainly for debugging purposes. Normally there is no reason to force a specific renderer, though--angle-renderer=d3d9may give slightly better performance on old hardware. Heads up: 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.
--macos-force-dedicated-gpu=<yes|no>โ deactivates the automatic graphics switching and forces the dedicated GPU. (default:no)
macOS only.
--cocoa-cb-sw-renderer=<yes|no|auto>โ use the Apple Software Renderer when usingcocoa-cb(default:auto). If set tonothe software renderer is never used and instead fails when a the usual pixel format could not be created,yeswill always only use the software renderer, andautoonly falls back to the software renderer when the usual pixel format couldn't be created. ๐
macOS and cocoa-cb only.
--cocoa-cb-10bit-context=<yes|no>โ creates a 10bit capable pixel format for the context creation (default:yes). Instead of an 8bit integer framebuffer, a 16bit half-float framebuffer is requested. โจ
macOS and cocoa-cb only.
--cocoa-cb-output-csp=<csp>โ this sets the color space of the layer to activate the macOS color transformation. Depending on the color space used, the system's EDR (HDR) support will be activated. To get correct results, this needs to be set to the color primaries/transfer characteristics of the VO target. It is recommended to use this switch together with--target-trcand--target-prim.
<csp> can be one of the following:
autoโ Sets the color space to the icc profile of the screen (default).display-p3โ DCI P3 primaries, a D65 white point and the sRGB transfer function.display-p3-hlgโ DCI P3 primaries, a D65 white point and the Hybrid Log-Gamma (HLG) transfer function.display-p3-pqโ DCI P3 primaries, a D65 white point and the Perceptual Quantizer (PQ) transfer function.display-p3-linearโ DCI P3 primaries, a D65 white point and linear transfer function.dci-p3โ DCI P3 color space.bt.2020โ ITU BT.2020 color space.bt.2020-linearโ ITU BT.2020 color space and linear transfer function.bt.2100-hlgโ ITU BT.2100 and the Hybrid Log-Gamma (HLG) transfer function.bt.2100-pqโ ITU BT.2100 and the Perceptual Quantizer (PQ) transfer function.bt.709โ ITU BT.709 color space.srgbโ sRGB colorimetry and non-linear transfer function.srgb-linearโ Same as sRGB but linear transfer function.rgb-linearโ RGB and linear transfer function.adobeโ Adobe RGB (1998) color space.
macOS and cocoa-cb only.
--macos-title-bar-appearance=<appearance>โ sets the appearance of the title bar (default:auto). Not all combinations of appearances and--macos-title-bar-materialmaterials make sense or are unique, jsyk. Appearances that are not supported by you current macOS version fall back to the default value. macOS 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+)
--macos-title-bar-material=<material>โ 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-appearanceappearances make sense or are unique. Materials that are not supported by you current macOS version fall back to the default value. macOS only
<material> can be one of the following:
titlebarโ The standard macOS title 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+)
--macos-title-bar-color=<color>โ sets the color of the title bar (default: completely transparent). Is influenced by--macos-title-bar-appearanceand--macos-title-bar-material. See--sub-colorfor color syntax. ๐จ--macos-fs-animation-duration=<default|0-1000>โ sets the fullscreen resize animation duration in ms (default:default). The default value is slightly less than the system's animation duration (500ms) to prevent some problems when the end of an async animation happens at the same time as the end of the system wide fullscreen animation. Setting anything higher than 500ms will only prematurely cancel the resize animation after the system wide animation ended. The upper limit is still set at 1000ms since it's possible that Apple or the user changes the system defaults. Anything higher than 1000ms though seems too long and shouldn't be set anyway. (macOS)--macos-app-activation-policy=<regular|accessory|prohibited>โ changes the App activation policy. Withaccessorythe mpv icon in the Dock can be hidden. (default:regular)
macOS only.
--macos-geometry-calculation=<visible|whole>โ this one changes up the rectangle that mpv uses to figure out where the window goes and how big it gets (default:visible).visibleis the polite one: it counts the menu bar and the Dock, so your window only ever gets positioned/sized inside the visible screen frame rectangle.wholeis the feral one: it takes the entire screen frame rectangle and straight-up ignores the menu bar and the Dock. All the other old restrictions still apply tho, like you still can't park a window on top of the menu bar etc.
macOS only. ๐
--macos-render-timer=<timer>โ sets the mode (default:callback) for syncing frame rendering to your display's vertical refresh rate. macOS and Vulkan (macvk) only, bestie.
<timer> can be one of these:
callbackโ syncs to theCVDisplayLinkcallbackpreciseโ syncs to the time of the next vertical display refresh reported by theCVDisplayLinkcallback provided informationsystemโ no manual syncing, it just depends on the layer mechanic and the next drawablefeedbackโ same asprecisebut it uses the presentation feedback core mechanism
--macos-menu-shortcuts=<yes|no>โ turns the default menu bar shortcuts on or off (default:yes). Heads up tho: menu bar shortcuts always take precedence over any other shortcuts, they don't get propagated to the mpv core, and you literally cannot use them in config files likeinput.confor script bindings. So don't try it. ๐--macos-bundle-path=path1,path2,...โ ok so App Bundles live in their own lil shell environment that's different from the one in your terminal. The defaultPATHvariable for all Bundles is/usr/bin:/bin:/usr/sbin:/sbin. Which means mpv can't find binaries installed by a package manager that might be used in scripts, for example. This option prepends all the given paths to that default BundlePATH. ๐ซถ
Default value in this order:
/usr/local/binโ homebrew (Intel) install path/usr/local/sbinโ homebrew (Intel) install path/opt/local/binโ MacPorts install path/opt/local/sbinโ MacPorts install path/opt/homebrew/binโ homebrew (ARM) install path/opt/homebrew/sbinโ homebrew (ARM) install path
--android-surface-size=<WxH>โ sets the dimensions of the rendering surface used by the Android gpu context. The embedding application needs to set this if the dimensions change during runtime (i.e. if the device gets rotated), via thesurfaceChangedcallback.
Android with --gpu-context=android only.
--d3d11-composition-size=<WxH>โ sets the size of the output for d3d11 composition mode. When you're in composition mode there's no window, so the embedding application must set the output size itself.
Windows with --gpu-context=d3d11 and --d3d11-output-mode=composition only.
--gpu-swโ keeps going even if a software renderer gets detected. This only works with OpenGL/Vulkan backends. For d3d11, go look at--d3d11-warpinstead.--gpu-context=<context1,context2,...[,]>โ you're giving a priority list of the GPU contexts to be used. The valueauto(the default) selects the GPU context with the default autoprobe order. You can also passhelpto get a complete list of compiled in backends (sorted by the default autoprobe order). ๐
Not me warning you: the default GPU context is subject to change, and must not be relied upon. If a certain GPU context needs to be used, it must be explicitly specified. Periodt.
autoโ auto-select (default). Note that this context must be used alone and does not participate in the priority list.winโ Win32/WGLwinvkโVK_KHR_win32_surfaceangleโ Direct3D11 through the OpenGL ES translation layer ANGLE. This supports almost everything thewinbackend does (if the ANGLE build is new enough).dxinterop(experimental) โ Win32, using WGL for rendering and Direct3D 9Ex for presentation. Works on Nvidia and AMD. Newer Intel chips with the latest drivers may also work.d3d11โ Win32, with native Direct3D 11 rendering.x11โ X11/GLX (deprecated/legacy, EGL is preferred these days)x11vkโVK_KHR_xlib_surfacewaylandโ Wayland/EGLwaylandvkโVK_KHR_wayland_surfacedrmโ DRM/EGLdisplayvkโVK_KHR_display. This backend is roughly the Vulkan equivalent of DRM/EGL, allowing for direct rendering via Vulkan without a display manager.x11eglโ X11/EGLandroidโ Android/EGL. Requires--widbe set to anandroid.view.Surface.macvkโ Vulkan on macOS with a metal surface through a translation layer (experimental)
This is an object settings list option. See List Options for details.
--gpu-api=<type1,type2,...[,]>โ same energy, but for a priority list of accepted graphics APIs.autoโ Use any available API (default). Note that the default GPU API used for this value is subject to change, and must not be relied upon. If a certain GPU API needs to be used, it must be explicitly specified.openglโ Allow only OpenGL (requires OpenGL 2.1+ or GLES 2.0+)vulkanโ Allow only Vulkan (requires a valid/working--spirv-compiler)d3d11โ Allow only--gpu-context=d3d11
This is an object settings list option. See List Options for details.
--opengl-es=<mode>โ controls which type of OpenGL context will be accepted:autoโ Allow all types of OpenGL (default)yesโ Only allow GLESnoโ Only allow desktop/core GL
--fbo-format=<fmt>โ selects the internal format of textures used for FBOs. The format can influence performance and quality of the video output.fmtcan 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, it attempts to utilize rgb10_a2 or rgba8 if all of the previous formats are not available. It's giving "I'll figure it out, bestie". โจ
--gamma-factor=<0.1..2.0>โ sets an additional raw gamma factor (default:1.0). If gamma is adjusted in other ways (like with the--gammaoption or key bindings and thegammaproperty), the value gets multiplied with the other gamma value. Math is math. ๐งฎ--gamma-autoโ automatically corrects the gamma value depending on ambient lighting conditions (adding a gamma boost for bright rooms).
This option is deprecated and may be removed in the future. Don't get attached. ๐ญ
NOTE: Only implemented on macOS and --vo=gpu.
--image-lut=<file>โ specifies a custom LUT file (in Adobe.cubeformat) to apply to the colors during image decoding. The exact interpretation of the LUT depends on the value of--image-lut-type. (Only for--vo=gpu-next)--image-lut-type=<value>โ controls the interpretation of color values fed to and from the LUT specified as--image-lut. Valid values are:autoโ Chooses the interpretation of the LUT automatically from tagged metadata, and otherwise falls back tonative. (Default)nativeโ Applied to the raw image contents in its native colorspace, before decoding to RGB. For example, for a HDR10 image, this would be fed PQ-encoded YCbCr values in the range0.0-1.0.normalizedโ Applied to the normalized RGB image contents, after decoding from its native color encoding, but before linearization.conversionโ Fully replaces the color decoding. A LUT of this type should ingest the image's native colorspace and output normalized non-linear RGB.
--target-colorspace-hint=<auto|yes|no>โ when enabled, output colorspace metadata will be set on the swapchain depending on the GPU context and platform this may affect compositor/display. This can be used for "HDR passthrough" and to set the output colorspace for SDR content. Inautomode, the target colorspace is only set if the current display parameters are known. Currently, this is supported on Wayland, D3D11 and winvk contexts. Theyesoption will always try to set the colorspace, you may need to adjust the--target-*options to match your display capabilities. Requires a supporting driver and--vo=gpu-next. (Default:auto)
Note: : Auto detected target colorspace metadata is not guaranteed to be always best choice. It depends on your compositor, driver, and display capabilities. However in most cases auto mode should work fine. ๐ฆ
--target-colorspace-hint-mode=<target|source|source-dynamic>โ select which metadata to use for the--target-colorspace-hint. (Only for--vo=gpu-next)targetโ Uses metadata based on the target display's actual capabilities. This mode adapts the source content to the target display before output. Note: HDR primaries are not overridden by the--target-primoption this only affects the enclosing container for the colorspace.--target-gamutcan be used to limit the output gamut if needed.sourceโ Uses the source content's metadata. This is the traditional "HDR passthrough" mode (SDR too), where it is assumed that the compositor and display will handle the colorspace directly and perform any necessary mappings.source-dynamicโ The same assource, but uses dynamic per-scene metadata instead of static HDR10. This is experimental and depends on the display's ability to react to metadata changes. Note that this does not send full HDR10+ or Dolby Vision metadata, but uses that information to produce HDR10 with per-scene luminance values.
Default is target. And if the target display params aren't available? It lowkey falls back to source. Also important: this happens on an individual properties basis โ so it'll merge source params into target for unknown properties, but not the other way around. Asymmetric, iykyk. ๐
The --target-* options override the metadata in both modes.
Note: The ICC profile always takes precedence over any metadata. Like, always always. ๐
Note: It is highly recommended to use--target-colorspace-hint=<auto|yes>so the output colorspace is set correctly. This is crucial for all non-sRGB content, even SDR, so the compositor, driver, and display can properly interpret the signal. ๐ Unfortunately, it's not as easy as it sounds. While mpv does high-quality color processing, we cannot guarantee what happens after the signal leaves mpv. So you may need to adjust additional settings to make sure the output is right. A one-size-fits-all default is just not feasible, bestie. ๐ญ Now with the backstory out of the way: For HDR output, the default oftargetshould work fine โ it'll automatically infer the best target HDR parameters and surface format. For compatibility, displays are assumed to be in HDR mode unless it's reported otherwise. (You can override this with--target-trc.) This way the HDR metadata is set and hopefully the compositor handles the rest. If the input is SDR, it gets converted to PQ with primaries set to source values. โจ For SDR output, for targets where mpv can't determine whether the target is HDR or SDR, you can usesourcemode. The metadata set will match the input colorspace. In case of HDR input, it'll passthrough as-is. Alternatively, you can usetargetmode and set--target-trcto a SDR transfer function. This way any input gets converted to SDR. Use the stats display to verify the input and output colorspace settings. ๐ TL;DR: Use--target-colorspace-hint=autoand adjust--target-*parameters to match your target display capabilities, until it looks best for you. Use Conditional auto profiles for specific adjustments. Avoid--target-colorspace-hint=nounless it's sRGB content โ but even then it's better to set the colorspace metadata. Periodt.
Note: Additional chatter about the "HDR passthrough" mode: there's a belief that this mode should send the source HDR signal as-is to the display, and the display will magically handle it, no matter what. This is not always true. In some cases it's better to send the HDR signal tone-mapped to the target display's capabilities, and the best way to do this is within mpv itself. ๐ง This is generally handled by either the compositor or the GPU driver. You can probably find HDR "calibration" options somewhere in your system. You can choose which metadata to send to the display and manually tweak it using the--target-*options. You can also try--inverse-tone-mappingif you want to make everything appear more HDR-like. ๐ Your mileage may vary โ this highly depends on the target display, there's no single answer. But try experimenting, you may be surprised. ๐
--target-colorspace-hint-strictโ When enabled (which is the default, btw), the configured swapchain colorspace (with the hint) will be respected. In this mode, the--target-*options act only as a hint, while the negotiated swapchain format is used for rendering output. This ensures correct results, since downstream processing depends on the signaled colorspace. When disabled, the swapchain colorspace gets overridden to match the--target-*options. (Only for--vo=gpu-next) ๐--target-prim=<value>โ 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:autoโ Disable any adaptation, except for atypical color spaces. Specifically, wide/unusual gamuts get automatically adapted to BT.709, while standard gamut (i.e. BT.601 and BT.709) content is not touched. (default) โจbt.470mโ ITU-R BT.470 Mbt.601-525โ ITU-R BT.601 (525-line SD systems, eg. NTSC), SMPTE 170M/240Mbt.601-625โ ITU-R BT.601 (625-line SD systems, eg. PAL/SECAM), ITU-R BT.470 B/Gbt.709โ ITU-R BT.709 (HD), IEC 61966-2-4 (sRGB), SMPTE RP177 Annex Bbt.2020โ ITU-R BT.2020 (UHD)appleโ Apple RGB ๐adobeโ Adobe RGB (1998)prophotoโ ProPhoto RGB (ROMM)cie1931โ CIE 1931 RGB (not to be confused with CIE XYZ)dci-p3โ DCI-P3 (Digital Cinema Colorspace), SMPTE RP431-2display-p3โ DCI-P3 with a D65 white pointv-gamutโ Panasonic V-Gamut (VARICAM) primariess-gamutโ Sony S-Gamut (S-Log) primaries
--target-trc=<value>โ 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:autoโ Disable any adaptation, except for atypical transfers. Specifically, HDR or linear light source material gets automatically converted to gamma 2.2, while SDR content is not touched. (default) ๐ธbt.1886โ ITU-R BT.1886 curve (assuming infinite contrast)srgbโ IEC 61966-2-4 (sRGB)linearโ Linear light outputgamma1.8โ Pure power curve (gamma 1.8), also used for Apple RGBgamma2.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), also used for BT.470-BGprophotoโ ProPhoto RGB (ROMM)pqโ ITU-R BT.2100 PQ (Perceptual quantizer) curve, aka SMPTE ST2084hlgโ ITU-R BT.2100 HLG (Hybrid Log-gamma) curve, aka ARIB STD-B67v-logโ Panasonic V-Log (VARICAM) curves-log1โ Sony S-Log1 curves-log2โ Sony S-Log2 curve
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. No cap, that's on you bestie. ๐ญ
--target-peak=<auto|nits>โ Specifies the measured peak brightness of the output display, incd/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 above203essentially 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 203. For HDR curves, it uses 203 * the transfer function's nominal peak. If available, it will use the target display's peak brightness as reported by the display. โญ
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's 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 as800 cd/m^2, and then calibrate it to a standard curve likegamma2.8. Setting this value to800would 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-mappingtomobiusor evenclip. ๐ฅ
--target-contrast=<auto|10-1000000|inf>โ Specifies the measured contrast of the output display.--target-contrastin conjunction with--target-peakvalue is used to calculate display black point. Used in black point compensation during HDR tone-mapping.autois the default and assumes1000:1contrast as a typical SDR display would have, or an infinite contrast when HDR--target-trcis used. If supported by the API, display contrast will be used as reported.infcontrast specifies display with perfect black level, in practice OLED. (Only for--vo=gpu-next) ๐ค--target-gamut=<value>โ Constrains the gamut of the display. You can use this option to output e.g.DCIP3-in-BT.2020. Set--target-primto the primaries of the containing colorspace (into which values will be encoded), and--target-gamutto the gamut you want to limit colors to. Takes the same values as--target-prim. (Only for--vo=gpu-next) ๐จ
Note: If the selected gamut is wider, it will be limited to--target-prim. Additionally, if--target-colorspace-hintis specified, the signaled gamut will be limited to the supported gamut of the swapchain. Which may differ from the requested--target-prim. ๐
--target-lut=<file>โ bestie, this drops a custom LUT file (has to be Adobe.cubeformat, okurrr) that gets applied to your colors before they hit the screen. The LUT gets fed normalized RGB values, and this happens after encoding into the target colorspace โ so like, after--target-trchas already done its thing. (Only for--vo=gpu-next) ๐--hdr-reference-white=<auto|10-1000000>โ sets the assumed peak brightness of the mastering display for SDR content, measured in cd/mยฒ (aka nits, bestie ๐). It's used as the HDR diffuse white level for SDR content โ basically it's the SDR brightness sitting inside an HDR container. Default is 203 cd/mยฒ. (Only for--vo=gpu-next)
โ ๏ธ heads up: this option overrides --target-peak if that's set and the target transfer function is SDR. Which means you can control SDR output separately from HDR output. iconique. โจ
--sdr-adjust-gamma=<auto|yes|no>โ okay so SDR transfer functions are lowkey a mess, they're often ambiguous or straight-up mismatched. Even when files are tagged with a specific function (say,bt.709), the actual content might not match at all. Like, most screen capture software tags its output asbt.709, but the content is usually just a direct sRGB capture. ๐
And it's not just the source side โ on the target side, "sRGB" is also ambiguous. Some displays are factory calibrated to a pure power 2.2 gamma, while others use the sRGB piecewise curve. Both of those are typically configured as "sRGB" in the swapchain config. Similar inconsistencies exist across compositor implementations of color management, because every platform handles this differently. See also --treat-srgb-as-power22. On top of that, bt.1886 needs the display contrast ratio to be known for correct rendering, and that's often just... not available. Use --target-contrast to specify it. ๐
So what does this option do? It controls whether SDR content should have its gamma adjusted. It only applies to the "sRGB" swapchain target configuration, since that's the most common and most ambiguous case. If set to no, content tagged as sRGB, gamma2.2 or bt.1886 gets rendered as-is. If set to yes, it'll be converted based on the available metadata.
auto (the default) behaves like no, except when --target-trc is explicitly set โ in that case it behaves like yes.
Generally it's recommended to enable this option, if you can make sure both source and target metadata is correct. (Only for --vo=gpu-next) ๐ฆ
--treat-srgb-as-power22=<no|input|output|both|auto>โ when this is on, sRGB gets (de)linearized using a pure power 2.2 curve instead of the standard sRGB piecewise transfer function. slay.
auto behaves like both, with possible platform-specific adjustments to keep the appearance consistent. Depending on the platform, the sRGB EOTF used by the system compositor may differ.
Default is auto. (Only for --vo=gpu-next) โจ
--tone-mapping=<value>โ picks the algorithm used for tone-mapping images onto the target display. This matters for both HDRโSDR conversion and gamut reduction (like playing BT.2020 content on a standard gamut display). Valid values, bestie, here we go ๐autoโ maps tobt.2390when using--vo=gpu, and tosplinewith--vo=gpu-next. (Default)clipโ hard-clips any out-of-range values. Use this when you care about perfect color accuracy for in-range values, and you're willing to completely distort the out-of-range ones. Not generally recommended. ๐mobiusโ generalization of Reinhard to a Mรถbius transform with a linear section. Smoothly maps out-of-range values while keeping contrast and colors for in-range material as much as possible. Use this when you care about color accuracy more than detail preservation. It sits somewhere in betweenclipandreinhard, depending on the value of--tone-mapping-param.reinhardโ the Reinhard tone mapping algorithm. Very simple continuous curve. Preserves overall image brightness but uses nonlinear contrast, which flattens details and degrades color accuracy.hableโ similar toreinhardbut preserves both dark and bright details better (slightly sigmoidal), at the cost of slightly darkening / desaturating everything. Developed by John Hable for use in video games. Use this when you care about detail preservation more than color/brightness accuracy. It's roughly equivalent to--tone-mapping=reinhard --tone-mapping-param=0.24. If possible, you should also enable--hdr-compute-peakfor the best results.bt.2390โ perceptual tone mapping curve (EETF) specified in ITU-R Report BT.2390.gammaโ fits a logarithmic transfer between the tone curves.linearโ linearly stretches the entire reference gamut to (a linear multiple of) the display.splineโ perceptually linear single-pivot polynomial. (--vo=gpu-nextonly)bt.2446aโ HDRโSDR mapping specified in ITU-R Report BT.2446, method A. This is the recommended curve for well-mastered content. (--vo=gpu-nextonly)st2094-40โ dynamic HDR10+ tone-mapping method specified in SMPTE ST2094-40 Annex B. In the absence of metadata, it falls back to a fixed spline matched to the input/output average brightness characteristics. (--vo=gpu-nextonly)st2094-10โ dynamic tone-mapping method specified in SMPTE ST2094-10 Annex B.2. Conceptually simpler than ST2094-40, and generally produces worse results.
--tone-mapping-param=<value>โ sets the tone mapping parameters. By default this is set to the special stringdefault, which maps to an algorithm-specific default value. It's ignored if the tone mapping algorithm isn't tunable. This affects these tone mapping algorithms:clipโ specifies an extra linear coefficient to multiply into the signal before clipping. Defaults to1.0.mobiusโ specifies the transition point from linear to mobius transform. Every value below this point is guaranteed to be mapped 1:1. The higher the value, the more accurate the result, at the cost of losing bright details. Defaults to0.3, which โ thanks to that steep initial slope โ still preserves in-range colors fairly accurately.reinhardโ specifies the local contrast coefficient at the display peak. Defaults to0.5, which means in-gamut values will be about half as bright as when clipping.bt.2390โ specifies the offset for the knee point. Defaults to1.0, which is higher than the value from the original ITU-R specification (0.5). (--vo=gpu-nextonly)gammaโ specifies the exponent of the function. Defaults to1.8.linearโ specifies the scale factor to use while stretching. Defaults to1.0.splineโ specifies the knee point (in PQ space). Defaults to0.30.st2094-10โ specifies the contrast (slope) at the knee point. Defaults to1.0.
--inverse-tone-mappingโ if set, this allows inverse tone mapping (aka expanding dynamic range ๐ซถ). You can use it for upscaling SDR content to HDR, or for making HDR content brighter. Not supported by all tone mapping curves, and use it with caution bestie. (--vo=gpu-nextonly)--tone-mapping-max-boost=<1.0..10.0>โ the upper limit for how much the tone mapping algorithm is allowed to boost the average brightness by over-exposing the image. The default value of1.0allows no additional brightness boost. A value of2.0would allow over-exposing by a factor of 2, and so on. Raising this can help reveal details that would otherwise be hidden in dark scenes, but raising it too high makes dark scenes look unnaturally bright. (--vo=gpu only)--tone-mapping-visualizeโ displays a (PQ-PQ) graph of the active tone-mapping LUT. Intended only for debugging purposes, ok? The X axis shows PQ input values, the Y axis shows PQ output values. The tone-mapping curve is shown in green/yellow. Yellow means the brightness has been boosted from the source, and dark blue regions show where the brightness has been reduced. The extra colored regions and lines indicate various monitor limits, plus a reference diagonal (neutral tone-mapping) and source scene average brightness information (if available). (--vo=gpu-nextonly) ๐--gamut-mapping-modeโ picks the algorithm used for reducing the gamut of images for the target display, after any tone mapping is done.autoโ chooses the best mode automatically. (Default)clipโ hard-clips to the gamut (per-channel). Very low quality, but free. ๐perceptualโ performs a perceptually balanced gamut mapping using a soft knee function to roll-off clipped regions, and a hue shifting function to preserve saturation. (--vo=gpu-nextonly)relativeโ performs relative colorimetric clipping, while maintaining an exponential relationship between brightness and chromaticity. (--vo=gpu-nextonly)saturationโ performs simple RGBโRGB saturation mapping. The input R/G/B channels are mapped directly onto the output R/G/B channels. Will never clip, but will distort all hues and/or result in a faded look. (--vo=gpu-nextonly)absoluteโ performs absolute colorimetric clipping. Likerelative, but does not adapt the white point. (--vo=gpu-nextonly)desaturateโ performs constant-luminance colorimetric clipping, desaturating colors towards white until they're in-range.darkenโ uniformly darkens the input slightly to prevent clipping on blown-out highlights, then clamps colorimetrically to the input gamut boundary, biased slightly to preserve chromaticity over luminance. (--vo=gpu-nextonly)
warnโ does zero gamut mapping, it just highlights the out-of-gamut pixels so you can see them. Snitch behaviour, honestly. ๐linearโ desaturates the image linearly/uniformly to drag the whole thing into the target gamut. (--vo=gpu-nextonly)
๐ Color Management, Part Who-Knows ๐
Peak Detection & Tone Mapping
--hdr-compute-peak=<auto|yes|no>โ compute the HDR peak and the per-frame average brightness every frame instead of trusting the tagged metadata. Bestie, these values get averaged over local regions and over several frames so the number doesn't jitter around like it's on an energy drink. Basically: dynamic, per-scene tone mapping. โจ
Needs compute shaders, which is a fairly recent OpenGL feature, and it'll probably run horribly on some drivers, so enable at your own risk. ๐ The special value auto (the default) turns HDR peak computation on automatically if compute shaders and SSBOs are supported.
--allow-delayed-peak-detectโ when you're using--hdr-compute-peak, this lets the detected peak be delayed by a frame when that's better for performance. Specifically, it's required to dodge an unnecessary FBO indirection when no advanced rendering is needed otherwise. Has no effect if there's already an indirect pass, like when advanced scaling is on. Defaults tono. (Only affects--vo=gpu-nextโ and heads up,--vo=gpualways delays the peak.)--hdr-peak-percentile=<0.0..100.0>โ which percentile of the input image's brightness histogram counts as the true peak of the scene. Set it to100(the default) and it measures the brightest pixel. Otherwise, the top of the frequency distribution gets progressively cut off. Set it too low and you'll clip very bright details ๐ญ, but it can improve the dynamic brightness range of scenes with very bright isolated highlights. Any value other than100comes with a small performance penalty. (Only for--vo=gpu-next)--hdr-peak-decay-rate=<0.0..1000.0>โ the decay rate for the HDR peak detection algorithm (default:20.0). Only relevant when--hdr-compute-peakis enabled. Higher values make the peak decay more slowly, which means more stable values, at the cost of more "eye adaptation"-like effects (though--hdr-scene-thresholdmitigates that somewhat). A value of0.0(the lowest possible) disables all averaging, so each frame's value is used directly as measured โ but don't do that for "noisy" sources, it may cause excessive flicker. (In signal theory terms, this controls the time constant "tau" of an IIR low pass filter ๐ง )--hdr-scene-threshold-low=<0.0..100.0>,--hdr-scene-threshold-high=<0.0..100.0>โ the lower and upper thresholds (in dB) for a brightness difference to count as a scene change (default:1.0low,3.0high). Only relevant when--hdr-compute-peakis enabled. Normally the peak averaging mechanism smooths over small brightness fluctuations, but for big jumps the frame can stay too bright or too dark for up to several seconds, depending on--hdr-peak-decay-rate. So to counteract that: once the brightness difference between the running average and the current frame passes the low threshold, mpv makes the averaging filter more aggressive, ramping up to the limit of the high threshold โ at which point the filter becomes instant. ๐--hdr-contrast-recovery=<0.0..2.0>,--hdr-contrast-smoothness=<1.0..100.0>โ turns on the HDR contrast recovery algorithm, which is designed to enhance contrast of HDR video after tone mapping. The strength (default:0.0) says how much contrast recovery you get โ0.0is completely off,1.0is 100% strength. Values above1.0are allowed but may cause excessive sharpening. The smoothness (default:3.5) says how much the HDR source is low-passed to get the contrast info โ a value of2.0corresponds to 2x downscaling. Low DPI display girlies (<= 100) might want to lower this, while very high DPI ("retina") display girlies might want to raise it. (Only forvo=gpu-next)
ICC Profiles ๐
--use-embedded-icc-profileโ loads the embedded ICC profile inside media files like PNG images. (Default:yes.) Note that this only works when you're also using a display ICC profile (--icc-profileor--icc-profile-auto), and it also requires LittleCMS 2 support.--icc-profile=<file>โ loads an ICC profile and uses it to transform video RGB into screen output. Needs LittleCMS 2 support compiled in. This option overrides--target-prim,--target-trcand--icc-profile-auto.--icc-profile-autoโ automatically picks the ICC display profile that your OS display settings currently specify.
NOTE: On Windows, the default profile has to 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.
--icc-cacheโ stores and loads 3DLUTs created from the ICC profile on disk, in the cache directory (Default:yes). Speeds up loading, since LittleCMS 2 can take a hot minute to build a 3D LUT. Note these files contain uncompressed LUTs โ their size depends on--icc-3dlut-sizeand can be very big. ๐ณ- On
--vo=gpu-next, files that haven't been accessed in the last 24 hours may be cleared if the cache limit (1.5 GiB) is exceeded. - On
--vo=gpu, this is not cleaned automatically, so old unused cache files may stick around forever.
- On
--icc-cache-dirโ the directory where the icc cache is stored. If unset, the cache lives in the system's cache directory (usually~/.cache/mpv).--icc-intent=<value>โ specifies the ICC intent used for the color transformation (when using--icc-profile).0โ perceptual1โ relative colorimetric (default)2โ saturation3โ absolute colorimetric
--icc-3dlut-size=<auto|RxGxB>โ size of the 3D LUT generated from the ICC profile in each dimension. The default ofautomeans picking the size automatically based on the profile characteristics. Sizes may range from2to512.
NOTE: Setting this to anything other than auto is strongly discouraged, except for testing. fr fr.
--icc-force-contrast=<no|0-1000000|inf>โ override the target device's detected contrast ratio with a specific value. It's detected automatically from the profile if possible, but for some profiles it might be missing, which makes the contrast get assumed as infinite โ and then video may appear darker than intended. If that's happening to you, setting this option might help. ๐ซถ Only affects BT.1886 content. The default ofnomeans use the profile values. The special valueinfmakes the BT.1886 curve be treated as a pure power gamma 2.4 function.--icc-use-lumaโ use the ICC profile luminance value. (Only for--vo=gpu-next)
LUTs ๐
--lut=<file>โ specifies a custom LUT (in Adobe.cubeformat) to apply to the colors as part of color conversion. The exact interpretation depends on the value of--lut-type. (Only for--vo=gpu-next)--lut-type=<value>โ controls the interpretation of color values fed to and from the LUT specified as--lut. Valid values are:autoโ chooses the interpretation of the LUT automatically from tagged metadata, and otherwise falls back tonative. (Default)nativeโ applied to raw image contents in its native RGB colorspace (non-linear light), before conversion to the output color space.normalizedโ applied to the normalized RGB image contents, in linear light, before conversion to the output color space.conversionโ fully replaces the conversion from the image color space to the output color space. If such a LUT is present, it has the highest priority, and overrides any ICC profiles, plus options related to tone mapping and output colorimetry (--target-prim,--target-trcetc.). ๐
Subtitles, But Make It Color Managed
--blend-subtitles=<yes|video|no>โ blend subtitles directly onto the upscaled video frames, before interpolation and/or color management (default:no). Enabling this makes subtitles get affected by--icc-profile,--target-prim,--target-trc,--interpolation,--gamma-factorand--glsl-shaders. It also boosts subtitle performance when using--interpolation. ๐ฅ
The downside: it restricts subtitles to the visible portion of the video, so you can't have subtitles chillin' in the black margins below a video (for example). ๐ญ
If video is selected, the behaviour is similar to yes, but subs are drawn at the video's native resolution, and scaled along with the video.
Note:--vo=gpu-nextwith--blend-subtitles=videowill correctly follow--video-rotateif rotated in 90-degree steps.
Warning: With--vo=gpu-next, the--blend-subtitles=videomode blends the subtitles after scaling the video, similar to--blend-subtitles=yes. The difference is that the subtitles are rendered at the video's native resolution and then scaled separately to blend with the video. This is useful for performance reasons, since it lets subtitles render at a lower resolution, but it does not have the same effect as hardsubbing, which would require blending before scaling. This may change in the future.
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 it may cause SRT subtitles or similar to look slightly off. ๐
--background=<none|color|tiles>โ bestie, if your frame has an alpha component, this decides what kind of background (if any) it gets blended with. Zero effect if there's no alpha component, so don't come crying to me about your opaque video not changing. ๐colorโ blends the frame against the background color, which is--background-color(normally black).tilesโ blends the frame against a checkerboard pattern ๐, using colors from--background-tile-color-0and--background-tile-color-1, and a tile size from--background-tile-size. This one is the default.noneโ no blending, no touching, alpha stays exactly as it is. Let it be. ๐
Heads up: background transparency on d3d11 requires --d3d11-flip=no.
History lesson, iykyk: before mpv 0.38.0 this option used to accept a color value for the background color. That job belongs to --background-color now. Use that instead. โญ
--background-color=<color>โ the color used to draw the parts of the mpv window that aren't covered by video when you're in--background=colormode. Wanna know how colors are defined around here? Peep the--sub-coloroption. ๐จ--background-tile-color-0=<color>,--background-tile-color-1=<color>โ the two colors for the checkerboard, used to draw the parts of the mpv window not covered by video when you're in--background=tilesmode. Again,--sub-colorexplains how colors are defined. ๐--background-tile-size=<1-4096>โ how big those tiles are when you're in--background=tilesmode. Default:16. ๐ง--border-background=<none|color|tiles|blur>โ literally the same as--background, except it only applies to the black bar / border area of the window.vo=gpu-nextonly. Defaults tocolor. โจ--background-blur-radius=<radius>โ the blur radius, in pixels, to use when you've set--border-background=blur. ๐ซถ--opengl-rectangle-texturesโ forces the use of rectangle textures (default:no). Normally this shouldn't have any advantages over normal textures, ngl. Also note that hardware decoding overrides this flag. Could be removed any time, so don't get attached. ๐ญ--gpu-tex-pad-x,--gpu-tex-pad-yโ enlarges the video source textures by this many pixels. For debugging only (normally textures are sized exactly, but hardware decoding interop means we may have to deal with additional padding, and these options let you test that). Could be removed any time. ๐--opengl-early-flush=<yes|no|auto>โ callsglFlush()after rendering a frame and before trying to display it (default:auto). Can fix stuttering in some cases, and in other cases it probably causes it, which is iconic honestly. Theautomode only callsglFlush()when the renderer is about to wait for a while after rendering, instead of flipping the GL front and backbuffers immediately โ meaning it does not call it in display-sync mode.
On macOS this is always deactivated, because over there it only causes performance problems and other regressions. ๐
--gpu-dumb-mode=<yes|no|auto>โ okay so this mode is extremely restricted and will disable most extended features. That includes high quality scalers and custom shaders! ๐
It's meant for hardware that doesn't support FBOs (including GLES, which supports it insufficiently), or to squeeze some more performance out of bad or old hardware.
This mode gets forced automatically when needed, and the option is mostly useful for debugging. The default of auto enables it automatically if nothing uses features that require FBOs.
This option might be silently removed in the future. ๐ฆ
--gpu-shader-cacheโ stores and loads compiled GLSL shaders in the cache directory (Default:yes). Normally shader compilation is very fast, so this isn't usually needed. It mostly matters for anything involving GLSL to SPIR-V conversion, that is: D3D11, ANGLE or Vulkan, plus some other proprietary drivers. Enabling this can improve startup performance on those platforms. ๐ฅ
On --vo=gpu-next, files that haven't been accessed in the last 24 hours may be cleared if the cache limit (128 MiB) is exceeded.
On --vo=gpu, this is not cleaned automatically, so old, unused cache files may stick around indefinitely. ๐ญ
--gpu-shader-cache-dirโ the directory where the gpu shader cache is stored. If this is unset, the cache lives in the system's cache directory (usually~/.cache/mpv). ๐--libplacebo-opts=<key>=<value>[,<key>=<value>[,...]]โ passes extra raw options to the libplacebo rendering backend (used by--vo=gpu-next). It may override the effects of any other options set using the normal options system, which is lowkey unhinged. Requires libplacebo v6.309 or higher. Included for debugging purposes only. Wanna know more? See:
---
## ๐ฌ Video Sync ๐ฌ
- **`--mc=<seconds/frame>`** โ maximum A-V sync correction per frame, in seconds. โฑ๏ธ
- **`--autosync=<factor>`** โ gradually adjusts the A/V sync based on audio delay measurements. Specifying `--autosync=0`, the default, makes frame timing based entirely on audio delay measurements. Specifying `--autosync=1` does the same thing, but subtly changes the A/V correction algorithm. An uneven video framerate in a video that plays fine with `--audio=no` can often be helped by setting this to an integer value greater than `1`. The higher the value, the closer the timing will be to `--audio=no`. Try `--autosync=30` to smooth out problems with sound drivers that don't implement a perfect audio delay measurement. With this value, if large A/V sync offsets occur, they'll only take about 1 or 2 seconds to settle out. This delay in reaction time to sudden A/V offsets should be the only side effect of turning this option on, for all sound drivers. ๐ง
- **`--video-timing-offset=<seconds>`** โ controls how long before the 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, then perform a blocking wait until the display time, and only then "swap" the frame to display. The rendering can't 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 ensures rendering always starts immediately after the previous frame was displayed. On the other hand, setting a too high value can reduce responsiveness with low FPS value. ๐
This option is interesting for client API users using the render API, because you can stop it 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.
- **`--video-sync=<audio|...>`** โ 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 not to 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 for 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 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 (like toggling fullscreen mode, or just 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. That 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's 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`).
> <red>The modes with `desync` in their names do NOT attempt to keep audio/video in sync.</red> They will slowly (or quickly) desync, until e.g. the next seek happens. These modes are meant for **testing**, not serious use. Periodt.
- **`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-tempo`** โ basically `display-resample` but it speeds up/slows down the *audio filters* instead of resampling, so the pitch doesn't do the chipmunk thing. ๐
Careful though: some audio filters are NOT okay with a speed close to 1. Bestie move is to set up a conditional profile that auto-switches to `display-resample` once the speed gets too close to 1 for your filter setup. To get the actual playback speed in the condition, use `(speed * video_speed_correction)`. See *Conditional auto profiles* for the deets.
- **`display-vdrop`** โ drops or repeats video frames to compensate for desyncing video. (Even though it *should* have the same effects as audio, the implementation is wildly different. It's giving "same energy, different codebase".)
- **`display-adrop`** โ drops or repeats audio data to compensate for desyncing video. This mode will cause **severe audio artifacts** if the real monitor refresh rate is too different from the reported or forced rate. ๐ญ Since mpv 0.33.0, this acts on entire audio frames instead of single samples.
- **`display-desync`** โ sync video to display, and let audio justโฆ play on its own. Free spirit energy.
- **`desync`** โ sync video according to the system clock, and let audio play on its own. Also unbothered, also thriving.
---
### **`--video-sync-max-factor=<value>`**
Maximum multiple for which to try to fit the video's FPS to the display's FPS (default: `5`).
So like, if this is set to `1`, the video FPS is forced to an integer multiple of the display FPS โ as long as the speed change doesn't exceed whatever `--video-sync-max-video-change` says. โจ
See `--interpolation-threshold` for how this option messes with interpolation.
---
### **`--video-sync-max-video-change=<value>`**
Maximum speed difference **in percent** that gets applied to video with `--video-sync=display-...` (default: `1`). Display sync mode gets disabled if the monitor and video refresh way don't match within the given range. It tries multiples too, no cap: playing 30 fps video on a 60 Hz screen will duplicate every second frame. Playing 24 fps video on a 60 Hz screen plays video in a `2-3-2-3-...` pattern. ๐ฆ
The defaults are not loose enough to speed up 23.976 fps video to 25 fps. We consider the pitch change too extreme to allow that behavior by default, periodt. Set this option to a value of `5` to enable it.
Note that `--video-sync=display-tempo` avoids this pitch change. ๐
Also note that in `--video-sync=display-resample` or `--video-sync=display-tempo` mode, audio speed will *additionally* be changed by a small amount if necessary for A/V sync. See `--video-sync-max-audio-change`.
---
### **`--video-sync-max-audio-change=<value>`**
Maximum *additional* speed difference in percent that's applied to audio with `--video-sync=display-...` (default: `0.125`). Normally the player plays audio at the speed of the video. But if the difference between audio and video position is too high โ drift, other timing errors, the usual chaos โ it'll try to speed up or slow down audio by this extra factor. ๐ธ
Too low values could lead to video frame dropping or repeating if the A/V desync can't be compensated. Too high values could lead to chaotic frame dropping because the audio "overshoots" and skips multiple video frames before the sync logic can even react. It's giving panic mode.
---
## ๐ Miscellaneous ๐
### **`--display-tags=tag1,tags2,...`**
Set the list of tags that should be displayed on the terminal and stats. Tags that are in the list but *not* present in the played file won't be shown. If a value ends with `*`, all tags are matched by prefix (though there's no general globbing โ don't get any ideas). Just passing `*` is 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.
---
### **`--mf-fps=<value>`**
Framerate used when decoding from multiple PNG or JPEG files with `mf://` (default: `1`).
---
### **`--mf-type=<value>`**
Input file type for `mf://` (available: `jpeg`, `png`, `tga`, `sgi`). By default, this is guessed from the file extension. ๐ผ๏ธ
---
### **`--stream-dump=<destination-filename>`**
Instead of playing a file, read its byte stream and write it to the given destination file. The destination gets **overwritten** โ no takebacks, no backup, no nothing. Can be useful to test network-related behavior. ๐ซถ
---
### **`--stream-lavf-o=opt1=value1,opt2=value2,...`**
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.
---
### **`--backdrop-type=<auto|none|mica|acrylic|mica-alt>`**
(Windows only) Controls the backdrop/border style. ๐ช
- `auto` โ Default Windows behavior
- `none` โ The backdrop will be black or white depending on the system's theme settings.
- `mica` โ Enables the Mica style, which is the default on Windows 11.
- `acrylic` โ Enables the Acrylic style (frosted glass look). โจ
- `mica-alt` โ Same as Mica, except reversed.
---
### **`--window-affinity=<default|excludefromcmcapture|monitor>`**
(Windows only) Controls the window affinity behavior of mpv.
- `default` โ Default Windows behavior
- `excludefromcapture` โ mpv's window will be completely excluded from capture by external applications or screen recording software. ๐ stealth mode fr
- `monitor` โ Blacks out the mpv window
---
### **`--vo-mmcss-profile=<name>`**
(Windows only) Set the MMCSS profile for the video renderer thread (default: `Playback`).
---
### **`--priority=<prio>`**
(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. ๐ Like, do not. We're being so serious.
---
### **`--media-controls=<yes|no>`**
(Windows only) Enable integration of media control interface SystemMediaTransportControls.
Windows may display "Unknown app" or show a missing mpv icon in the media control panel. To fully support it, you need to register mpv using the `--register` command.
Default: `yes` (except for libmpv)
---
### **`--force-media-title=<string>`**
Force the contents of the `media-title` property to this value. Useful for scripts which want to set a title without overriding the user's setting in `--title`. ๐
---
### **`--external-files=<file-list>`**
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` use (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. That 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.
---
### **`--external-file=<file>`**
CLI/config file only alias for `--external-files-append`. Each use of this option will add a new external file.
---
### **`--cover-art-files=<file-list>`**
Use an external file as cover art while playing audio. This makes it appear on the track list and subject to automatic track selection. Options like `--audio-display` control whether such tracks are supposed to be selected. ๐
(The difference to loading a file with `--external-files` is that video tracks will be marked as being pictures, which affects the auto-selection method. If the passed file is a video, only the first frame will be decoded and displayed. Enabling the cover art track during playback may show a random frame if the source file is a video. Normally you're not supposed to pass videos to this option, so this paragraph describes the behavior coincidentally resulting from implementation details. ๐ iykyk)
This is a path list option. See *List Options* for details.
---
### **`--cover-art-file=<file>`**
CLI/config file only alias for `--cover-art-files-append`. Each use of this option will add a new external file.
---
### **`--cover-art-auto=<no|exact|fuzzy|all>`**
Whether to load *external* cover art automatically. Similar to `--sub-auto` and `--audio-file-auto`. If a video already has tracks (which are not marked as cover art), external cover art will not be loaded.
- `no` โ Don't automatically load cover art.
- `exact` โ Load the media filename with an image file extension (default).
- `fuzzy` โ Load all cover art containing the media filename.
- `all` โ Load all images in the current directory. ๐ go wild bestie
See `--cover-art-files` for details about what constitutes cover art.
See `--audio-display` how to control display of cover art (this can be used to disable cover art that is part of the file).
---
### **`--image-exts=ext1,ext2,...`**
Image file extensions to try to match when using `--cover-art-auto`, `--autocreate-playlist` or `--directory-filter-types`.
This is a string list option. See *List Options* for details. Use `--help=image-exts` to see default extensions.
---
### **`--cover-art-whitelist=filename1,filename2,...`**
Filenames to load as cover art, sorted by descending priority. They are combined with the extensions in `--image-exts`. This has no effect if `cover-art-auto` is `no`.
Default:
AlbumArt,Album,cover,front,AlbumArtSmall,Folder,.folder,thumb
This is a string list option. See *List Options* for details.
---
### **`--video-exts=ext1,ext2,...`**
Video file extensions to try to match when using `--autocreate-playlist` or `--directory-filter-types`.
This is a string list option. See *List Options* for details. Use `--help=video-exts` to see default extensions. ๐ฅ
- **`--archive-exts=ext1,ext2,...`** โ okay so these are the archive file extensions mpv will try to match when you're using `--autocreate-playlist` or `--directory-filter-types` ๐๏ธโจ
This is a string list option, bestie โ see List Options for the deets. And if you wanna peek at the default extensions, just hit `--help=archive-exts` ๐
- **`--playlist-exts=ext1,ext2,...`** โ and these are the playlist file extensions it tries to match when you're using `--autocreate-playlist` or `--directory-filter-types` ๐ต
Also a string list option (List Options has the tea). Wanna see the defaults? `--help=playlist-exts`, periodt ๐
- **`--autoload-files=<yes|no>`** โ auto-load/select external files, default is `yes` ๐ซถ
If you set this to `no`, mpv will NOT automatically load external files the way `--sub-auto`, `--audio-file-auto` and `--cover-art-auto` describe. And heads up: if external files get *forcibly* added (like with `--sub-files`), they won't be auto-selected either ๐ค
This does not affect playlist expansion, redirection, or other loading of referenced files like with ordered chapters. Noted ๐
- **`--stream-record=<file>`** โ writes the received/read data from the demuxer to the output file you give it ๐ผ
Real talk: the output file will **always be overwritten without asking**, so likeโฆ be careful. The output format is decided 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 though: if you seek back far enough to exceed the forward buffering size, the cache stops actively reading โ and for a live stream, that'll return in dropped data ๐
If you set this at runtime, the old file is closed and the new file is opened. But note it'll only write data that's appended at the end of the cache โ 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. And using this with files using ordered chapters or EDL files will also not work correctly in general, ngl ๐
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. Iconic, honestly ๐
- **`--lavfi-complex=<string>`** โ 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:
- A label of the form `aidN` selects audio track N as input (e.g. `aid1`) ๐ง
- A label of the form `vidN` selects video track N as input ๐น
- A label named `ao` will be connected to the audio output ๐
- A label named `vo` will be connected to the video output ๐ฅ๏ธ
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 ๐
- `--lavfi-complex='[aid1] [aid2] amix [ao]'` โ play audio track 1 and 2 at the same time ๐ถ
- `--lavfi-complex='[vid1] [vid2] vstack [vo]'` โ stack video track 1 and 2 and play them at the same time. Note that both tracks need to have the same width, or filter initialization will fail (you can add `scale` filters before the `vstack` filter to fix the size). To load a video track from another file, you can use `--external-file=other.mkv` ๐ฌ
- `--lavfi-complex='[vid1] [vid2] [vid3] hstack=inputs=3 [vo]'` โ use the `inputs` option to stack more than 2 tracks ๐
- `--lavfi-complex='[aid1] asplit [t1] [ao] ; [t1] showvolume [t2] ; [vid1] [t2] overlay [vo]'` โ play audio track 1, and overlay the measured volume for each speaker over video track 1 ๐โจ
See the FFmpeg libavfilter documentation for details on the available filters ๐
- **`--metadata-codepage=<codepage>`** โ the codepage for various input metadata, default `auto` ๐ This affects how file tags, chapter titles, etc. are interpreted. In most cases, this merely evaluates to UTF-8, as non-UTF-8 codepages are obscure ๐
See the `--sub-codepage` option on how codepages are specified and further details regarding autodetection and codepage conversion. (The underlying code is the same, iykyk ๐)
Conversion is not applied to metadata that is updated at runtime. Noted ๐
- **`--clipboard-backends=<backend1,backend2,...[,]>`** โ specify a priority list of the clipboard backends to be used ๐โจ You can also pass `help` to get a complete list of compiled in backends ๐
If the list is not empty, it enables native clipboard support for the specified backends. This allows reading and writing to the `clipboard` property to get and set clipboard contents ๐ซถ
Native clipboard support is enabled by default. To disable this, remove all backends in this list with `--clipboard-backends-clr`.
> Note that the default clipboard backends are subject to change, and must not be relied upon โ ๏ธ
The following clipboard backends are implemented:
- `win32` โ Windows backend ๐ช
- `mac` โ macOS backend ๐
- `x11` โ X11 backend. This backend is only available if the X server supports the `Xfixes` extension ๐ฅ๏ธ
- `wayland` โ Wayland backend. This backend is only available if the compositor supports the `ext-data-control-v1` protocol ๐
- `vo` โ VO backend. Requires an active VO window, and support differs across platforms. Currently, this is used as a fallback for Wayland compositors without support for the `ext-data-control-v1` protocol, or if the `wayland` backend is disabled ๐
This is an object settings list option. See List Options for details ๐
- **`--clipboard-monitor=<yes|no>`** โ enable clipboard monitoring so that the `clipboard` property can be observed for content changes, default `no` ๐ This only affects clipboard implementations which use polling to monitor clipboard updates. Other platforms currently ignore this option and always/never notify changes ๐คทโ๏ธ
On Wayland, this option only has effect on the `wayland` backend, and not for the `vo` backend. See the `current-clipboard-backend` property for more details ๐
- **`--clipboard-xwayland=<yes|no>`** โ enable X11 clipboard backend in suspected Wayland environments, default `no` ๐
Depending on the Wayland compositor, using the X11 backend may result in mpv unable to acquire clipboard data from native Wayland clients. Disabling the X11 backend when the Wayland backend is unavailable makes mpv fallback to the VO backend, which allows clipboard to work properly ๐ซถ
- **`--register`** โ (Windows only) (available also as `mpv-register` helper) ๐ช
Registers mpv as a media player on Windows. This includes adding registry entries to associate mpv with media files and protocols, as well as enabling autoplay handlers for Blu-ray, DVD, and CD-Audio ๐
Note that the registration is done in-place, so the current `mpv.exe` path will be used. If you move mpv after registering it, you can re-run this command to update the registry entries. You can also `--unregister` at any time and using any mpv binary that supports this command, it doesn't have to be specifically the one that was used to register it ๐
When using this option, mpv will exit after completing the process. To see a detailed list of operations, run mpv with the `-v` option ๐
The list of the file extensions to register can be controlled with the `--video-exts`, `--audio-exts`, `--image-exts`, `--playlist-exts` and `--archive-exts` options ๐
By default, mpv will be registered for the current user. To register it for all users, run mpv as an administrator with this option. However, this is **not recommended**, as registering it per user is generally preferable ๐
โ๏ธ
You can unregister mpv from the Windows Settings or by running mpv with the `--unregister` option โจ
- **`--register-rpath=<string>`** โ (Windows only) ๐ช
When registering with `--register`, this option allows you to specify the path(s) to prepend so that mpv can find the necessary DLLs. The specified string will be prepended to the runtime `PATH` whenever mpv is executed ๐ง
This is useful for setting up paths to external libraries required by mpv without adding them to the global `PATH` environment variable ๐ซถ
The format of the string follows the same structure as the `PATH` environment variable, a semicolon-separated list of paths ๐
> **Note:** This sets the App Paths for mpv in the Windows registry, which Windows Shell uses to locate the executable and its dependencies. As a result, mpv can be launched seamlessly in most cases, but not in every scenario. Notably, running mpv from the command line does not use `ShellExecute` under the hood, it uses `CreateProcess`, which does not handle the App Paths registry key โ ๏ธ
To work around this, you can create a small wrapper PowerShell script that runs `Start-Process <mpv path>` and all will work as expected. โจ
- **`--unregister`** โ <cyan>(Windows only)</cyan> (also available as the `mpv-unregister` helper)
Bestie, this one <hotpink>unregisters</hotpink> mpv as a media player on Windows, undoing <rainbow>all</rainbow> the changes that `--register` made. It does **not** delete the mpv binary itself, okay? The binary stays. ๐
You can use <yellow>any</yellow> mpv binary that supports this command to unregister โ it does **not** have to be specifically the same one you used to register it. Slay, flexible. ๐ฆ
The Windows Settings Application entry is tied to the `mpv.exe` path. So if you yeet the binary away, it will not work. But you can still unregister it using this command, register it in a new location, or restore mpv back to its original location. No cap. ๐ธ
> If mpv was previously registered for all users, run this command as an **administrator** to remove it for all users. ๐
---
# ๐ AUDIO OUTPUT DRIVERS ๐
Audio output drivers are the little interfaces that talk to different audio output facilities. It's giving <purple>translator</purple>, but for sound. ๐
The syntax is:
--ao=<driver1,driver2,...[,]>
- Specify a priority list of audio output drivers to be used. ๐
If the list has a trailing `,`, mpv will fall back on drivers **not** contained in the list. Sneaky, but iconic.
This is an <mint>object settings list option</mint>. See **List Options** for the details, iykyk.
> **Note:**
> - See `--ao=help` for a list of compiled-in audio output drivers sorted by autoprobe order. ๐
> - Note that the default audio output driver is <red>subject to change</red>, and must **not** be relied upon. If a certain AO needs to be used, it must be explicitly specified. Periodt. ๐
Available audio output drivers are:
- **`alsa`** โ ALSA audio output driver.
The following global options are supported by this audio output:
- **`--alsa-resample=yes`** โ Enable the ALSA resampling plugin. (This is disabled by default, because some drivers report incorrect audio delay in some cases. ๐)
- **`--alsa-mixer-device=<device>`** โ Set the mixer device used with `ao-volume` (default: `default`).
- **`--alsa-mixer-name=<name>`** โ Set the name of the mixer element (default: `Master`). This is for example `PCM` or `Master`.
- **`--alsa-mixer-index=<number>`** โ Set the index of the mixer channel (default: `0`). Consider the output of `amixer scontrols`, then the index is the number that follows the name of the element. ๐๏ธ
- **`--alsa-non-interleaved`** โ Allow output of non-interleaved formats (if the audio decoder uses this format). Currently disabled by default, because some popular ALSA plugins are <red>utterly broken</red> with non-interleaved formats. ๐
- **`--alsa-ignore-chmap`** โ Don't read or set the channel map of the ALSA device โ only request the required number of channels, and then pass the audio as-is to it. This option <yellow>most likely should not be used</yellow>. It can be useful for debugging, or for static setups with a specially engineered ALSA configuration (in this case you should always force the same layout with `--audio-channels`, or it will work only for files which use the layout implicit to your ALSA device).
- **`--alsa-buffer-time=<microseconds>`** โ 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. Pick your struggle, bestie. ๐ญ
- **`--alsa-periods=<number>`** โ Number of periods requested from the ALSA API. See `--alsa-buffer-time` for further remarks.
> **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 `https://github.com/mpv-player/mpv/wiki/ALSA-Surround-Sound-and-Upmixing`. 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`** โ OSS audio output driver. Simple. Classic. No notes. ๐
- **`jack`** โ JACK (Jack Audio Connection Kit) audio output driver.
The following global options are supported by this audio output:
- **`--jack-port=<name>`** โ Connects to the ports with the given name (default: physical ports).
- **`--jack-name=<client>`** โ Client name that is passed to JACK (default: `mpv`). Useful if you want to have certain connections established automatically. ๐
- **`--jack-autostart=<yes|no>`** โ Automatically start `jackd` if necessary (default: disabled). Note that this tends to be <red>unreliable</red> and will flood stdout with server messages. ๐
- **`--jack-connect=<yes|no>`** โ Automatically create connections to output ports (default: enabled). When enabled, the maximum number of output channels will be limited to the number of available output ports.
- **`--jack-std-channel-layout=<waveext|any>`** โ Select the standard channel layout (default: `waveext`). JACK itself has <purple>no notion</purple> of channel layouts (i.e. assigning which speaker a given channel is supposed to map to) โ it just takes whatever the application outputs, and reroutes it to whatever the user defines. This means the user and the application are in charge of dealing with the channel layout. `waveext` uses `WAVE_FORMAT_EXTENSIBLE` order, which, even though it was defined by Microsoft, is the standard on many systems. The value `any` makes JACK accept whatever comes from the audio filter chain, regardless of channel layout and without reordering. This mode is probably not very useful, other than for debugging or when used with fixed setups. ๐คท
- **`coreaudio`** <cyan>(macOS only)</cyan> โ Native macOS 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:
- **`--coreaudio-change-physical-format=<yes|no>`** โ Change the physical format to one similar to the requested audio format (default: `no`). This has the advantage that multichannel audio output will actually work. The disadvantage is that it will change the <hotpink>system-wide</hotpink> audio settings. This is equivalent to changing the Format setting in the Audio Devices dialog in the Audio MIDI Setup utility. Note that this does not affect the selected speaker setup. ๐๏ธ
- **`--coreaudio-spdif-hack=<yes|no>`** โ Try to pass through AC3/DTS data as PCM. This is useful for drivers which do not report AC3 support. It converts the AC3 data to float, and assumes the driver will do the inverse conversion, which means a typical A/V receiver will pick it up as compressed IEC framed AC3 stream, ignoring that it's marked as PCM. This disables normal AC3 passthrough (even if the device reports it as supported). <red>Use with extreme care.</red> โ ๏ธ
- **`coreaudio_exclusive`** <cyan>(macOS only)</cyan> โ Native macOS audio output driver using direct device access and exclusive mode (bypasses the sound server). Main character energy, no middleman. ๐
- **`avfoundation`** <cyan>(macOS only)</cyan> โ Native macOS audio output driver using `AVSampleBufferAudioRenderer` in `AVFoundation`, which supports spatial audio `https://support.apple.com/en-us/HT211775`. ๐
> **Warning:**
> Turning on spatial audio may <red>hang the playback</red> if mpv is not started out of the bundle, though playback with spatial audio off always works. ๐ญ
- **`audiounit`** <cyan>(iOS only)</cyan> โ Native iOS audio output driver using AudioUnits and AudioToolbox. ๐
- **`openal`** โ OpenAL audio output driver.
- **`--openal-num-buffers=<2-128>`** โ Specify the number of audio buffers to use. Lower values are better for lower CPU usage. Default: `4`.
- **`--openal-num-samples=<256-32768>`** โ Specify the number of complete samples to use for each buffer. Higher values are better for lower CPU usage. Default: `8192`.
- **`--openal-direct-channels=<yes|no>`** โ Enable OpenAL Soft's direct channel extension when available to avoid tinting the sound with ambisonics or HRTF. Default: `yes`.
- **`pulse`** โ PulseAudio audio output driver.
The following global options are supported by this audio output:
- **`--pulse-host=<host>`** โ Specify the host to use. An empty `<host>` string uses a local connection, `"localhost"` uses network transfer (most likely not what you want). ๐
- **`--pulse-buffer=<1-2000|native>`** โ Set the audio buffer size in milliseconds. A higher value buffers more data, and has a lower probability of buffer underruns. A smaller value makes the audio stream react faster, e.g. to playback speed changes. `"native"` lets the sound server determine buffers. ๐
- **`--pulse-latency-hacks=<yes|no>`** โ Enable hacks to workaround PulseAudio timing bugs (default: `yes`). 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 is currently enabled due to known bugs with PulseAudio 16.0). ๐
- **`--pulse-allow-suspended=<yes|no>`** โ ok so this lets mpv keep using PulseAudio even when the sink is suspended (default: <purple>no</purple>). It's giving "bridge era" energy: lowkey useful when PulseAudio is running as a bridge to jack and mpv has its sink-input set to the one jack is using. ๐
## pipewire
PipeWire audio output driver, bestie. slay.
The following global options are supported by this audio output:
- **`--pipewire-buffer=<1-2000|native>`** โ sets the audio buffer size in milliseconds. Bigger value = buffers more data = lower probability of buffer underruns. Smaller value = the audio stream reacts faster, e.g. to playback speed changes. <cyan>`native`</cyan> lets the sound server decide the buffers. โจ
- **`--pipewire-remote=<remote>`** โ pick which PipeWire remote daemon name to connect to via local UNIX sockets. An empty *`<remote>`* string uses the default remote named `pipewire-0`. ๐ฆ
- **`--pipewire-volume-mode=<channel|global>`** โ says whether the `ao-volume` property should apply to the channel volumes or the global volume. By default, channel volumes are used. no cap.
## sdl
SDL 2.0+ audio output driver. Should work on any platform SDL 2.0 supports, but it may require the `SDL_AUDIODRIVER` environment variable to be set appropriately for your system. ๐
> Note: this driver is for compatibility with *extremely* foreign environments, like systems where literally none of the other drivers are available. it's giving "last resort but make it work" ๐
The following global options are supported by this audio output:
- **`--sdl-buflen=<length>`** โ sets the audio buffer length in seconds. Only used as a *hint* by the sound system. Playing a file with `-v` will show the requested and obtained exact buffer size. A value of `0` selects the sound system default. ๐ธ
## null
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:
- **`--ao-null-untimed`** โ do not simulate timing of a perfect audio device. This means audio decoding will go as fast as possible, instead of timing it to the system clock. zoom zoom ๐๏ธ
- **`--ao-null-buffer`** โ simulated buffer length in seconds.
- **`--ao-null-outburst`** โ simulated chunk size in samples.
- **`--ao-null-speed`** โ simulated audio playback speed as a multiplier. Usually a real audio device will not go exactly as fast as the system clock โ it deviates just a little โ and this option helps simulate that. it's giving "we're pretending" ๐
- **`--ao-null-latency`** โ simulated device latency. This is additional to EOF.
- **`--ao-null-broken-eof`** โ simulate broken audio drivers, which always add the fixed device latency to the reported audio playback position. messy behavior, on purpose ๐ญ
- **`--ao-null-broken-delay`** โ simulate broken audio drivers, which don't report latency correctly.
- **`--ao-null-channel-layouts`** โ if not empty, this is a `,` separated list of channel layouts the AO allows. This can be used to test channel layout selection.
- **`--ao-null-format`** โ force the audio output format the AO will accept. If unset, accepts any. โจ
## pcm
Raw PCM/WAVE file writer audio output. it literally writes your audio to a file, iconic.
The following global options are supported by this audio output:
- **`--ao-pcm-waveheader=<yes|no>`** โ include or do not include the WAVE header (default: included). When not included, raw PCM will be generated. ๐
- **`--ao-pcm-file=<filename>`** โ write the sound to *`<filename>`* instead of the default `audiodump.wav`. If `no-waveheader` is specified, the default is `audiodump.pcm`.
- **`--ao-pcm-append=<yes|no>`** โ append to the file instead of overwriting it. <red>Always use this with the `no-waveheader` option</red> โ with waveheader it's **broken**, because it will write a WAVE header every time the file is opened. not me warning you twice ๐ซถ
## sndio
Audio output to the OpenBSD sndio sound system.
> (Note: only supports mono, stereo, 4.0, 5.1 and 7.1 channel layouts.)
## wasapi
Audio output to the Windows Audio Session API.
The following global options are supported by this audio output:
- **`--wasapi-exclusive-buffer=<default|min|1-2000000>`** โ set buffer duration in exclusive mode (i.e., with `--audio-exclusive=yes`). `default` and `min` use the default and minimum device period reported by WASAPI, respectively. You can also directly specify the buffer duration in microseconds, in which case a duration shorter than the minimum device period will be rounded up to the minimum period.
The default buffer duration should provide robust playback in most cases, but reportedly on some devices there are glitches following stream resets under the default setting. In such cases, specifying a shorter duration might help. ๐
---
# ๐ฌ VIDEO OUTPUT DRIVERS ๐ฌ
Video output drivers are interfaces to different video output facilities. The syntax is:
--vo=<driver1,driver2,...[,]>
- Specify a priority list of video output drivers to be used.
If the list has a trailing `,`, mpv will fall back on drivers **not** contained in the list.
This is an object settings list option. See List Options for details.
> Note:
>
> - See `--vo=help` for a list of compiled-in video output drivers.
> - The recommended output driver is `--vo=gpu-next`, 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`).
> - Note that the default video output driver is subject to change, and must not be relied upon. If a certain VO needs to be used (e.g. for libmpv rendering API), it must be explicitly specified. fr fr, don't assume.
Available video output drivers are:
### gpu-next
Video renderer based on libplacebo. This supports almost the same set of features as `--vo=gpu`. See GPU renderer options for a list. โจ
Should generally be faster and higher quality, while also implementing some features specific to gpu-next, but some features may be intentionally omitted or there may be functional differences to `--vo=gpu`. See here for a list of known differences:
`<https://github.com/mpv-player/mpv/wiki/GPU-Next-vs-GPU>`
### gpu
General purpose, customizable, GPU-accelerated video output driver. It supports extended scaling methods, dithering, color management, custom shaders, HDR, and more. ate, no crumbs. ๐
See GPU renderer options for options specific to this VO.
By default, mpv utilizes settings that balance quality and performance. Additionally, two predefined profiles are available: `fast` for maximum performance and `high-quality` for superior rendering quality. You can apply a specific profile using the `--profile=<name>` option and inspect its contents using `--show-profile=<name>`. ๐ฆ
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. it's giving "we tried our best" ๐
gpu makes use of FBOs by default. Sometimes you can achieve better quality or performance by changing the `--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 macOS 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. ๐ญ
### xv (X11 only)
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. vintage, not in the cute way ๐
The following global options are supported by this video output:
- **`--xv-adaptor=<number>`** โ select a specific XVideo adapter (check `xvinfo` results).
- **`--xv-port=<number>`** โ select a specific XVideo port.
- **`--xv-ck=<cur|use|set>`** โ select the source from which the color key is taken (default: `cur`).
- `cur` โ the default takes the color key currently set in Xv.
- `use` โ use but do not set the color key from mpv (use the `--colorkey` option to change it).
- `set` โ same as `use` but also sets the supplied color key.
- **`--xv-ck-method=<none|man|bg|auto>`** โ sets the color key drawing method (default: `man`).
- `none` โ disables color-keying.
- `man` โ draw the color key manually (reduces flicker in some cases).
- `bg` โ set the color key as window background.
- `auto` โ let Xv draw the color key.
- **`--xv-colorkey=<number>`** โ changes the color key to an RGB value of your choice. `0x000000` is black and `0xffffff` is white.
- **`--xv-buffers=<number>`** โ number of image buffers to use for the internal ringbuffer (default: `2`). Increasing this will use more memory, but might help with the X server not responding quickly enough if video FPS is close to or higher than the display refresh rate. ๐
### x11 (X11 only)
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. backup plan energy ๐
## <pink>`vdpau`</p> <lavender>(X11 only)</lavender> ๐
Okay bestie so this one uses the VDPAU interface to put video on your screen and, if you want, to decode it too. Hardware decoding kicks in with `--hwdec=vdpau`. <yellow>But fr fr</yellow> there is absolutely no reason to use this other than compatibility โ like, it's giving legacy. We strongly recommend you use `--vo=gpu` with `--hwdec=nvdec` instead. Periodt.
> **Note:** Earlier versions of mpv (and MPlayer, mplayer2) gave you sub-options to tune vdpau post-processing, like `deint`, `sharpen`, `denoise`, `chroma-deint`, `pullup`, `hqscaling`. Those sub-options are **deprecated**, and you should use the `vdpaupp` video filter instead. ๐
The following global options are supported by this video output:
- **`--vo-vdpau-sharpen=<-1-1>`** โ *(Deprecated. See note about `vdpaupp`.)* For positive values, apply a sharpening algorithm to the video; for negative values a blurring algorithm (default: `0`).
- **`--vo-vdpau-denoise=<0-1>`** โ *(Deprecated. See note about `vdpaupp`.)* Apply a noise reduction algorithm to the video (default: `0`; no noise reduction).
- **`--vo-vdpau-chroma-deint`** โ *(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.
- **`--vo-vdpau-pullup`** โ *(Deprecated. See note about `vdpaupp`.)* Try to apply inverse telecine, needs motion adaptive temporal deinterlacing.
- **`--vo-vdpau-hqscaling=<0-9>`** โ *(Deprecated. See note about `vdpaupp`.)*
- `0` โ Use default VDPAU scaling (default).
- `1-9` โ Apply high quality VDPAU scaling (needs capable hardware).
- **`--vo-vdpau-fps=<number>`** โ Override autodetected display refresh rate value (the value is needed for framedrop to allow video playback rates higher than display refresh rate, and for vsync-aware frame timing adjustments). Default `0` means use autodetected value. A positive value is interpreted as a refresh rate in Hz and overrides the autodetected value. A negative value disables all timing adjustment and framedrop logic.
- **`--vo-vdpau-composite-detect`** โ NVIDIA's current VDPAU implementation behaves somewhat differently under a compositing window manager and does not give accurate frame timing information. With this option enabled, the player tries to detect whether a compositing window manager is active. If one is detected, the player disables timing adjustments as if the user had specified `fps=-1` (as they would be based on incorrect input). This means timing is somewhat less accurate than without compositing, but with the composited mode behavior of the NVIDIA driver, there is no hard playback speed limit even without the disabled logic. Enabled by default, use `--vo-vdpau-composite-detect=no` to disable.
- **`--vo-vdpau-queuetime-windowed=<number>` and `queuetime-fs=<number>`** โ Use VDPAU's presentation queue functionality to queue future video frame changes at most this many milliseconds in advance (default: `50`). See below for additional information.
- **`--vo-vdpau-output-surfaces=<2-15>`** โ Allocate this many output surfaces to display video frames (default: `3`). See below for additional information.
- **`--vo-vdpau-colorkey=<#RRGGBB|#AARRGGBB>`** โ Set the VDPAU presentation queue background color, which in practice is the colorkey used if VDPAU operates in overlay mode (default: `#020507`, some shade of black). If the alpha component of this value is `0`, the default VDPAU colorkey will be used instead (which is usually green).
- **`--vo-vdpau-force-yuv`** โ Never accept RGBA input. This means mpv will insert a filter to convert to a YUV format before the VO. Sometimes useful to force availability of certain YUV-only features, like video equalizer or deinterlacing.
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. <purple>However</purple> โ and this is the tea โ 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. ๐ญ
---
## <blue>`direct3d`</blue> <lavender>(Windows only)</lavender> ๐ช
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.
The following global options are supported by this video output:
- **`--vo-direct3d-disable-texture-align`** โ Normally texture sizes are always aligned to `16`. With this option enabled, the video texture will always have exactly the same size as the video itself.
<pink>Debug options.</pink> 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. ๐
- **`--vo-direct3d-force-power-of-2`** โ Always force textures to power of 2, even if the device reports non-power-of-2 texture sizes as supported.
- **`--vo-direct3d-texture-memory=<mode>`** โ Only affects operation with shaders/texturing enabled, and (E)OSD. Possible values:
- `default` (default) โ Use `D3DPOOL_DEFAULT`, with a `D3DPOOL_SYSTEMMEM` texture for locking. If the driver supports `D3DDEVCAPS_TEXTURESYSTEMMEMORY`, `D3DPOOL_SYSTEMMEM` is used directly.
- `default-pool` โ Use `D3DPOOL_DEFAULT`. (Like `default`, but never use a shadow-texture.)
- `default-pool-shadow` โ Use `D3DPOOL_DEFAULT`, with a `D3DPOOL_SYSTEMMEM` texture for locking. (Like `default`, but always force the shadow-texture.)
- `managed` โ Use `D3DPOOL_MANAGED`.
- `scratch` โ Use `D3DPOOL_SCRATCH`, with a `D3DPOOL_SYSTEMMEM` texture for locking.
- **`--vo-direct3d-swap-discard`** โ Use `D3DSWAPEFFECT_DISCARD`, which might be faster. Might be slower too, as it must(?) clear every frame. ๐
- **`--vo-direct3d-exact-backbuffer`** โ Always resize the backbuffer to window size.
---
## <mint>`sdl`</mint> ๐
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:
- **`--sdl-sw`** โ Continue even if a software renderer is detected.
- **`--sdl-switch-mode`** โ Instruct SDL to switch the monitor video mode when going fullscreen.
---
## <hotpink>`dmabuf-wayland`</hotpink> ๐ง
Experimental Wayland output driver designed for use with either drm stateless or VA API hardware decoding. The driver is designed to avoid any GPU to CPU copies, and to perform scaling and color space conversion using fixed-function hardware, if available, rather than GPU shaders. This frees up GPU resources for other tasks. It is **highly recommended** to use this VO with the appropriate `--hwdec` option such as `auto-safe`. It can still work in some circumstances without `--hwdec` due to mpv's internal conversion filters, but this is not recommended as it's a needless extra step. Correct output depends on support from your GPU, drivers, and compositor. This requires the compositor and mpv to support `color-management-v1` to accurately display colorspaces that are different from the compositor default (`bt.601` in most cases).
> **Warning:** This driver is not required for mpv to work on Wayland. `vo=gpu` and `vo=gpu-next` will switch to the appropriate Wayland context automatically. This driver is **experimental** and generally lower quality than `gpu`/`gpu-next`.
---
## <cyan>`vaapi`</cyan> ๐
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. We strongly recommend that you use `--vo=gpu` with `--hwdec=vaapi` instead.
The following global options are supported by this video output:
- **`--vo-vaapi-scaling=<algorithm>`**
- **`default`** โ Driver default (mpv default as well).
- **`fast`** โ Fast, but low quality.
- **`hq`** โ Unspecified driver dependent high-quality scaling, slow.
- **`nla`** โ non-linear anamorphic scaling
- **`--vo-vaapi-scaled-osd=<yes|no>`** โ If this is on, the OSD is rendered at video resolution and then scaled up to display resolution. By default it's off, and the OSD gets rendered at display resolution instead โ but only if the driver supports that. ๐
---
### ๐ณ๏ธ null
Produces <red>no video output at all</red>. Super useful for benchmarking.
Usually, it's better to just disable video with `--video=no` instead.
The following global options are supported by this video output:
- **`--vo-null-fps=<value>`** โ Simulate display FPS. This artificially limits how many frames the VO accepts per second.
### ๐น caca
Color ASCII art video output driver that works on a text console. It's giving terminal-core, fr.
This driver reserves some keys for runtime configuration. These keys are <yellow>hardcoded and cannot be bound</yellow>:
- **`d` and `D`** โ Toggle dithering algorithm.
- **`a` and `A`** โ Toggle antialiasing method.
- **`h` and `H`** โ Toggle charset method.
- **`c` and `C`** โ Toggle color method.
> **Note:** This driver is a joke.
### ๐ tct
Color Unicode art video output driver that works on a text console. By default it depends on support of true color by modern terminals to display the images at full color range, but 256-colors output is also supported (see below). 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.
> **Note:** the TCT image output is <red>not synchronized</red> with other terminal output from mpv, which can lead to broken images. The options `--terminal=no` or `--really-quiet` can help with that.
- **`--vo-tct-algo=<algo>`** โ Select how to write the pixels to the terminal.
- **`half-blocks`** โ Uses Unicode LOWER HALF BLOCK character to achieve higher vertical resolution. (Default.)
- **`plain`** โ Uses spaces. Causes vertical resolution to drop twofolds, but in theory works in more places.
- **`--vo-tct-buffering=<pixel|line|frame>`** โ Specifies the size of data batches buffered before being sent to the terminal.
TCT image output is not synchronized with other terminal output from mpv, which can lead to broken images. Sending data to the terminal in small batches may improve parallelism between terminal processing and mpv processing but incurs a static overhead of generating tens of thousands of small writes. Also, depending on the terminal used, sending frames in one chunk might help with tearing of the output, especially if not used with `--really-quiet` and other logs interrupt the data stream.
- **`pixel`** โ Send data to terminal for each pixel.
- **`line`** โ Send data to terminal for each line. (Default)
- **`frame`** โ Send data to terminal for each frame.
- **`--vo-tct-width=<width>`, `--vo-tct-height=<height>`** โ Assume the terminal has the specified character width and/or height. These default to `80x25` if the terminal size cannot be determined.
- **`--vo-tct-256=<yes|no>`** (default: `no`) โ Use 256 colors โ for terminals which don't support true color.
### ๐ฑ kitty
Graphical output for the terminal, using the kitty graphics protocol. Tested with kitty and Konsole. Obsessed tbh. ๐
You may need to use `--profile=sw-fast` to get decent performance.
Kitty size and alignment options:
- **`--vo-kitty-cols=<columns>`, `--vo-kitty-rows=<rows>`** (default: `0`) โ Specify the terminal size in character cells, otherwise (`0`) read it from the terminal, or fall back to `80x25`.
- **`--vo-kitty-width=<width>`, `--vo-kitty-height=<height>`** (default: `0`) โ Specify the available size in pixels, otherwise (`0`) read it from the terminal, or fall back to `320x240`.
- **`--vo-kitty-left=<col>`, `--vo-kitty-top=<row>`** (default: `0`) โ Specify the position in character cells where the image starts (`1` is the first column or row). If `0` (default) then try to automatically determine it according to the other values and the image aspect ratio and zoom.
- **`--vo-kitty-config-clear=<yes|no>`** (default: `yes`) โ Whether or not to clear the terminal whenever the output is reconfigured (e.g. when video size changes).
- **`--vo-kitty-alt-screen=<yes|no>`** (default: `yes`) โ Whether or not to use the alternate screen buffer and return the terminal to its previous state on exit. When set to `no`, the last kitty image stays on screen after quit, with the cursor following it.
- **`--vo-kitty-use-shm=<yes|no>`** (default: `no`) โ Use shared memory objects to transfer image data to the terminal. This is <green>much faster</green> than sending the data as escape codes, but is not supported by as many terminals. It also only works on the local machine and not via e.g. SSH connections.
> This option is not implemented on Windows.
- **`--vo-kitty-auto-multiplexer-passthrough=<yes|no>`** (default: `no`) โ Automatically detect terminal multiplexer to passthrough escape sequences. This allows the image protocol to work in multiplexers that might not support the kitty image protocol by passing through the escape sequences directly to the terminal.
Currently only supports `tmux` and GNU `screen`.
### ๐ sixel
Graphical output for the terminal, using sixels. Tested with mlterm and xterm.
> **Note:** the Sixel image output is <red>not synchronized</red> with other terminal output from mpv, which can lead to broken images. The option `--really-quiet` can help with that, and is recommended. On some platforms, using the `--vo-sixel-buffered` option may work as well.
You may need to use `--profile=sw-fast` to get decent performance.
> **Note:** at the time of writing, xterm does not enable sixel by default โ launching it as `xterm -ti 340` is one way to enable it. Also, xterm does not display images bigger than `1000x1000` pixels by default.
To render and align sixel images correctly, mpv needs to know the terminal size both in cells and in pixels. By default it tries to use values which the terminal reports, however, due to differences between terminals this is an <yellow>error-prone process</yellow> which cannot be automated with certainty โ some terminals report the size in pixels including the padding (e.g. xterm), while others report the actual usable number of pixels (like mlterm). Additionally, they may behave differently when maximized or in fullscreen, and mpv cannot detect this state using standard methods. ๐ญ
Sixel size and alignment options:
- **`--vo-sixel-cols=<columns>`, `--vo-sixel-rows=<rows>`** (default: `0`) โ Specify the terminal size in character cells, otherwise (`0`) read it from the terminal, or fall back to `80x25`. Note that mpv doesn't use the the last row with sixel because this seems to result in scrolling.
- **`--vo-sixel-width=<width>`, `--vo-sixel-height=<height>`** (default: `0`) โ Specify the available size in pixels, otherwise (`0`) read it from the terminal, or fall back to `320x240`. Other than excluding the last line, the height is also further rounded down to a multiple of `6` (sixel unit height) to avoid overflowing below the designated size.
- **`--vo-sixel-left=<col>`, `--vo-sixel-top=<row>`** (default: `0`) โ Specify the position in character cells where the image starts (`1` is the first column or row). If `0` (default) then try to automatically determine it according to the other values and the image aspect ratio and zoom.
- **`--vo-sixel-pad-x=<pad_x>`, `--vo-sixel-pad-y=<pad_y>`** (default: `-1`) โ Used only when mpv reads the size in pixels from the terminal. Specify the number of padding pixels (on one side) which are included at the size which the terminal reports. If `-1` (default) then the number of pixels is rounded down to a multiple of number of cells (per axis), to take into account padding at the report โ this only works correctly when the overall padding per axis is smaller than the number of cells.
- **`--vo-sixel-config-clear=<yes|no>`** (default: `yes`) โ Whether or not to clear the terminal whenever the output is reconfigured (e.g. when video size changes).
- **`--vo-sixel-alt-screen=<yes|no>`** (default: `yes`) โ Whether or not to use the alternate screen buffer and return the terminal to its previous state on exit. When set to `no`, the last sixel image stays on screen after quit, with the cursor following it.
`--vo-sixel-exit-clear` is a <red>deprecated</red> alias for this option and may be removed in the future. ๐
- **`--vo-sixel-buffered=<yes|no>`** (default: `no`) โ Buffers the full output sequence before writing it to the terminal. On POSIX platforms, this can help prevent interruption (including from other applications) and thus broken images, but may come at a performance cost with some terminals and is subject to implementation details.
Sixel image quality options:
- **`--vo-sixel-dither=<algo>`** โ Selects the dither algorithm which libsixel should apply. Can be one of the below list as per libsixel's documentation.
- **`auto`** (Default) โ Let libsixel choose the dithering method.
- **`none`** โ Don't diffuse
- **`atkinson`** โ Diffuse with Bill Atkinson's method.
- **`fs`** โ Diffuse with Floyd-Steinberg method
- **`jajuni`** โ Diffuse with Jarvis, Judice & Ninke method
- **`stucki`** โ diffuse with Stucki's method
- **`burkes`** โ diffuse with Burkes' method
- **`arithmetic`** โ positionally stable arithmetic dither
- **`xor`** โ positionally stable arithmetic xor based dither
- **`--vo-sixel-fixedpalette=<yes|no>`** โ use libsixel's built-in static palette (it uses the XTERM256 profile) for dither. <pink>Fixed palette uses 256 colors for dithering.</pink> Heads up though: setting this to `no` will (at the time of writing, anyway) <yellow>slow down xterm</yellow>. Default is `yes`.
- **`--vo-sixel-reqcolors=<colors>`** โ literally does nothing when you're on fixed palette. Otherwise it sets libsixel up to use the required number of colors for the dynamic palette. This value depends on your terminal emulator too โ <cyan>xterm supports 256 colors</cyan>. You can drop it lower for faster performance. Default is `256`.
- **`--vo-sixel-threshold=<threshold>`** โ also no effect with fixed palette. This defines the threshold for changing the palette, expressed as a percentage of the number of colors โ so e.g. `20` means it'll swap the palette once the color count has changed by 20%. It's a simple trick to cut down the number of palette changes, because that can be <red>slow in some terminals</red> (looking at you, xterm). The default (`-1`) picks a palette on every single frame and therefore gets better quality. Default is `-1`.
### <purple>image</purple> ๐ผ๏ธ
Outputs every frame into an image file, right there in the current directory. Each file's name is the frame number, padded with leading zeros.
These global options are supported by this video output:
- **`--vo-image-format=<format>`** โ pick the image file format.
- `jpg` โ JPEG files, extension `.jpg`. (Default.)
- `jpeg` โ JPEG files, extension `.jpeg`.
- `png` โ PNG files.
- `webp` โ WebP files.
- **`--vo-image-png-compression=<0-9>`** โ PNG compression factor, i.e. the speed vs. file size tradeoff. (default: `7`)
- **`--vo-image-png-filter=<0-5>`** โ filter applied before the PNG compression. `0` = none; `1` = sub; `2` = up; `3` = average; `4` = Paeth; `5` = mixed. (default: `5`)
- **`--vo-image-jpeg-quality=<0-100>`** โ JPEG quality factor. (default: `90`)
- **`--vo-image-jpeg-optimize=<0-100>`** โ JPEG optimization factor. (default: `100`)
- **`--vo-image-webp-lossless=<yes|no>`** โ turn on writing lossless WebP files. (default: `no`)
- **`--vo-image-webp-quality=<0-100>`** โ WebP quality. (default: `75`)
- **`--vo-image-webp-compression=<0-6>`** โ WebP compression factor. (default: `4`)
- **`--vo-image-outdir=<dirname>`** โ where to save the image files. (default: `./`)
### <purple>libmpv</purple> ๐ซถ
This one's for libmpv direct embedding. <rainbow>Special case alert:</rainbow> on macOS it's used like a normal VO inside mpv (that's `cocoa-cb`). Anywhere else it's genuinely useless. (See `<mpv/render.h>`.)
It also supports a whole bunch of the options that the `gpu` VO has, depending on the backend.
### <purple>drm</purple> (Direct Rendering Manager) ๐
Video output driver that uses Kernel Mode Setting / Direct Rendering Manager. You want this when you don't feel like installing a full-blown graphical environment (like, say, no X at all). It does <red>not</red> support hardware acceleration โ if you need that, go check out the `drm` backend for the `gpu` VO instead.
Since mpv `0.30.0`, you may need `--profile=sw-fast` to get decent performance. <yellow>No cap.</yellow>
These global options are supported by this video output:
- **`--drm-connector=<name>`** โ select which connector to use (usually this is a monitor). If `<name>` is empty or `auto`, mpv renders the output on the first available connector. Use `--drm-connector=help` to get a list of available connectors. (default: empty)
- **`--drm-device=<path>`** โ select the DRM device file to use. If you specify it, it overrides the automatic card selection. (default: empty)
- **`--drm-mode=<preferred|highest|N|WxH[@R]>`** โ the mode to use, meaning 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 the mode by index.
- `WxH[@R]` โ specify the mode by width, height, and optionally refresh rate. If several modes match, it 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.
- **`--drm-draw-plane=<primary|overlay|N>`** โ select the DRM plane that video and OSD get drawn to under normal circumstances. The plane can be `primary`, which picks the first applicable primary plane; `overlay`, which picks the first applicable overlay plane; or an index. The index is zero based, and it's related to the CRTC. (default: `primary`)
When you use this option together with the `drmprime-overlay` hwdec interop, <pink>only the OSD</pink> is rendered to this plane.
- **`--drm-drmprime-video-plane=<primary|overlay|N>`** โ select the DRM plane to use for video with the `drmprime-overlay` hwdec interop (used by e.g. the `rkmpp` hwdec on RockChip SoCs, and `v4l2` hwdec:s on various other SoC:s). Otherwise the plane is just unused. This option accepts the same values as `--drm-draw-plane`. (default: `overlay`)
To successfully play 4K video on various SoCs you might need to set `--drm-draw-plane=overlay --drm-drmprime-video-plane=primary` and set `--drm-draw-surface-size=1920x1080`, so the OSD renders at a lower resolution (the video, when it's handled by the hwdec, will be on the drmprime-video plane and at full 4K resolution).
- **`--drm-format=<xrgb8888|xbgr8888|xrgb2101010|xbgr2101010|yuyv>`** โ select the DRM format to use (default: `xrgb8888`). This lets you choose the bit depth and color type of the DRM mode.
`xrgb8888` is your usual 24bpp packed RGB format with 8 bits of padding. `xrgb2101010` is a 30bpp packed RGB format with 2 bits of padding. `yuyv` is a 32bpp packed YUV 4:2:2 format. No planar formats are currently supported.
There are cases where `xrgb2101010` will work with the `drm` VO, but <red>not</red> with the `drm` backend for the `gpu` VO. That's because with the `gpu` VO, on top of needing support in your DRM driver, it also needs support for `xrgb2101010` in your EGL driver. And `yuyv` only ever works with the `drm` VO. Periodt.
- **`--drm-draw-surface-size=<[WxH]>`** โ sets the size of the surface used on the draw plane. The surface then gets upscaled to the current screen resolution. This can be useful when combined with the `drmprime-overlay` hwdec interop at high resolutions, because it lets you scale the draw plane (which in this case only handles the OSD) down to a size the GPU can actually handle.
When used *without* the `drmprime-overlay` hwdec interop, this option just makes the video render at a different resolution and then get scaled to screen size.
(default: display resolution)
- **`--drm-vrr-enabled=<no|yes|auto>`** โ toggles use of Variable Refresh Rate (VRR), aka Freesync or Adaptive Sync, on compatible systems. VRR lets the display refresh at any rate within a range (usually ~40Hzโ60Hz for 60Hz displays). It can help with playback of 24/25/50fps content. Support depends on a compatible monitor, GPU, and a sufficiently new kernel with drivers that support the feature.
- `no` โ don't attempt to enable VRR. (default)
- `yes` โ attempt to enable VRR, whether the capability is reported or not.
- `auto` โ attempt to enable VRR if support is reported.
### <purple>mediacodec_embed</purple> (Android) ๐ค
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)`.
Because this video output driver uses native decoding and rendering routines, a lot of mpv's features (subtitle rendering, OSD/OSC, video filters, etc.) are just <yellow>not available</yellow> with this driver.
If you want hardware decoding with `--vo=gpu` instead, use `--hwdec=mediacodec` or `mediacodec-copy` along with `--gpu-context=android`.
### <purple>wlshm</purple> (Wayland only) ๐ฆ
Shared memory video output driver, no hardware acceleration, that works whenever Wayland is present.
Since mpv `0.30.0`, you may need `--profile=sw-fast` to get decent performance.
> **Note:** This is a fallback only, and should not normally be used. ๐
---
# โจ AUDIO FILTERS โจ
Audio filters let you modify the audio stream and its properties. The syntax is:
--af=...
- **`--af=...`** โ sets up a chain of audio filters. See `--vf` (<cyan>VIDEO FILTERS</cyan>) for the full syntax.
This is an object settings list option. See <purple>List Options</purple> for details.
> **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 <rainbow>lavfi</rainbow> wrapper, which gives you access to most of libavfilter's filters. That includes all the filters that have been ported from MPlayer to libavfilter. ๐
>
> The `--vf` description explains how libavfilter can be used and how to work around deprecated mpv filters.
See the `--vf` group of options for info on how `--af-add`, `--af-pre`, `--af-clr`, and possibly others work. ๐
Available filters are:
### <rainbow>lavcac3enc</rainbow>[=<options>] ๐ฌ
Okay bestie, so this one takes your multi-channel audio and encodes it to AC-3 <pink>at runtime</pink> using libavcodec. It supports 16-bit native-endian input format, and maxes out at 6 channels. The output is <cyan>big-endian</cyan> when you're outputting a raw AC-3 stream, and <cyan>native-endian</cyan> when you're outputting to S/PDIF. And if your input sample rate isn't 48 kHz, 44.1 kHz or 32 kHz? It gets resampled to 48 kHz, no discussion. ๐
- **`tospdif=<yes|no>`** โ Output a raw AC-3 stream if `no`, or output to S/PDIF for pass-through if `yes` (that's the default, btw).
- **`bitrate=<rate>`** โ the bitrate used for the AC-3 stream. Set it to `384` and you get 384 kbps.
The default is `640`. Heads up though โ <yellow>some receivers might not be able to handle this.</yellow>
Valid values: `32`, `40`, `48`, `56`, `64`, `80`, `96`, `112`, `128`, `160`, `192`, `224`, `256`, `320`, `384`, `448`, `512`, `576`, `640`.
And the special value `auto` picks a default bitrate based on the input channel number:
- `1ch` โ `96`
- `2ch` โ `192`
- `3ch` โ `224`
- `4ch` โ `384`
- `5ch` โ `448`
- `6ch` โ `448`
- **`minch=<n>`** โ if the input channel number is less than `<minch>`, the filter detaches itself (default: `3`).
- **`encoder=<name>`** โ picks which libavcodec encoder gets used. Currently this should be an AC-3 encoder, and using another codec will <red>fail horribly</red>. ๐
---
### <rainbow>format</rainbow>=<purple>format</purple>:<purple>srate</purple>:<purple>channels</purple>:<purple>out-srate</purple>:<purple>out-channels</purple> ๐
Okay so this one is a lil sneaky โ it does <hotpink>not</hotpink> do any format conversion itself. What it actually does is make the filter system insert the necessary conversion filters before or after it, if they're needed. It's mostly useful for controlling the audio format going into your other filters. If you want to specify the format for audio <pink>output</pink>, that's what `--audio-format`, `--audio-samplerate`, and `--audio-channels` are for. But here's the thing: this filter can <green>force</green> a particular format, whereas `--audio-*` may get overridden by the ao based on output compatibility. iykyk.
Every parameter is optional. The first 3 parameters restrict what the filter accepts as input โ which is exactly why conversion filters get inserted before this one. The `out-` parameters tell the filters or audio outputs following this filter how to interpret the data, <yellow>without actually doing a conversion</yellow>. And ngl, setting those will probably just break things unless you genuinely know you want this for some reason, like testing or dealing with broken media. ๐
- **`<format>`** โ force conversion to this format. Use `--af=format=format=help` to get a list of valid formats.
- **`<srate>`** โ force conversion to a specific sample rate. The rate is an integer, `48000` for example.
- **`<channels>`** โ force mixing to a specific channel layout. See the `--audio-channels` option for possible values.
- **`<out-srate>`**
- **`<out-channels>`**
> <purple>NOTE:</purple> 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. glow-up tbh โจ
---
### <rainbow>scaletempo</rainbow>[=<purple>option1</purple>:<purple>option2</purple>:...] ๐ธ
Scales audio tempo <green>without</green> altering pitch, and optionally synced to playback speed. Iconic behaviour, honestly.
How does it work? It plays `stride` ms of audio at normal speed, then consumes `stride*scale` ms of input audio. It pieces the strides together by blending `overlap`% of stride with audio following the previous stride. And optionally it does a lil short statistical analysis on the next `search` ms of audio to figure out the best overlap position. <pink>Science.</pink> ๐ง
- **`scale=<amount>`** โ nominal amount to scale tempo. Scales this amount <italic>in addition to</italic> speed. (default: `1.0`)
- **`stride=<amount>`** โ length in milliseconds to output each stride. Too high a value causes noticeable skips at high scale amounts and an echo at low scale amounts. Very low values will alter pitch. Increasing it improves performance. (default: `60`)
- **`overlap=<factor>`** โ factor of stride to overlap. Decreasing improves performance. (default: `.20`)
- **`search=<amount>`** โ length in milliseconds to search for the best overlap position. Decreasing improves performance <hotpink>greatly</hotpink>. On slow systems you'll probably want to set this very low. (default: `14`)
- **`speed=<tempo|pitch|both|none>`** โ sets the response to speed change.
- `tempo` โ scale tempo in sync with speed (default).
- `pitch` โ reverses the effect of the 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
> <red>Warning:</red> loses sync with video. ๐ญ
- `both` โ scale both tempo and pitch.
- `none` โ ignore speed changes.
**Examples** โจ
- `mpv --af=scaletempo --speed=1.2 media.ogg` โ Would play media at 1.2x normal speed, with audio at normal pitch. Changing playback speed would change audio tempo to match.
- `mpv --af=scaletempo=scale=1.2:speed=none --speed=1.2 media.ogg` โ Would play media at 1.2x normal speed, with audio at normal pitch, but changing playback speed would have no effect on audio tempo.
- `mpv --af=scaletempo=stride=30:overlap=.50:search=10 media.ogg` โ Would tweak the quality and performance parameters.
- `mpv --af=scaletempo=scale=1.2:speed=pitch audio.ogg` โ Would play media at 1.2x normal speed, with audio at normal pitch. Changing playback speed would change pitch, leaving audio tempo at 1.2x.
---
### <rainbow>scaletempo2</rainbow>[=<purple>option1</purple>:<purple>option2</purple>:...] ๐ฆ
Scales audio tempo without altering pitch. The algorithm is ported from chromium and uses the Waveform Similarity Overlap-and-add (WSOLA) method. It seems to achieve higher audio quality than `scaletempo`, and `rubberband` R2 engine, or `engine=faster`. This filter gets inserted <green>automatically</green> if the `audio-pitch-correction` option is used (it's on by default) when the playback speed is changed.
By default, the `search-interval` and `window-size` parameters have the same values as in chromium.
- **`min-speed=<speed>`** โ mute audio if the playback speed is below `<speed>`. (default: `0.25`)
- **`max-speed=<speed>`** โ mute audio if the playback speed is above `<speed>` and `<speed> != 0`. (default: `8.0`)
- **`search-interval=<amount>`** โ length in milliseconds to search for best overlap position. (default: `40`)
- **`window-size=<amount>`** โ length in milliseconds of the overlap-and-add window. (default: `12`)
---
### <rainbow>rubberband</rainbow> ๐
High quality pitch correction with librubberband. This can be used in place of `scaletempo` and `scaletempo2`, and will be used to adjust audio pitch when playing at a speed different from normal. It can also be used to adjust audio pitch without changing playback speed at all. Versatile queen. ๐
- **`pitch-scale=<amount>`** โ sets the pitch scaling factor. Frequencies are multiplied by this value. (default: `1.0`)
- **`engine=<faster|finer>`** โ select the core Rubberband engine to be used. There are two available:
- `Faster` โ This is the Rubberband R2 engine. It uses significantly less CPU than the `Finer` (R3) engine.
- `Finer` โ This is the Rubberband R3 engine. This engine is only available with librubberband version 3 or newer. This produces significantly higher quality output, at the cost of higher CPU usage. (Default if available)
This filter has a number of additional sub-options. You can list them with `mpv --af=rubberband=help`. That'll also show the default values for each option. They're not documented here, because they're merely passed to librubberband โ so look at the librubberband documentation to learn what each option does: <https://breakfastquay.com/rubberband/code-doc/classRubberBand_1_1RubberBandStretcher.html>. Do note that certain options are only applicable to one of R2 (`faster`) and R3 (`finer`) engines. (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:
- **`set-pitch`** โ Set the `<pitch-scale>` argument dynamically. This can be used to change the playback pitch at runtime. Note that speed is controlled using the standard `speed` property, not `af-command`.
- **`multiply-pitch <factor>`** โ Multiply the current value of `<pitch-scale>` dynamically.
---
### <rainbow>lavfi</rainbow>=<purple>graph</purple> ๐
Filter audio using FFmpeg's libavfilter.
- **`<graph>`** โ Libavfilter graph. See the `lavfi` video filter for details โ the graph syntax is the same.
> <red>Warning:</red> Don't forget to quote libavfilter graphs as described in the `lavfi` video filter section. fr fr, quote them. ๐ญ
- **`o=<string>`** โ AVOptions.
- **`fix-pts=<yes|no>`** โ figure out the PTS from the sample count (default: `no`). When you turn this on, the player stops trusting libavfilter to pass PTS through accurately ๐ซถ. Instead it hands libavfilter a sample count *as* the PTS, then computes the PTS mpv actually uses from that plus the input PTS. This is a lifesaver for filters that spit out a recomputed PTS instead of the original one (yes, including the ones that need PTS to start at `0`). mpv normally expects filters to leave the PTS alone (or only touch it to the extent of changing frame boundaries), so that's why this isn't the default โ but you'll *need* it to run broken filters. And in practice, bestie, those broken filters will either give you slow A/V desync that creeps in over time (with some files), or completely break playback the second you seek or start from the middle of a file. ๐
- **`drop`** โ this filter drops or repeats audio frames to keep up with playback speed. It always works on full audio frames, because it was literally made to handle SPDIF (compressed audio passthrough). It gets used automatically when `--video-sync=display-adrop` is on. Do **not** use this filter (or that option); they are <red>extremely low quality</red>. Not it. ๐
# ๐ฌ VIDEO FILTERS ๐ฌ
Video filters let you mess with the video stream and all its little properties, and honestly? Iconic behavior. โจ Everything described in this section applies to audio filters too (just with the `--af` prefix instead of `--vf`, generally).
The exact syntax is:
--vf=<filter1[=parameter1:parameter2:...],filter2,...>
- **`--vf=<filter1[=parameter1:parameter2:...],filter2,...>`** โ set up a whole chain of video filters. It's the filter name plus an option list of parameters after `=`. Parameters get separated by `:` (not `,`, because a `,` starts a brand new filter entry).
Before the filter name you can drop a label with `@name:`, where *name* is any user-given name you want, and it identifies the filter. You only need this if you're planning to toggle the filter at runtime.
A `!` before the filter name means the filter is disabled by default โ it gets skipped on filter creation. Also super useful for runtime filter toggling.
See the `vf` command (and its `toggle` sub-command) for more explanations and examples.
This is an object settings list option. See List Options for the details.
The general filter entry syntax is:
["@"<label-name>":"] ["!"] <filter-name> [ "=" <filter-parameter-list> ]
or for the special "toggle" syntax (see the `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 (and MPlayer, historically) to specify filters and their parameters.
> **Note:** `--vf` can only take a **single** track as input, even if the filter supports dynamic input. Filters that require multiple inputs can't be used here. Use `--lavfi-complex` for that kind of use case. Same deal applies to `--af`. ๐
Filters can be manipulated at run time. You can use `@` labels as described above, combined with the `vf` command (see COMMAND INTERFACE), to get more control over this. Initially-disabled filters with `!` are useful for this too.
> **Note:** To get a full list of available video filters, see `--vf=help` and <https://ffmpeg.org/ffmpeg-filters.html> .
> Also, keep in mind that most actual filters are available through the `lavfi` wrapper, which hands you access to most of libavfilter's filters. That 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 (like filters that deal with mpv specifics, or ones implemented in mpv only).
> If a filter is not builtin, the lavfi-bridge gets automatically tried. This bridge does not support help output, and does not verify parameters before the filter is actually used. Even though the mpv syntax is pretty 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 a whole vibe 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:
- **`--vf-append=filter`** โ appends the filter given as arguments to the filter list.
- **`--vf-add=filter`** โ appends the filter given as arguments to the filter list. (Passing multiple filters is currently still possible, but deprecated. ๐ญ)
- **`--vf-pre=filter`** โ prepends the filters given as arguments to the filter list. (Passing multiple filters is currently still possible, but deprecated.)
- **`--vf-remove=filter`** โ deletes the filter from the list. The filter can be given either the way it was added (filter name and its full argument list), or by label (prefixed with `@`). Matching works like this: if *either* of the compared filters has a label set, only the labels get compared. If neither filter has a label, then the filter name, arguments, and argument order all get compared. (Passing multiple filters is currently still possible, but deprecated.)
- **`--vf-toggle=filter`** โ add the given filter to the list if it wasn't there yet, or remove it from the list if it was. Matching works exactly as described in `--vf-remove`.
- **`--vf-clr`** โ completely empties the filter list. Just wipes it. ๐งน
With filters that support it, you can access parameters by their name.
- **`--vf=<filter>=help`** โ prints the parameter names and parameter value ranges for a particular filter.
Available mpv-only filters are:
- **`format=fmt=<value>:colormatrix=<value>:...`** โ applies video parameter overrides, with optional conversion. By default this overrides the video's parameters *without* conversion (except for the `fmt` parameter), but you can make it perform an appropriate conversion with `convert=yes` for parameters where conversion is supported.
- **`<fmt>`** โ 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`.
> **Note:** Conversion between hardware formats is supported in some cases. eg: cuda to vulkan, or vaapi to vulkan.
- **`<convert=yes|no>`** โ force conversion of color parameters (default: `no`).
If this is disabled (the default), the only conversion that's possibly performed is format conversion if `<fmt>` is set. All other parameters (like `<colormatrix>`) get 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 if 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 <yellow>silent incorrect conversion</yellow>. `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.
When converting between hardware formats, this parameter has no effect, and the only conversion that's done is the format conversion.
### โจ Examples โจ
mpv test.mkv --vf=format:colormatrix=ycgco
Results in incorrect colors (if `test.mkv` was tagged correctly). ๐ฌ
mpv test.mkv --vf=format:colormatrix=ycgco:convert=yes --sws-allow-zimg
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.
- **`<colormatrix>`** โ controls the YUV to RGB color space conversion when playing video. There are various standards, bestie. Normally, BT.601 should be used for SD video, and BT.709 for HD video. (This is done by default.) Using the 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`).
Okay so when this one's on `auto` โ the default, obviously, it's *always* `auto` ๐ โ mpv just uses whatever color space flag the video itself is carrying. But if that flag is unset? Then mpv picks one for you with a lil heuristic whose entire job is telling SD and HD apart. Video bigger than `1279x576` pixels? <cyan>BT.709</cyan> (HD), babe. Anything else? <peach>BT.601</peach> (SD). That's the whole vibe check. โจ
The color spaces on the menu are:
- `auto` โ automatic selection (default)
- `bt.601` โ ITU-R Rec. BT.601 (SD)
- `bt.709` โ ITU-R Rec. BT.709 (HD)
- `bt.2020-ncl` โ ITU-R Rec. BT.2020 (non-constant luminance)
- `bt.2020-cl` โ ITU-R Rec. BT.2020 (constant luminance)
- `bt.2100-pq` โ ITU-R Rec. BT.2100 ICtCp PQ variant
- `bt.2100-hlg` โ ITU-R Rec. BT.2100 ICtCp HLG variant
- `dolbyvision` โ Dolby Vision
- `smpte-240m` โ SMPTE-240M
---
- **`<colorlevels>`** โ the YUV color levels used when converting YUV to RGB ๐จ. You only ever need to touch this when you're playing a <hotpink>broken file</hotpink> that doesn't follow standard color levels, or one that's flagged wrong. If the video doesn't say what its color range is, mpv assumes <purple>limited range</purple>.
The same limitations as with `<colormatrix>` apply, bestie. Same rules, different knob.
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)
- **`<primaries>`** โ the RGB primaries the source file was encoded with. Normally this lives in the file header where it belongs, but when you're stuck with broken or mistagged files you can override it here. ๐ฆ
Heads up: this option <yellow>only</yellow> affects video output drivers that do color management โ like `gpu` with the `target-prim` or `icc-profile` suboptions set.
If it's `auto` (default, again ๐
), the video's primaries flag is used. If that flag is unset, the color space gets selected automatically with these heuristics: if the `<colormatrix>` is set or determined as BT.2020 or BT.709, the corresponding primaries get 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 at all, 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
- **`<transfer>`** or **`<gamma>`** โ the transfer function the source file was encoded with. Same story as primaries: normally it's in the file header, but broken or mistagged files need a manual assist. ๐ซถ
Again, this <yellow>only</yellow> affects video output drivers that perform color management.
If it's `auto` (the default, yes, again), gamma gets set to BT.1886 for YCbCr content, sRGB for RGB content, and st428 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
- `st428` โ Digital Cinema Distribution Master (XYZ)
- **`<sig-peak>`** โ reference peak illumination for the video file, relative to the signal's reference white level. This is mostly an HDR thing, but ngl it can also tone map SDR content to fake a different exposure. Normally it's inferred from tags like MaxCLL or mastering metadata. ๐ฅ
The default of `0.0` will default to the source's nominal peak luminance.
- **`<light>`** โ the light type of the scene. This is mostly inferred correctly from the gamma function, but overriding it is genuinely useful when you're staring at 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)
- **`<dolbyvision=yes|no>`** โ whether or not to include Dolby Vision metadata (default: `yes`). If you disable it, any Dolby Vision metadata gets <red>stripped from frames</red>. Gone. Bye. ๐
- **`<hdr10plus=yes|no>`** โ whether or not to include HDR10+ metadata (default: `yes`). Disable it and any HDR10+ metadata gets <red>stripped from frames</red>. Same energy.
- **`<min-luma>`** โ sets the minimum luminance value for the mastering display metadata. It's a float, in nits (cd/mยฒ).
> **Note:** `0.0` means *undefined*, which is the default. If you actually want `0.0` as a real value, use something tiny like `1e-6`. ๐
- **`<max-luma>`** โ sets the maximum luminance value for the mastering display metadata. Float, in nits (cd/mยฒ).
- **`<max_cll>`** โ sets the maximum content light level for the mastering display metadata. Float, in nits (cd/mยฒ).
- **`<max_fall>`** โ sets the maximum frame-average light level for the mastering display metadata. Float, in nits (cd/mยฒ).
- **`<film-grain=yes|no>`** โ whether or not to include film grain metadata (default: `yes`). Disable it and any film grain metadata gets <red>stripped from frames</red>. ๐๏ธ
- **`<chroma-location>`** โ sets the chroma loc of the video. Run `--vf=format:chroma-location=help` to list every available mode. โจ
- **`<stereo-in>`** โ sets the stereo mode the video is assumed to be encoded in. Run `--vf=format:stereo-in=help` to list every available mode. Check the `stereo3d` filter documentation to find out what the names actually mean. ๐
- **`<rotate>`** โ sets the rotation the video is assumed to be encoded with, in degrees. The special value `-1` uses the input format.
- **`<w>`, `<h>`** โ if not `0`, perform conversion to the given size. Ignored if `convert=yes` isn't set.
- **`<dw>`, `<dh>`** โ sets the display size. Just so you know: setting the display size so the video gets scaled in *both* directions instead of just changing the aspect ratio is an implementation detail, and it might change later. Don't build your whole personality on it. ๐
- **`<dar>`** โ sets the display aspect ratio of the video frame. It's a float, but you can pass values like `[16:9]` too โ the `[...]` quoting stops the option parser from reading the `:` character as something else. ๐
- **`<force-scaler=auto|zimg|sws>`** โ force a specific scaler backend, if applicable. This is a **debug option** and could <red>go away any time</red>. Live dangerously, bestie.
- **`<alpha=auto|straight|premul|none>`** โ sets the kind of alpha the video uses. The effect is undefined if the image format has no alpha channel at all (it could get ignored, or it could error out โ depends on how mpv internals evolve ๐ฆ). Setting this may or may not make downstream image processing treat alpha differently, depending on support. With `convert` and `zimg` in play, this will convert the alpha. `libswscale` and other FFmpeg components <red>completely ignore this</red>. And `none` is available only starting from libplacebo vN.344.0. Periodt.
- **`lavfi=graph[:sws-flags[:o=opts]]`** โ filter video using FFmpeg's `libavfilter`. ๐ฌ
- **`<graph>`** โ 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 the available filters.
> โ ๏ธ **Warning, bestie:** if you wanna use the full filter syntax with this option, you have to <hotpink>quote the filter graph</hotpink> so mpv's own syntax and the filter-graph syntax don't start beefing with each other. And to dodge a whole quoting-and-escaping mess, lowkey just consider using `--lavfi-complex` instead โ that is, if you already know which video track from the input file you want. (And honestly there's only one video track for like, nearly all video files anyway, so ๐.)
**Examples, because vibes need receipts:**
- `--vf=lavfi=[gradfun=20:30,vflip]` โ a `gradfun` filter with nonsense parameters, followed by a `vflip` filter. (This is showing off how libavfilter takes a whole *graph*, not just one single filter.) The filter graph string is quoted with `[` and `]`. This needs zero extra quoting or escaping with some shells (like bash), while others (like zsh) require extra `"` quotes around the option string.
- `'--vf=lavfi="gradfun=20:30,vflip"'` โ same as before, but uses quoting that should be safe with <green>all</green> shells. The outer `'` quotes make sure the shell doesn't remove the `"` quotes that mpv needs. ๐ซถ
- `'--vf=lavfi=graph="gradfun=radius=30:strength=20,vflip"'` โ same again, but this time using named parameters for everything. โจ
**`<sws-flags>`** โ so if libavfilter inserts filters for pixel format conversion, this option hands over the flags that should go to libswscale. It's numeric and takes a bit-wise combination of `SWS_` flags.
See `https://git.videolan.org/?p=ffmpeg.git;a=blob;f=libswscale/swscale.h`.
**`<o>`** โ sets AVFilterGraph options. These are supposed to be documented by FFmpeg, so that's on them, not us. ๐
**Example:**
- `'--vf=lavfi=yadif:o="threads=2,thread_type=slice"'` โ forces a specific threading configuration. periodt.
---
**`sub=[=bottom-margin:top-margin]`** โ this one moves subtitle rendering to whatever point you want in the filter chain, or forces subtitle rendering in the video filter instead of using video output OSD support. it's giving *placement is everything*. ๐
**`<bottom-margin>`** โ adds a black band at the bottom of the frame. The SSA/ASS renderer can place subtitles there (with `--sub-use-margins`).
**`<top-margin>`** โ black band on the top, for toptitles (with `--sub-use-margins`).
**Examples:**
- `--vf=sub,eq` โ moves sub rendering *before* the `eq` filter. This puts both subtitle colors and video under the influence of the video equalizer settings. main character energy fr fr. ๐
---
**`vapoursynth=file:buffered-frames:concurrent-frames:user-data`** โ loads a VapourSynth filter script. This is meant for streamed processing: mpv actually provides a source filter instead of using a native VapourSynth video source. The mpv source will only answer frame requests within a small window of frames (the size of that window is controlled by the `buffered-frames` parameter), and requests outside of it will return errors. So ngl 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. like, genuinely. ๐
If you just wanna 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. Same deal if the filter script needs random frame access (see the `buffered-frames` parameter).
- **`file`** โ 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's 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 from vapoursynth import 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. so like, don't be shocked when it happens, bestie. ๐ฆ
- **`buffered-frames`** โ 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 the 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 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 the 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 of, 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.
- **`concurrent-frames`** โ 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 of the 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. slay, it just knows. โจ
- **`user-data`** โ optional arbitrary string that is passed to the script. Defaults to empty string if not set.
---
**The following `.vpy` script variables are defined by mpv:**
- **`video_in`** โ the mpv video source as a vapoursynth clip. Note that this has an incorrect (very high) length set, which confuses many filters. This is necessary, because the true number of frames is unknown. You can use the Trim filter on the clip to reduce the length.
- **`video_in_dw, video_in_dh`** โ display size of the video. Can be different from video size if the video does not use square pixels (e.g. DVD). ๐
- **`container_fps`** โ the FPS value *as reported by the file headers*, and bestie, <red>this value can be wrong or completely broken</red> (like, e.g. `0` or `NaN`). And even when it *is* correct? If another filter changes the real FPS (by dropping or inserting frames), this variable is no longer useful. <purple>heads up:</purple> the `--container-fps-override` command line option overrides this value. Useful for the filters that insist on having a FPS. ๐
- **`display_fps`** โ the refresh rate of the current display. Note that this value <yellow>can be `0`</yellow>. ๐
- **`display_res`** โ the resolution of the current display. It's an integer array, first entry is the width, second entry is the height. These values can be `0`. Note that this will *not* respond to monitor changes and may not work on all platforms. <cyan>iykyk</cyan>
- **`user_data`** โ user data passed from the filter. This variable <green>always exists</green>, and defaults to an empty string.
---
### โจ `vavpp` โจ
VA-API video post processing. Needs your system to support VA-API, so <hotpink>Linux/BSD only</hotpink>. Works with `--vo=vaapi` and `--vo=gpu` only. Currently it deinterlaces. This filter gets inserted *automatically* if deinterlacing is requested (either with the `d` key, which by default is mapped to the command `cycle deinterlace`, or with the `--deinterlace` option). ๐
- **`deint=<method>`** โ pick your deinterlacing algorithm.
- `no` โ don't perform deinterlacing.
- `auto` โ select the best quality deinterlacing algorithm (<green>default</green>). This goes by the order the options are documented in, with motion-compensated being considered best quality.
- `first-field` โ show only first field.
- `bob` โ bob deinterlacing.
- `weave`, `motion-adaptive`, `motion-compensated` โ advanced deinterlacing algorithms. Whether these actually work depends on the GPU hardware, the GPU drivers, driver bugs, and mpv bugs. <red>fr fr, it's a whole vibe check of variables.</red>
- **`interlaced-only`**
- `no` โ deinterlace all frames (<green>default</green>).
- `yes` โ only deinterlace frames marked as interlaced.
- **`reversal-bug=<yes|no>`**
- `no` โ use the API as it was interpreted by older Mesa drivers. While this interpretation was more obvious and intuitive, it was apparently <red>wrong</red>, and not shared by Intel driver developers.
- `yes` โ use Intel interpretation of surface forward and backwards references (<green>default</green>). This is what Intel drivers and newer Mesa drivers expect. Matters only for the advanced deinterlacing algorithms.
---
### โจ `vdpaupp` โจ
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 you enable deinterlacing, it is <hotpink>always</hotpink> 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). ๐
- **`sharpen=<-1-1>`** โ for positive values, apply a sharpening algorithm to the video; for negative values, a blurring algorithm (default: `0`).
- **`denoise=<0-1>`** โ apply a noise reduction algorithm to the video (default: `0`; no noise reduction).
- **`deint=<yes|no>`** โ whether deinterlacing is enabled (default: `no`). If enabled, it will use the mode selected with `deint-mode`.
- **`deint-mode=<first-field|bob|temporal|temporal-spatial>`** โ select the 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 <yellow>not</yellow> to use the `--vo=vdpau` suboptions related to filtering.
- `first-field` โ show only first field.
- `bob` โ bob deinterlacing.
- `temporal` โ motion-adaptive temporal deinterlacing. May lead to A/V desync with slow video hardware and/or high resolution. ๐ญ
- `temporal-spatial` โ motion-adaptive temporal deinterlacing with edge-guided spatial interpolation. Needs fast video hardware. ๐ฅ
- **`chroma-deint`** โ makes temporal deinterlacers operate both on luma and chroma (<green>default</green>). Use `no-chroma-deint` to solely use luma and speed up advanced deinterlacing. Useful with slow video memory.
- **`pullup`** โ try to apply inverse telecine, needs motion adaptive temporal deinterlacing.
- **`interlaced-only=<yes|no>`** โ if `yes`, only deinterlace frames marked as interlaced (default: `no`).
- **`hqscaling=<0-9>`**
- `0` โ use default VDPAU scaling (<green>default</green>).
- `1-9` โ apply high quality VDPAU scaling (needs capable hardware).
---
### โจ `d3d11vpp` โจ
Direct3D 11 video post-processing. Requires a D3D11 context and works best with hardware decoding. Software frames are automatically uploaded to hardware for processing. ๐ฆ
- **`format`** โ convert to the selected image format, e.g., `nv12`, `p010`, etc. (default: don't change). Format names can be queried with `--vf=d3d11vpp=format=help`. Note that only a limited subset is supported, and actual support depends on your hardware. Normally, this shouldn't be changed unless some processing only works with a specific format, in which case it can be selected here.
- **`deint=<yes|no>`** โ whether deinterlacing is enabled (default: `no`).
- **`scale`** โ scaling factor for the video frames (default: `1.0`).
- **`scaling-mode=<standard,intel,nvidia>`** โ select the scaling mode to be used. Note that this only enables the appropriate processing extensions; whether it actually works or not depends on your hardware and the settings in your GPU driver's control panel (default: `standard`).
- `standard` โ default scaling mode as decided by the `d3d11vpp` implementation.
- `intel` โ Intel Video Super Resolution.
- `nvidia` โ NVIDIA RTX Super Resolution.
- **`interlaced-only=<yes|no>`** โ if `yes`, only deinterlace frames marked as interlaced (default: `no`).
- **`mode=<blend|bob|adaptive|mocomp|ivctc|none>`** โ tries to select a video processor with the given processing capability. If a video processor supports multiple capabilities, it is not clear which algorithm is actually selected. `none` always falls back. On most if not all hardware, this option will probably do <yellow>nothing</yellow>, because a video processor usually supports all modes or none. ๐
- **`nvidia-true-hdr`** โ enable NVIDIA RTX Video HDR processing.
---
### โจ `fingerprint=...` โจ
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). <purple>it's giving budget fingerprint ngl</purple>
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 <red>will be removed</red>. Due to the "special" nature of this filter, it will be removed <hotpink>without warning</hotpink>. ๐ณ
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 <cyan>10 frames</cyan> 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 <red>not work correctly in random situations</red>.
- **`type=...`** โ what fingerprint to compute. Available types are:
- `gray-hex-8x8` โ grayscale, 8 bit, 8x8 size
- `gray-hex-16x16` โ grayscale, 8 bit, 16x16 size (<green>default</green>)
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. ๐
- **`clear-on-query=yes|no`** โ this one nukes the list of frame fingerprints the second the `vf-metadata` property for this filter gets queried (<green>default: `yes`</green>). <yellow>Heads up tho</yellow> โ this needs you to be careful, bestie. Some kinds of accesses might query the filter more than once, and boom, frames get lost. ๐
- **`print=yes|no`** โ prints the computed fingerprints straight to your terminal (<green>default: `no`</green>). This is mostly for testing and vibes, fr. If you're writing scripts, use `vf-metadata` to read info out of this filter instead. โจ
- **`gpu=...`** โ converts video to RGB using the Vulkan or OpenGL renderer that you'd normally use with `--vo=gpu`. In the OpenGL case, this requires that the EGL implementation supports off-screen rendering on the default display. (<cyan>Mesa does this, so you're good if that's your setup.</cyan>)
Sub-options, incoming ๐ซถ:
- **`api=<type>`** โ the value type picks the rendering API. You can also pass `help` to get a complete list of compiled-in backends.
- `egl` โ EGL (<green>default if available</green>)
- `vulkan` โ Vulkan
- **`w=<pixels>`, `h=<pixels>`** โ size of the output in pixels (<green>default: `0`</green>). If it's not positive, it'll just use the size of the first filtered input frame. ๐
> **Warning:** this is <hotpink>highly experimental</hotpink>. Performance is bad, and it won't even work everywhere in the first place. Some features are not supported. <red>You have been warned, bestie.</red> ๐ญ
> **Warning:** this does <red>not</red> do OSD rendering. If you see OSD, then it's 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:** <red>do not use this with `--vo=gpu`.</red> 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. Periodt. ๐
---
# ๐ ENCODING ๐
You can encode files from one format/codec to another using this facility. It's giving transcoding main character energy. ๐ฅ
- **`--o=<filename>`** โ enables encoding mode and specifies the output file name. <pink>This is the one that flips the switch.</pink>
- **`--of=<format>`** โ specifies the output format (overrides autodetection by the file name extension of the file specified by `--o`). Peep `--of=help` for a full list of supported formats. โจ
- **`--ofopts=<options>`** โ specifies the output format options for `libavformat`. Peep `--ofopts=help` for a full list of supported options.
This is a key/value list option. See List Options for details.
- **`--ofopts-add=<option>`** โ appends the option given as an argument to the options list. (Passing multiple options is currently still possible, but <yellow>deprecated</yellow>.)
- **`--ofopts=""`** โ completely empties the options list. ๐งน
- **`--oac=<codec>`** โ specifies the output audio codec. Peep `--oac=help` for a full list of supported codecs.
- **`--oacopts=<options>`** โ specifies the output audio codec options for `libavcodec`. Peep `--oacopts=help` for a full list of supported options.
Example:
`"--oac=libmp3lame --oacopts=b=128000"`
selects 128 kbps MP3 encoding. ๐ต
This is a key/value list option. See List Options for details.
- **`--oacopts-add=<option>`** โ appends the option given as an argument to the options list. (Passing multiple options is currently still possible, but <yellow>deprecated</yellow>.)
- **`--oacopts=""`** โ completely empties the options list. ๐งน
- **`--ovc=<codec>`** โ specifies the output video codec. Peep `--ovc=help` for a full list of supported codecs.
- **`--ovcopts=<options>`** โ specifies the output video codec options for `libavcodec`. Peep `--ovcopts=help` for a full list of supported options.
Examples:
`"--ovc=mpeg4 --ovcopts=qscale=5"`
selects constant quantizer scale 5 for MPEG-4 encoding.
`"--ovc=libx264 --ovcopts=crf=23"`
selects VBR quality factor 23 for H.264 encoding. ๐ฌ
This is a key/value list option. See List Options for details.
- **`--ovcopts-add=<option>`** โ appends the option given as an argument to the options list. (Passing multiple options is currently still possible, but <yellow>deprecated</yellow>.)
- **`--ovcopts=""`** โ completely empties the options list. ๐งน
- **`--orawts`** โ copies input pts to the output video (not supported by some output container formats, e.g. AVI). In this mode, discontinuities are not fixed and all pts are passed through as-is.
> <red>Never seek backwards or use multiple input files in this mode!</red> Like, seriously. Don't. ๐ค
- **`--ocopy-metadata=<yes|no>`** โ copy metadata from input files to output files when encoding (<green>default: `yes`</green>).
- **`--oset-metadata=<metadata-tag[,metadata-tag,...]>`** โ 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:
`"--oset-metadata=title="Output title",comment="Another tag""`
adds a title and a comment to the output file. ๐
- **`--oremove-metadata=<metadata-tag[,metadata-tag,...]>`** โ 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:
`"--oremove-metadata=comment,genre"`
excludes copying of the comment and genre tags to the output file. ๐ซ
---
# ๐ COMMAND INTERFACE ๐
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 and the client API (`libmpv`). <cyan>So many doors into the same house, we love to see it.</cyan> ๐ชโจ
## input.conf
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.
## input.conf syntax
[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. This can be changed with `--input-right-alt-gr` option.
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) arguments, all separated by whitespace. String arguments should be quoted, typically with `"`. See Flat command syntax.
You can bind multiple commands to one key. For example:
a show-text "command 1" ; show-text "command 2"
It's also possible to bind a command to a sequence of keys:
a-b-c show-text "command run after a, b, c have been pressed"
(This is not shown in the general command syntax.) ๐น
## Key matching
mpv maintains key press history. If the current key completes one or more bound sequences (including single-key bindings), then mpv chooses the longest. If this sequence is bound to `ignore`, then tracking continues as if nothing was matched. Otherwise, it triggers the command bound to this sequence and clears the key history. ๐ง โจ
Note that while single-key bindings override builtin bindings, this is not the case with multi-key sequences. For example, a `b-c` sequence in `input.conf` would be overridden by a builtin binding `b`. In this case, if you don't care about `b`, you can bind it to `ignore`.
As a more complex example, if you want to bind both `b` and `a-b-c`, then it won't work, because `b` would override `a-b-c`. However, binding `a-b` to `ignore` would allow that, because after `a-b` the longest match `a-b` is ignored, and a following `c` would trigger the sequence `a-b-c` while `b` alone would still work. <purple>Iconic problem-solving behaviour, honestly.</purple> ๐
## Key names
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 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. These are influenced by keyboard modifiers which affect produced text, such as shift and caps lock. 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`).
> **Note:** the `Shift` modifier requires some attention. In general, when the `Shift` modifier is combined with a key which produces text, the actual produced text key name when shift is pressed should be used. ๐ซถ
Special key names like `Shift+LEFT` work as expected. If you're ever in doubt โ <pink>use `--input-test`</pink> to check how a key/combination is seen by mpv, bestie. It's the vibe check for your keyboard. ๐
Symbolic key names and modifier names are <cyan>case-insensitive</cyan>. Unicode key names are <hotpink>case-sensitive</hotpink>, just like how keyboard text input would produce. No cap.
Another type of key names are <purple>hexadecimal key names</purple>, which start with `0x`, followed by the hexadecimal value of the key. That hex value can be either a Unicode code point value, or it can serve as fallback for special keys that don't have a special mpv defined name. They will <red>break</red> as soon as mpv adds proper names for them, but they can enable you to use a key at all if that doesn't happen. ๐
All symbolic names are listed by `--input-keylist`. And `--input-test` is a special mode that prints all input on the OSD. โจ
Comments on some symbolic names, since we're being thorough:
- **`KP*`** โ Keypad names. Behavior varies by backend (whether they implement this, and on how they treat numlock), but typically mpv tries to map keys on the keypad to separate names, even if they produce the same text as normal keys.
- **`MOUSE_BTN*`, `MBTN*`** โ Various mouse buttons.
- Depending on backend, the mouse wheel might also be represented as a button. In addition, `MOUSE_BTN3` to `MOUSE_BTN6` are <red>deprecated</red> aliases for `WHEEL_UP`, `WHEEL_DOWN`, `WHEEL_LEFT`, `WHEEL_RIGHT`.
- `MBTN*` are aliases for `MOUSE_BTN*`.
- **`WHEEL_*`** โ Mouse wheels and touch pads (typically).
- These keys are <green>scalable</green> when used with scalable commands if the underlying device supports high-resolution scrolling (e.g. touch pads). โจ
- **`AXIS_*`** โ <red>Deprecated</red> aliases for `WHEEL_*`.
- **`*_DBL`** โ Mouse button double clicks.
- **`MOUSE_MOVE`, `MOUSE_ENTER`, `MOUSE_LEAVE`** โ Emitted by mouse move events. Enter/leave happens when the mouse enters or leaves the mpv window (or the current mouse region, using the deprecated mouse region input section mechanism).
- **`CLOSE_WIN`** โ Pseudo key emitted when closing the mpv window using the OS window manager (for example, by clicking the close button in the window title bar). ๐
- **`GAMEPAD_*`** โ Keys emitted by the SDL gamepad backend. ๐ฎ
- **`UNMAPPED`** โ Pseudo-key that matches any unmapped key. (You should probably avoid this if possible, because it might change behavior or get removed in the future.) ๐
- **`ANY_UNICODE`** โ Pseudo-key that matches any key that produces text. (You should probably avoid this if possible, because it might change behavior or get removed in the future.) ๐
---
## ๐ Flat command syntax ๐
This is the syntax used in `input.conf`, and referred to as "input.conf syntax" in a number of other places.
<command> ::= [<prefixes>] <command_name> (<argument>)* <argument> ::= (<unquoted> | " <double_quoted> " | ' <single_quoted> ' | X <custom_quoted> X)
`command_name` is an unquoted string with the command name itself. See <cyan>List of Input Commands</cyan> for a list.
Arguments are separated by whitespaces even if the command expects only one argument. Arguments with whitespaces or other special characters <hotpink>must be quoted</hotpink>, or the command cannot be parsed correctly.
<blue>Double quotes</blue> interpret JSON/C-style escaping, like `\t` or `\"` or `\\`. JSON escapes according to <purple>RFC 8259</purple>, minus surrogate pair escapes. This is the <green>only</green> form which allows newlines at the value โ as `\n`.
<blue>Single quotes</blue> take the content literally, and cannot include the single-quote character at the value.
<blue>Custom quotes</blue> also take the content literally, but are more flexible than single quotes. They start with `` ` `` (back-quote) followed by any ASCII character, and end at the first occurrence of the same pair in reverse order, e.g. `` `-foo-` `` or ` ``bar`` `. The final pair sequence is not allowed at the value โ in these examples `` -` `` and `` `` `` respectively. In the second example the last character of the value also can't be a back-quote.
Mixed quoting at the same argument, like `'foo'"bar"`, is <red>not supported</red>. ๐ซ
> Note that argument parsing and property expansion happen at <bold>different stages</bold>. First, arguments are determined as described above, and then, where applicable, properties are expanded โ regardless of argument quoting. However, expansion can still be prevented with the `raw` prefix or `$>`. See <cyan>Input Command Prefixes</cyan> and <cyan>Property Expansion</cyan>.
---
## ๐ Commands specified as arrays ๐
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 <cyan>Flat command syntax</cyan>, 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 <green>not</green> 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.
Property expansion is <hotpink>disabled by default</hotpink> for these APIs. This can be changed with the `expand-properties` prefix. See <cyan>Input Command Prefixes</cyan>.
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 would have to <red>double-escape</red> in `input.conf`, but not with the array APIs.
For complex commands, consider using <cyan>Named arguments</cyan> instead, which should give slightly more compatibility. Some commands do not support named arguments and inherently take an array, though.
---
## ๐ฆ Named arguments ๐ฆ
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.
The name of the command is provided with a `name` string field. The name of each command is defined in each command description in the <cyan>List of Input Commands</cyan>. `--input-cmdlist` also lists them. See the `subprocess` command for an example.
Some commands do <red>not</red> support named arguments (e.g. `run` command). You need to use APIs that pass arguments as arrays.
Named arguments are <red>not supported</red> in the "flat" `input.conf` syntax, which means you cannot use them for key bindings in `input.conf` at all. ๐ญ
Property expansion is <hotpink>disabled by default</hotpink> for these APIs. This can be changed with the `expand-properties` prefix. See <cyan>Input Command Prefixes</cyan>.
---
## ๐ List of Input Commands ๐
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 <cyan>Flat command syntax</cyan>).
---
### ๐ Playback Control ๐
- **`seek <target> [<flags>]`** โ Change the playback position. By default, seeks by a relative amount of seconds.
The second argument consists of flags controlling the seek mode:
- `relative` (default) โ Seek relative to current position (a negative value seeks backwards).
- `absolute` โ Seek to a given time (a negative value starts from the end of the file).
- `absolute-percent` โ Seek to a given percent position.
- `relative-percent` โ Seek relative to current position in percent.
- `keyframes` โ Always restart playback at keyframe boundaries (fast). โก
- `exact` โ Always do exact/hr/precise seeks (slow). ๐ข
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 <red>deprecated</red>.
This is a <green>scalable command</green>. See the documentation of `nonscalable` input command prefix in <cyan>Input Command Prefixes</cyan> for details. โจ
- **`revert-seek [<flags>]`** โ 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:
- `mark` โ Mark the current time position. The next normal `revert-seek` command will seek back to this point, no matter how many seeks happened since last time.
- `mark-permanent` โ If set, mark the current position, and do not change the mark position before the next `revert-seek` command that has `mark` or `mark-permanent` set (or playback of the current file ends). Until this happens, `revert-seek` will always seek to the marked point. This flag <red>cannot be combined</red> with `mark`.
Using it without any arguments gives you the default behavior.
- **`sub-seek <skip> [<flags>]`** โ Change video and audio position such that the subtitle event after `<skip>` subtitle events is displayed. For example, `sub-seek 1` skips to the next subtitle, `sub-seek -1` skips to the previous subtitles, and `sub-seek 0` seeks to the beginning of the current subtitle.
This is similar to `sub-step`, except that it seeks video and audio instead of adjusting the subtitle delay. ๐ฌ
Secondary argument:
- `primary` (default) โ Seeks through the primary subtitles.
- `secondary` โ Seeks through the secondary subtitles.
For embedded subtitles (like with Matroska), this works only with subtitle events that have already been displayed, or are within a short prefetch range. See <cyan>Cache</cyan> for details on how to control the available prefetch range. ๐ซถ
- **`frame-step [<frames>] [<flags>]`** โ bestie, this one walks the video forward or backwards by however many frames you tell it. No `<frames>`? It just assumes `1`. Iconic.
The second argument is a lil bundle of flags that controls the frameskip mode:
- **`play`** (default) โ plays the video forward by the amount of frames you asked for, then pauses. <pink>Only works with a positive value</pink>, aka stepping forwards only. No backwards vibes here.
- **`seek`** โ does a very exact seek that *attempts* to seek by the desired amount of frames. If `<frames>` is `-1`, it goes exactly to the previous frame. Chef's kiss precision.
- **`mute`** โ literally the same as `play` but it mutes the audio stream if there is any, for the duration of the frame step. Silent movie era ๐
Okay so real talk: the default frameskip mode, `play`, is <green>more accurate</green> but it can be <red>slow</red> depending on how many frames you're skipping (like, skipping forward 100 frames will literally play 100 frames of video before stopping ๐). This mode only works when going forwards. Frame stepping back always performs a seek, periodt.
When you use `seek` mode, it can still be very slow (it's trying to be precise, not fast, iykyk), and sometimes it just... fails to behave as expected ๐ญ. How well it 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 framestepping *silently* behave incorrectly in corner cases ๐. Using `--hr-seek-framedrop=no` should help, although it might make precise seeking slower. Also if the video is VFR, framestepping using seeks will probably not work correctly except for the `-1` case. Not me warning you twice.
This does not work with audio-only playback. Sorry audio girlies.
- **`frame-back-step`** โ calls `frame-step` with a value of `-1` and the `seek` flag. That's it, that's the whole thing. It's giving "one job" and it ate ๐
This does not work with audio-only playback either.
- **`stop [<flags>]`** โ stops playback and clears the playlist. With default settings, this is essentially like `quit`. Super useful for the client API: playback can be stopped <purple>without terminating the player</purple>. Main character energy honestly.
The first argument is optional, and supports the following flags:
- **`keep-playlist`** โ do not clear the playlist. She stays. ๐ซถ
---
## ๐ Property Manipulation ๐
- **`set <name> <value>`** โ sets the given property or option to the given value. Simple, clean, slay.
- **`del <name>`** โ deletes the given property. Most properties cannot be deleted though, so don't get too attached ๐
- **`add <name> [<value>]`** โ adds the given value to the property or option. On overflow or underflow, it clamps the property to the maximum. If `<value>` is omitted, assume `1`.
Whether or not key-repeat is enabled by default depends on the property. Currently properties with continuous values are repeatable by default (like `volume`), while discrete values are not (like `osd-level`). Not me explaining the personality differences of each property ๐ญ
This is a scalable command. See the documentation of nonscalable input command prefix in Input Command Prefixes for details.
- **`multiply <name> <value>`** โ similar to `add`, but it multiplies the property or option with the numeric value. Math girlie behavior. โจ
- **`cycle <name> [<value>]`** โ cycles the given property or option. The second argument can be `up` or `down` to set the cycle direction. On overflow, set the property back to the minimum; on underflow, set it to the maximum. If `up` or `down` is omitted, assume `up`.
Whether or not key-repeat is enabled by default depends on the property. Currently properties with continuous values are repeatable by default (like `volume`), while discrete values are not (like `osd-level`).
This is a scalable command. See the documentation of nonscalable input command prefix in Input Command Prefixes for details.
- **`cycle-values [<"!reverse">] <property> <value1> [<value2> [...]]`** โ cycles 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). Round and round we go ๐ฆ
This command has a variable number of arguments, and cannot be used with named arguments. No named args, bestie, it said what it said.
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. Convenience is the whole vibe.
- **`change-list <name> <operation> <value>`** โ 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 <yellow>empty string</yellow>. Yeah, awkward, but we move.
> **Example**
>
> ```text
> 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`.
---
## ๐ Playlist Manipulation ๐
- **`playlist-next [<flags>]`** โ go to the next entry on the playlist. Bye to the current one ๐
First argument:
- **`weak`** (default) โ if the last file on the playlist is currently played, do nothing. Just chillin'.
- **`force`** โ terminate playback if there are no more files on the playlist. Dramatic exit, we love to see it.
- **`playlist-prev [<flags>]`** โ go to the previous entry on the playlist. Rewind era.
First argument:
- **`weak`** (default) โ if the first file on the playlist is currently played, do nothing.
- **`force`** โ terminate playback if the first file is being played.
- **`playlist-next-playlist`** โ go to the next entry on the playlist with a different `playlist-path`. Not just any next entry, a *different-path* next entry. Picky but valid.
- **`playlist-prev-playlist`** โ go to the first of the previous entries on the playlist with a different `playlist-path`. Same energy, going backwards. ๐ธ
- **`playlist-play-index <integer|current|none>`** โ start (or restart) playback of the given playlist index. In addition to the 0-based playlist entry index, it supports the following values:
- **`<current>`** โ the current playlist entry (as in `playlist-current-pos`) will be played again (unload and reload). If `none` is set, playback is stopped. (In corner cases, `playlist-current-pos` can point to a playlist entry even if playback is currently inactive,
- **`<none>`** โ playback is stopped. If idle mode (`--idle`) is enabled, the player will enter idle mode, otherwise it will exit.
This command is similar to `loadfile` in that it only manipulates the state of what to play next, without waiting until the current file is unloaded, and the next one is loaded. It's giving "future plans" not "right now".
Setting `playlist-pos` or similar properties can have a similar effect to this command. However, it's more explicit, and guarantees that playback is restarted if for example the new playlist entry is the same as the previous one. Guaranteed restarts only ๐ฅ
- **`loadfile <url> [<flags> [<index> [<options>]]]`** โ load the given file or URL and play it. Technically, this is just a playlist manipulation command (which either replaces the playlist or adds an entry to it). Actual file loading happens independently. For example, a `loadfile` command that replaces the current file with a new one returns <purple>before</purple> the current file is stopped, and the new file even begins loading. It's asynchronous, she's got places to be.
Second argument:
- **`<replace>`** (default) โ stop playback of the current file, and play the new file immediately.
- **`<append>`** โ append the file to the playlist.
- **`<append-play>`** โ append the file, and if nothing is currently playing, start playback. (Always starts with the added file, even if the playlist was not empty before running this command.)
- **`<insert-next>`** โ insert the file into the playlist, directly after the current entry.
- **`<insert-next-play>`** โ insert the file next, and if nothing is currently playing, start playback. (Always starts with the added file, even if the playlist was not empty before running this command.)
- **`<insert-at>`** โ insert the file into the playlist, at the index given in the third argument.
- **`<insert-at-play>`** โ insert the file at the index given in the third argument, and if nothing is currently playing, start playback. (Always starts with the added file, even if the playlist was not empty before running this command.)
The third argument is an insertion index, used <hotpink>only</hotpink> by the `insert-at` and `insert-at-play` actions. When used with those actions, the new item will be inserted at the index position in the playlist, or appended to the end if index is less than 0 or greater than the size of the playlist. This argument will be ignored for all other actions. This argument is added in mpv 0.38.0.
The fourth 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,...` When using the client API, this can be a `MPV_FORMAT_NODE_MAP` (or a Lua table), however the values themselves must be strings currently. These options are set during playback, and restored to the previous value at end of playback (see Per-File Options).
> **Warning:**
> Since mpv 0.38.0, an insertion index argument is added as the third argument. This breaks <red>all existing uses</red> of this command which make use of the argument to include the list of options to be set while the file is playing. To address this problem, the third argument now needs to be set to `-1` if the fourth argument needs to be used. Not a drill, bestie, set it to `-1` ๐ญ
- **`loadlist <url> [<flags> [<index>]]`** โ load the given playlist file or URL (like `--playlist`). Whole list, incoming ๐ฆ
Second argument:
- **`<replace>`** (default) โ stop playback and replace the internal playlist with the new one.
- **`<append>`** โ drops the new playlist at the *end* of the internal playlist you already got going. no cap, it just chills at the back. ๐
- **`<append-play>`** โ appends the new playlist, and bestie if nothing is playing rn, it starts playback. (and it **always** starts with the new playlist, even if the internal playlist was not empty before you ran this. like, it's committed to the new one. ๐
)
- **`<insert-next>`** โ slots the new playlist into the current internal playlist, directly after the current entry. right behind it. ๐ซถ
- **`<insert-next-play>`** โ inserts the new playlist, and if nothing is playing, starts playback. (again: **always** starts with the new playlist, even if the internal playlist was not empty before running this command. yes really. ๐)
- **`<insert-at>`** โ inserts the new playlist at the index given in the third argument. precision placement, iconic. โจ
- **`<insert-at-play>`** โ inserts the new playlist at the index given in the third argument, and if nothing is currently playing, it starts playback. (and yep โ **always** starts with the new playlist, even if the internal playlist was not empty before running this command. ๐)
Okay so about that third argument: it's an **insertion index**, and it's only used by the `insert-at` and `insert-at-play` actions. When you use it with those, the new playlist gets inserted at that index position in the internal playlist โ or, if the index is less than `0` or greater than the size of the internal playlist, it just gets appended to the end. For every other action, this argument is simply ignored. periodt. ๐
---
## ๐ถ Playlist Commands (cont.) ๐ถ
- **`playlist-clear`** โ clears the playlist, except for the file that's currently playing. that one stays. main character privileges. ๐
- **`playlist-remove <index>`** โ removes the playlist entry at the given index. index values start counting at `0` (zero-indexed, as the universe intended). the special value `current` removes the current entry. heads up tho: removing the current entry also **stops playback and starts playing the next entry**. it's giving consequences. ๐ญ
- **`playlist-move <index1> <index2>`** โ moves the playlist entry at *index1* so it takes the place of the entry at *index2*. and here's the lil paradox, bestie: the moved entry will **not** have the index value *index2* after moving, if *index1* was lower than *index2* โ because *index2* refers to the **target entry**, not the index the entry will have after moving. yes it's confusing. yes it's still true. ๐
- **`playlist-shuffle`** โ shuffles the playlist. this is basically the same thing that happens on start if you're using the `--shuffle` option. ๐ฒ
- **`playlist-unshuffle`** โ tries to revert the previous `playlist-shuffle` command. it only works **once** (so multiple successive `playlist-unshuffle` commands do literally nothing). and it may not work correctly if new recursive playlists have been opened since a `playlist-shuffle` command. so... temper your expectations. ๐
---
## ๐ฌ Track Manipulation ๐ฌ
- **`sub-add <url> [<flags> [<title> [<lang>]]]`** โ loads the given subtitle file or stream. by default it gets selected as the current subtitle after loading. cute, right? ๐
the *flags* argument is one of these values:
- **`<select>`** โ select the subtitle immediately (this is the default). โจ
- **`<auto>`** โ don't select the subtitle. (or, in some special situations, let the default stream selection mechanism decide. let it cook. ๐ฅ)
- **`<cached>`** โ select the subtitle, but 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 [thing] was changed since it was loaded, those changes won't be reflected. ๐)
additionally, these flags can be tacked on with a `+`:
- **`<hearing-impaired>`** โ marks the track as suitable for the hearing impaired. ๐ซถ
- **`<visual-impaired>`** โ marks the track as suitable for the visually impaired. ๐ซถ
- **`<forced>`** โ marks the track as forced. ๐
- **`<default>`** โ marks the track as default. โญ
- **`<attached-picture>`** (only for `video-add`) โ marks the track as an attached picture, same as the `albumart` argument for `video-add`. ๐ผ๏ธ
the *title* argument sets the track title in the UI.
the *lang* argument sets the track language, and it can also influence stream selection when flags are set to `auto`. iykyk. ๐
- **`sub-remove [<id>]`** โ removes the given subtitle track. if the *id* argument is missing, it removes the current track. (works on external subtitle files only, so don't @ me about embedded ones. ๐
)
- **`sub-reload [<id>]`** โ reloads the given subtitle tracks. if the *id* argument is missing, it reloads the current track. (again, external subtitle files only.)
this works by unloading and re-adding the subtitle track. refresh queen. ๐ง
- **`sub-step <skip> [<flags>]`** โ changes subtitle timing such that the subtitle event after the next *<skip>* subtitle events is displayed. *<skip>* can be negative to step backwards. ๐
secondary argument:
- **`primary`** (default) โ steps through the primary subtitles.
- **`secondary`** โ steps through the secondary subtitles.
- **`audio-add <url> [<flags> [<title> [<lang>]]]`** โ loads the given audio file. see the `sub-add` command for how the rest works. ๐ง
- **`audio-remove [<id>]`** โ removes the given audio track. see the `sub-remove` command. ๐๏ธ
- **`audio-reload [<id>]`** โ reloads the given audio tracks. see the `sub-reload` command. ๐
- **`video-add <url> [<flags> [<title> [<lang> [<albumart>]]]]`** โ loads the given video file. see the `sub-add` command for the common options. ๐ฅ
- **`albumart`** (`MPV_FORMAT_FLAG`) โ if enabled, mpv will load the given video as album art. ๐ผ๏ธโจ
- **`video-remove [<id>]`** โ removes the given video track. see the `sub-remove` command. ๐๏ธ
- **`video-reload [<id>]`** โ reloads the given video tracks. see the `sub-reload` command. ๐
- **`rescan-external-files [<mode>]`** โ rescans external files according to your current `--sub-auto`, `--audio-file-auto` and `--cover-art-auto` settings. this is how you auto-load external files *after* the file was already loaded. late to the party but still welcome. ๐
the *mode* argument is one of these:
- **`<reselect>`** (default) โ select the default audio and subtitle streams, which typically selects external files with the highest preference. (the implementation is not perfect, and could be improved on request โ so like, file a request if you care. ๐)
- **`<keep-selection>`** โ do not change current track selections. hands off. โ
---
## ๐ Text Manipulation ๐
- **`print-text <text>`** โ prints text to stdout. the string can contain properties (see Property Expansion). take care to put the argument in quotes, bestie, or it'll get weird. ๐
- **`expand-text <text>`** โ property-expands the argument and returns the expanded string. this can be used **only** through the client API or from a script using `mp.command_native`. (see Property Expansion.) ๐
- **`expand-path <text>`** โ expands a path's double-tilde placeholders into a platform-specific path. same deal as `expand-text`: this can only be used through the client API or from a script using `mp.command_native`. ๐ค๏ธ
> **Example**
>
> ```lua
> 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. so cute, so useful. ๐
- **`normalize-path <filename>`** โ returns a canonical representation of the path *filename* by converting it to an absolute path, removing consecutive slashes, removing `.` components, resolving `..` components, and converting slashes to backslashes on Windows. symlinks are **not** resolved unless the platform is Unix-like and one of the path components is `..`. if *filename* is a URL, it is returned unchanged. and this can only be used through the client API or from a script using `mp.command_native`. ๐
> **Example**
>
> ```lua
> mp.osd_message(mp.command_native({"normalize-path", "/foo//./bar"}))
> ```
>
> this line of Lua prints `"/foo/bar"` on the OSD. glow up achieved. โจ
- **`escape-ass <text>`** โ modifies *text* so that commands and functions that interpret ASS tags, such as `osd-overlay` and `mp.create_osd_overlay`, will display it verbatim, and returns it. this can only be used through the client API or from a script using `mp.command_native`. ๐
> **Example**
>
> ```lua
> mp.osd_message(mp.command_native({"escape-ass", "foo {bar}"}))
> ```
>
> this line of Lua prints `"foo \{bar}"` on the OSD. escaping is self-care. ๐
---
## โ๏ธ Configuration Commands โ๏ธ
- **`apply-profile <name> [<mode>]`** โ applies the contents of a named profile. this is basically like using `profile=name` in a config file, except you can map it to a key binding to change it at runtime. glow-up for your workflow. ๐ฅ
the *mode* argument:
- **`apply`** โ apply the profile. this is the default if the argument is omitted.
- **`restore`** โ restore options set by a previous `apply-profile` command for this profile. only works if the profile has `profile-restore` set to a relevant mode. prints a warning if nothing could be done. see Runtime profiles for the details. ๐
- **`load-config-file <filename>`** โ loads a configuration file, similar to the `--include` option. if the file was already included, its previous options are **not** reset before it is reparsed. noted. ๐
- **`write-watch-later-config`** โ writes the resume config file that the `quit-watch-later` command writes, but keeps playback going like normal. multitasking icon. ๐
- **`delete-watch-later-config [<filename>]`** โ deletes any existing resume config file that was written by `quit-watch-later` or `write-watch-later-config`. if a *filename* is specified, then the deleted config is for that file; otherwise, it's the same one that would be written by `quit-watch-later` or `write-watch-later-config` in the current circumstance. ๐๏ธโจ
---
## ๐ฌ OSD Commands ๐ฌ
- **`show-text <text> [<duration>|-1 [<level>]]`** โ shows text on the OSD. the string can contain properties, which get expanded as described in Property Expansion. this is how you show playback time, filename, and so on. and fun fact: `no-osd` has **no effect** on this command. ๐
- **`<duration>`** โ the time in ms to show the message for. by default, it uses the same value as `--osd-duration`. โฑ๏ธ
- **`<level>`** โ the minimum OSD level to show the text at (see `--osd-level`). ๐
- **`show-progress`** โ shows the progress bar, the elapsed time and the total duration of the file on the OSD. and again, `no-osd` has **no effect** on this command. iconic. ๐
- **`overlay-add <id> <x> <y> <file> <offset> <fmt> <w> <h> <stride> <dw> <dh>`** โ add an OSD overlay that's built from raw data ๐
bestie this one is literally made for scripts and applications that drive mpv and wanna slap stuff on top of the video window. it's giving "I brought my own pixels" energy.
overlays are *usually* displayed in screen resolution, but with some VOs the resolution gets reduced to that of the video's. so you can go read the <cyan>`osd-width`</cyan> and <cyan>`osd-height`</cyan> properties. at least with `--vo-xv` and anamorphic video (such as DVD), you should read <cyan>`osd-par`</cyan> as well, and the overlay should be aspect-compensated. no cap.
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. don't be chaotic about it ๐
- `id` โ 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. slay, it's just an ID.
- `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` โ 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` โ a string identifying the image format. currently, only <cyan>`bgra`</cyan> 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. so likeโฆ don't. ๐ญ)
- `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.)
- `dw` and `dh` โ specify the (optional) display size of the overlay. the overlay visible portion of the overlay (`w` and `h`) is scaled to in display to `dw` and `dh`. if parameters are not present, the values for `w` and `h` are used.
> **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 command returns. if you want to use this command before mpv 0.18.1, reads the old docs to see how to handle this correctly. vintage behaviour, honestly โจ
- **`overlay-remove <id>`** โ remove an overlay added with `overlay-add` and the same ID. does nothing if no overlay with this ID exists. it's giving "if you're not there, no drama, I simply will not react" ๐
- **`osd-overlay`** โ 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. the lore is still developing.)
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. it's honestly iconic.
this command accepts the following parameters:
- `id` โ 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. gone. poof. ๐ฆ
- `format` โ string that gives the type of the overlay. accepts the following values (HTML rendering of this is broken, view the generated manpage instead, or the raw RST source):
- `ass-events` โ 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. <cyan>`OSD`</cyan> contains the text style as defined by the current `--osd-...` options. <cyan>`Default`</cyan> 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.
- `none` โ special value that causes the overlay to be removed. most parameters other than `id` and `format` are mostly ignored.
- `data` โ string defining the overlay contents according to the `format` parameter.
- `res_x`, `res_y` โ used if `format` is set to `ass-events` (see description there). optional, defaults to `0`/`720`.
- `z` โ 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. no promises, bestie ๐
- `hidden` โ if set to `true`, do not display this (default: `false`).
- `compute_bounds` โ if set to `true`, attempt to determine bounds and write them to the command's result value as `x0`, `x1`, `y0`, `y1` rectangle (default: `false`). if the rectangle is empty, not known, or somehow degenerate, it is not set. `x1`/`y1` is the coordinate of the bottom exclusive corner of the rectangle.
the result value may depend on the VO window size, and is based on the last known window size at the time of the call. this means the results may be different from what is actually rendered.
for `ass-events`, the result rectangle is recomputed to PlayRes coordinates (`res_x`/`res_y`). if window size is not known, a fallback is chosen.
you should be aware that this mechanism is very inefficient, as it renders the full result, and then uses the bounding box of the rendered bitmap list (even if `hidden` is set). it will flush various caches. its results also depend on the used libass version.
this feature is experimental, and may change in some way again. ๐งช
> **Note:**
> always use named arguments (`mpv_command_node()`). Lua scripts should use the `mp.create_osd_overlay()` helper instead of invoking this command directly.
---
## โจ Input and Keybind Commands โจ
- **`mouse <x> <y> [<button> [<mode>]]`** โ send a mouse event with given coordinate (`<x>`, `<y>`). click click, bestie ๐ฑ๏ธ
second argument:
- `<button>` โ the button number of clicked mouse button. this should be one of `0-19`. if `<button>` is omitted, only the position will be updated.
third argument:
- `<single>` (default) โ the mouse event represents regular single click.
- `<double>` โ the mouse event represents double-click.
- **`keypress <name> [<scale>]`** โ yeets a key event straight through mpv's input handler, so whatever behavior is bound to that key just <pink>happens</pink>. ๐
`name` uses the `input.conf` naming scheme for keys and modifiers (yes, modifiers too, bestie). `scale` scales the numerical change effected by the bound command โ same mechanism as precise scrolling. Super handy for the client API: key events can be sent to libmpv to handle internally. ๐
- **`keydown <name>`** โ basically `keypress`'s sibling, but it sets the `KEYDOWN` flag, so if the key is bound to a repeatable command it'll run over and over with mpv's key repeat timing until you call `keyup`. ๐ฆ
- **`keyup [<name>]`** โ sets the `KEYUP` flag, which stops any repeated behavior that had been triggered. `name` is optional! If `name` isn't given, or is an empty string, `KEYUP` gets set on **all** keys. Otherwise, `KEYUP` is only set on the key specified by `name`. ๐ธ
- **`keybind <name> <cmd> [<comment>]`** โ binds a key to an input command. `cmd` has to be a **complete** command with all the desired arguments and flags in it, no halfsies. Both `name` and `cmd` use the `input.conf` naming scheme. `comment` is an optional string that can be read as the comment entry of input-bindings. Primarily useful for the client API. โจ
- **`enable-section <name> [<flags>]`** โ <red>this command is deprecated</red>, except for mpv-internal uses. Enables all key bindings in the named input section.
The enabled input sections form a <purple>stack</purple>. Bindings in sections on the top of the stack are preferred over lower sections. This command puts the section on top of the stack. If the section was already on the stack, it's implicitly removed beforehand. (A section cannot be on the stack more than once, no duplicates allowed, we're not doing that here. ๐)
The `flags` parameter can be a combination (separated by `+`) of the following flags:
- **`exclusive`** โ all sections enabled before the newly enabled section are disabled. They'll be re-enabled as soon as all exclusive sections above them are removed. In other words, the new section shadows all previous sections. ๐
- **`allow-hide-cursor`** โ this feature can't be used through the public API. ๐
- **`allow-vo-dragging`** โ same. ๐ซถ
- **`disable-section <name>`** โ <red>deprecated</red>, except for mpv-internal uses. Disables the named input section. It's the undo button for `enable-section`. ๐
- **`define-section <name> <contents> [<flags>]`** โ <red>deprecated</red>, except for mpv-internal uses. Creates a named input section, or replaces 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. Periodt.
The last parameter has the following meaning:
- **`default`** (also used if parameter omitted) โ use a key binding defined by this section only if the user hasn't already bound this key to a command.
- **`force`** โ always bind a key. (The input section that was made active most recently wins if there are ambiguities.) ๐ฅ
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's 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. ๐
- **`load-input-conf <filename>`** โ loads an input configuration file, similar to the `--input-conf` option. If the file was already included, its previous bindings are **not** reset before it is reparsed. Not me giving you a reparse heads-up, it's just facts. ๐ง
---
## ๐ Execution Commands ๐
- **`run <command> [<arg1> [<arg2> [...]]]`** โ runs the given command. Unlike in MPlayer/mplayer2 and earlier versions of mpv (`0.2.x` and older), this <hotpink>doesn't call the shell</hotpink>. 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 <cyan>detached</cyan> way. mpv doesn't wait until the command is completed, but continues playback right after spawning it. Main character energy: mpv moves on immediately. ๐
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`. ๐จ
- **`subprocess`** โ similar to `run`, but gives more control about process execution to the caller, and does <red>not</red> 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.
- **`args`** (`MPV_FORMAT_NODE_ARRAY[MPV_FORMAT_STRING]`) โ 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 executable is searched in the directories in the `PATH` environment variable. On Unix, this is equivalent to `posix_spawnp` and `execvp` behavior. ๐ง
- **`playback_only`** (`MPV_FORMAT_FLAG`) โ boolean indicating whether the process should be killed when playback of the current playlist entry terminates (optional, default: `true`). If enabled, stopping playback will automatically kill the process, and you can't start it outside of playback. ๐ญ
- **`capture_size`** (`MPV_FORMAT_INT64`) โ integer setting the maximum number of stdout plus stderr bytes that can be captured (optional, default: `64MB`). If the number of bytes exceeds this, capturing is stopped. The limit is **per captured stream**. ๐
- **`capture_stdout`** (`MPV_FORMAT_FLAG`) โ capture all data the process outputs to stdout and return it once the process ends (optional, default: `no`). ๐
- **`capture_stderr`** (`MPV_FORMAT_FLAG`) โ same as `capture_stdout`, but for stderr.
- **`detach`** (`MPV_FORMAT_FLAG`) โ whether to run the process in detached mode (optional, default: `no`). In this mode, the process is run in a new process session, and the command does not wait for the process to terminate. If neither `capture_stdout` nor `capture_stderr` have been set to `true`, the command returns immediately after the new process has been started, otherwise the command will read as long as the pipes are open. ๐
- **`env`** (`MPV_FORMAT_NODE_ARRAY[MPV_FORMAT_STRING]`) โ set a list of environment variables for the new process (default: `empty`). If an empty list is passed, the environment of the mpv process is used instead. (Unlike the underlying OS mechanisms, the mpv command cannot start a process with empty environment. Fortunately, that is completely useless.) The format of the list is as in the `execle()` syscall. Each string item defines an environment variable as in `NAME=VALUE`. ๐
On Lua, you may use `utils.get_env_list()` to retrieve the current environment if you e.g. simply want to add a new variable.
- **`stdin_data`** (`MPV_FORMAT_STRING`) โ feed the given string to the new process' stdin. Since this is a string, you cannot pass arbitrary binary data. If the process terminates or closes the pipe before all data is written, the remaining data is silently discarded. Probably does not work on win32. ๐
- **`passthrough_stdin`** (`MPV_FORMAT_FLAG`) โ if enabled, wire the new process' stdin to mpv's stdin (default: `no`). Before mpv `0.33.0`, this argument did not exist, but the behavior was as if this was set to `true`. โญ
The command returns the following result (as `MPV_FORMAT_NODE_MAP`):
- **`status`** (`MPV_FORMAT_INT64`) โ typically this is the process exit code (`0` or positive) if the process terminates normally, or negative for other errors (failed to start, terminated by mpv, and others). The meaning of negative values is <red>undefined</red>, other than meaning error (and does not correspond to OS low level exit status values). ๐
On Windows, it can happen that a negative return value is returned even if the process terminates normally, 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. ๐ช
- **`stdout`** (`MPV_FORMAT_BYTE_ARRAY`) โ captured stdout stream, limited to `capture_size`. ๐
- **`stderr`** (`MPV_FORMAT_BYTE_ARRAY`) โ same as `stdout`, but for stderr.
- **`error_string`** (`MPV_FORMAT_STRING`) โ empty string if the process terminated normally. 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 `true`.
- **`killed_by_us`** (`MPV_FORMAT_FLAG`) โ bestie, this one tells you whether <pink>mpv itself</pink> yeeted the process ๐. Like when `playback_only` is `true` and it kicks in, or you abort the command (think `mp.abort_async_command()`), or the player is literally about to dip out and exit.
> ngl the command itself will *always* come back as success as long as your parameters are correct ๐ญ. Whether the process actually got spawned, or got killed somehow, or returned an error status โ you gotta go dig that out of the `result` value yourself, no cap.
This command can be aborted asynchronously via the API, fr. Also peep <purple>Asynchronous command details</purple>. And lowkey only the `run` command can start processes in a *truly detached* way ๐
> **Note:** the subprocess will always get terminated on player exit if it wasn't started in detached mode โ even if `playback_only` is `false` ๐.
> **Warning:** do NOT forget to set the `playback_only` field to `false` if you want the command to run while the player is in idle mode, or if you don't want the end of playback to kill the command ๐
.
<purple>**Example**</purple>
local r = mp.command_native({ name = "subprocess", playback_only = false, capture_stdout = true, args = {"cat", "/proc/cpuinfo"}, }) if r.status == 0 then print("result: " .. r.stdout) end
This is a fairly useless Lua example, which demonstrates how to run a process in a blocking manner, and retrieving its stdout output. (Iconic little demo though, we love a proof of concept โจ)
---
- **`quit [<code>]`** โ Exit the player. If an argument is given, it's used as process exit code. Simple as, bye bestie ๐
- **`quit-watch-later [<code>]`** โ Exit player, and store current playback position. Playing that file later will seek to the previous position on start. The (optional) argument is exactly as in the `quit` command. See <cyan>RESUMING PLAYBACK</cyan>. (the way it remembers where you were... main character energy fr ๐ซถ)
---
### ๐ Scripting Commands ๐
- **`script-message [<arg1> [<arg2> [...]]]`** โ Send a message to <hotpink>all clients</hotpink>, 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.
- **`script-message-to <target> [<arg1> [<arg2> [...]]]`** โ 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()`. Note that client names only consist of alphanumeric characters and `_`. ๐ฏ
This command has a variable number of arguments, and cannot be used with named arguments.
- **`script-binding <name> [<arg>]`** โ Invoke a script-provided key binding. This can be used to remap key bindings provided by external Lua scripts. ๐ฅ
`<name>` is the name of the binding. `<arg>` is a user-provided arbitrary string which can be used to provide extra information.
It can optionally be prefixed with the name of the script, using `/` as separator, e.g. `script-binding scriptname/bindingname`. Note that script names only consist of alphanumeric characters and `_`.
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 in string format:
1. The string `key-binding`.
2. The name of the binding (as established above).
3. The key state as string (see below).
4. The key name (since mpv 0.15.0).
5. The text the key would produce, or empty string if not applicable.
6. The scale of the key, such as the ones produced by `WHEEL_*` keys. The scale is `1` if the key is nonscalable.
7. The user-provided string `<arg>`, or empty string if the argument is not used.
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 3 characters:
1. One of `d` (key was pressed down), `u` (was released), `r` (key is still down, and was repeated; only if key repeat is enabled for this binding), `p` (key was pressed; happens if up/down can't be tracked).
2. Whether the event originates from the mouse, either `m` (mouse button) or `-` (something else).
3. Whether the event results from a cancellation (e.g. the key is logically released but not physically released), either `c` (canceled) or `-` (something else). Not all types of cancellations set this flag.
Future versions can add more arguments and more key state characters to support more input peculiarities. ๐
This is a scalable command. See the documentation of nonscalable input command prefix in <lavender>Input Command Prefixes</lavender> for details.
- **`load-script <filename>`** โ Load a script, similar to the `--script` option. Whether this waits for the script to finish initialization or not changed multiple times, and the future behavior is left undefined. ๐
On success, returns a `mpv_node` with a `client_id` field set to the return value of the `mpv_client_id()` API call of the newly created script handle.
---
### ๐ธ Screenshot Commands ๐ธ
- **`screenshot [<flags>]`** โ Take a screenshot. Say cheese bestie ๐งโจ
Multiple flags are available (some can be combined with `+`):
- `<video>` โ Save the video image in its original resolution, without OSD or subtitles. This is the default when no flag is specified, and it does not need to be explicitly added when combined with other flags.
- `<scaled>` โ Save the video image in the current playback resolution.
- `<subtitles>` (default) โ Save the video image with subtitles. Some video outputs may still include the OSD in the output under certain circumstances.
- `<osd>` โ Save the video image with OSD.
- `<window>` โ Save the contents of the mpv window, with OSD and subtitles. This is an alias of `scaled+subtitles+osd`.
- `<each-frame>` โ Take a screenshot each frame. Issue this command again to stop taking screenshots. Note that you should disable frame-dropping when using this mode - or you might receive duplicate images in cases when a frame was dropped. This flag can be combined with the other flags, e.g. `video+each-frame`.
The exact behaviors of all flags other than `each-frame` depend on the selected video output.
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.)
On success, returns a `mpv_node` with a `filename` field set to the saved screenshot location.
- **`screenshot-to-file <filename> [<flags>]`** โ 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 <cyan>Property Expansion</cyan>.
- **`screenshot-raw [<flags> [<format>]]`** โ Return a screenshot in memory. This can be used only through the client API or from a script using `mp.command_native`. 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 the format of the screenshot image data. This can be controlled by the `format` argument. The format can be one of the following:
- `bgr0` (default) โ This format is organized as `B8G8R8X8` (where `B` is the LSB). The contents of the padding `X` are undefined.
- `bgra` โ This format is organized as `B8G8R8A8` (where `B` is the LSB).
- `rgba` โ This format is organized as `R8G8B8A8` (where `R` is the LSB).
- `rgba64` โ This format is organized as `R16G16B16A16` (where `R` is the LSB). Each component occupies 2 bytes per pixel. When this format is used, the image data will be high bit depth, and `--screenshot-high-bit-depth` is ignored.
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 * bpp` 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 * bpp`. Here, `bpp` is the number of bytes per pixel, which is `8` for `rgba64` format and `4` for other formats.
The `flags` argument is like the first argument to `screenshot` and supports `subtitles`, `video`, `window`.
---
### ๐ Filter Commands ๐
- **`af <operation> <value>`** โ Change audio filter chain. See `vf` command. ๐
- **`vf <operation> <value>`** โ Change video filter chain. ๐ฌ
The semantics are exactly the same as with option parsing (see <purple>VIDEO FILTERS</purple>). As such the text below is a redundant and incomplete summary.
The first argument decides what happens:
- `<set>` โ Overwrite the previous filter chain with the new one.
- **`<add>`** โ tack the new filter chain onto the end of the one that's already there, like adding a new charm to your bracelet ๐ซ
- **`<toggle>`** โ checks if that exact filter (with the **exact** parameters, no fudging) is already chilling in the video chain. If it is โ yeet it out. If it isn't โ add it in. (And if you passed several filters to the command, it does this lil dance for *each* one.)
There's a special variant where you combine this with labels and use `@name` with **no** filter name and **no** parameters as the filter entry. That toggles the enable/disable flag instead. ๐๏ธ
- **`<remove>`** โ literally just like toggle but it *always* removes the given filter from the chain, no "maybe it's not there" energy.
- **`<clr>`** โ nukes **all** the filters. But bestie, listen: like the other sub-commands, this does **not** touch automatically inserted filters. Those are not your business, they're the player's business.
The argument is **always** needed. So for `clr` you'd do `vf clr ""`. Yes, the empty string is required, don't @ me ๐
---
You can assign labels to a filter by prefixing it with `@name:` (where *name* is a user-chosen arbitrary identifier โ go feral, it's yours). Labels let you refer to filters by name in **all** of the filter chain modification commands. And for `add`, if you use a label that's already taken, it replaces the existing filter. ๐
The `vf` command shows you the list of requested filters on the OSD after it changes the filter chain. That's roughly equivalent to `show-text ${vf}`. But heads up: auto-inserted filters for format conversion do **not** show up on that list โ only what the user actually requested. โจ
Normally the commands check whether the video chain got recreated successfully, and they'll undo the whole operation if it failed. **But** if the command runs before video is configured (which can totally happen if you run the command immediately after opening a file and before a video frame is decoded), that check can't run at all. And then... yeah, creating the video chain can just fail. ๐ซ
### Example for input.conf
- `a vf set vflip` โ turn the video upside-down on the *a* key ๐
- `b vf set ""` โ remove all video filters on *b*
- `c vf toggle gradfun` โ toggle debanding on *c*
### Example how to toggle disabled filters at runtime
- Add something like `vf-add=@deband:!gradfun` to `mpv.conf`. The `@deband:` is the label โ an arbitrary, user-given name for this filter entry. The `!` before the filter name disables the filter by default. Everything after that is the normal filter name and possibly filter parameters, like in the normal `--vf` syntax. ๐ท๏ธ
- Add a `vf toggle @deband` to `input.conf`. This toggles the `"disabled"` flag for the filter with the label `deband` when the *a* key is hit. ๐
---
### `vf-command <label> <command> <argument> [<target>]`
Send a command to the filter. Real talk though: right now this **only** works with the `lavfi` filter. For the list of supported commands for each filter, go read the libavfilter documentation. ๐
`<label>` is an mpv filter label โ use `all` to send it to every filter at once.
`<command>` and `<argument>` are filter-specific strings.
`<target>` is a filter or filter instance name, and it defaults to `all`. Note that the target is an additional specifier for filters that support them, like complex `lavfi` filter chains. ๐ฏ
### `af-command <label> <command> <argument> [<target>]`
Same as `vf-command`, but for audio filters. ๐ง
---
## โจ Miscellaneous Commands โจ
### `ignore`
Use this to "block" keys that should be unbound and do absolutely nothing. Super useful for disabling default bindings *without* disabling all bindings with `--input-default-bindings=no`. ๐ซ
### `drop-buffers`
Drop audio/video/demuxer buffers and restart from fresh. Might help with unseekable streams that are going out of sync. โ ๏ธ This command might be changed or removed in the future.
### `dump-cache <start> <end> <filename>`
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 (which means you get a file with no packets in it, sad). ๐ญ
Dumping a larger part of the cache will **freeze the player**. No effort was made to fix this, because this feature was meant mostly for creating small excerpts. So... keep it small, bestie.
See `--stream-record` for various caveats that mostly apply to this command too, since 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 the network gets appended to the cache as well. This behaves similar to `--stream-record` (although it does **not** conflict with that option, and both can be 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, except it can block for *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 re-encode 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 being written to.
This command is experimental, and all details about it may change in the future. ๐ (iconic but unstable, we love that for her)
### `ab-loop`
Cycle through A-B loop states. The first command sets the A point (the `ab-loop-a` property); the second sets the B point; and the third clears both points. ๐
### `ab-loop-dump-cache <filename>`
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. ๐
### `ab-loop-align-cache`
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). And 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. โฐ๏ธ
### `begin-vo-dragging`
Begin window dragging if supported by the current VO. This command should **only** be called while a mouse button is being pressed โ otherwise it will be ignored. The exact effect of this command depends on the VO implementation of window dragging. For example, on Windows and macOS only the left mouse button can begin window dragging, while X11 and Wayland allow other mouse buttons. ๐ฑ๏ธ
### `context-menu`
Show the context menu on the video window. See the Context Menu section for details. ๐
**Undocumented commands:** `ao-reload` (experimental/internal). ๐คซ
---
## ๐ List of events ๐
This is a **partial** list of events. This section describes what `mpv_event_to_node()` returns, and that's what the scripting APIs and the JSON IPC see. Note that the C API has separate C-level declarations with `mpv_event`, which may be slightly different. ๐ง
Also, events are **asynchronous**: the player core keeps running while events are delivered to scripts and other clients. In some cases, you can use hooks to enforce synchronous execution. โฑ๏ธ
All events can have the following fields:
- `event` โ Name as the event (as returned by `mpv_event_name()`).
- `id` โ The `reply_userdata` field (an opaque user value). If `reply_userdata` is `0`, the field is not added.
- `error` โ Set to an error string (as returned by `mpv_error_string()`). This field is missing if no error happened, or if the event type does not report errors. Most events leave this unset.
This list uses the event name field value, and the C API symbol in brackets:
### `start-file` (`MPV_EVENT_START_FILE`)
Happens right before a new file is loaded. When you receive this, the player is loading the file (or possibly already done with it). ๐
This has the following fields:
- `playlist_entry_id` โ Playlist entry ID of the file being loaded now.
### `end-file` (`MPV_EVENT_END_FILE`)
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 following fields:
- `reason` โ Has one of these values:
- `eof` โ The file has ended. This can (but doesn't have to) include incomplete files or broken network connections under circumstances.
- `stop` โ Playback was ended by a command.
- `quit` โ Playback was ended by sending the `quit` command.
- `error` โ An error happened. In this case, an `error` field is present with the error string.
- `redirect` โ Happens with playlists and similar. Details see `MPV_END_FILE_REASON_REDIRECT` in the C API.
- **`unknown`** โ <pink>Unknown.</pink> Normally this doesn't happen, unless the Lua API is out of sync with the C API. (Same energy as: your script could get reason strings that didn't even exist yet back when you wrote the script. ๐)
- **`playlist_entry_id`** โ the playlist entry ID of the file that was being played, or was *trying* to be played. Same value as the `playlist_entry_id` field in the matching `start-file` event, bestie.
- **`file_error`** โ set to the mpv error string describing the approximate reason playback failed. Unset if there's no known error. (In Lua scripting, this value was set on the `error` field directly. That's deprecated since mpv 0.33.0. In the future, this `error` field will be unset for this specific event. So like... don't build on it. ๐)
- **`playlist_insert_id`** โ if loading ended because the playlist entry to be played was, for example, a playlist, and the current playlist entry gets replaced with a number of other entries. This may happen at least with `MPV_END_FILE_REASON_REDIRECT` (other event types may use this for similar but different purposes in the future). In this case, `playlist_insert_id` will be set to the playlist entry ID of the first inserted entry, and `playlist_insert_num_entries` to the total number of inserted playlist entries. Note that in this specific case, the ID of the last inserted entry is `playlist_insert_id+num-1`. <red>Beware:</red> depending on circumstances, you may observe the new playlist entries *before* seeing the event (e.g. reading the `playlist` property or getting a property change notification before receiving the event). If this is 0 in the C API, this field isn't added.
- **`playlist_insert_num_entries`** โ see `playlist_insert_id`. Only present if `playlist_insert_id` is present.
---
### `file-loaded` (`MPV_EVENT_FILE_LOADED`)
Happens after a file was loaded and begins playback. ๐ฌ
### `seek` (`MPV_EVENT_SEEK`)
Happens on seeking. (This might include cases when the player seeks internally, even without user interaction โ it's giving sneaky. This includes e.g. segment changes when playing ordered chapters Matroska files.)
### `playback-restart` (`MPV_EVENT_PLAYBACK_RESTART`)
Start of playback after seek or after file was loaded.
### `shutdown` (`MPV_EVENT_SHUTDOWN`)
Sent when the player quits, and the script should terminate. Normally handled automatically. See *Details on the script initialization and lifecycle*.
### `log-message` (`MPV_EVENT_LOG_MESSAGE`)
Receives messages enabled with `mpv_request_log_messages()` (Lua: `mp.enable_messages`).
This contains, on top of the default event fields, the following fields:
- **`prefix`** โ the module prefix, identifies the sender of the message. This is what the terminal player puts in front of the message text when using the `--v` option, and it's also what's used for `--msg-level`.
- **`level`** โ the log level as string. See `msg.log` for possible log level names. Note that later versions of mpv might add new levels or remove (undocumented) existing ones.
- **`text`** โ the log message. The text will end with a newline character. Sometimes it can contain multiple lines.
> Keep in mind that these messages are meant to be hints for humans. You should <red>NOT</red> parse them, and `prefix`/`level`/`text` of messages might change any time. ๐
### `hook`
The event has the following fields:
- **`hook_id`** โ ID to pass to `mpv_hook_continue()`. The Lua scripting wrapper provides a better API around this with `mp.add_hook()`.
### `get-property-reply` (`MPV_EVENT_GET_PROPERTY_REPLY`)
See C API.
### `set-property-reply` (`MPV_EVENT_SET_PROPERTY_REPLY`)
See C API.
### `command-reply` (`MPV_EVENT_COMMAND_REPLY`)
This is one of the commands for which the `error` field is meaningful.
JSON IPC and Lua and possibly other backends treat this specially and may not pass the actual event to the user. See C API.
The event has the following fields:
- **`result`** โ the result (on success) of any `mpv_node` type, if any.
### `client-message` (`MPV_EVENT_CLIENT_MESSAGE`)
Lua and possibly other backends treat this specially and may not pass the actual event to the user.
The event has the following fields:
- **`args`** โ array of strings with the message data.
### `video-reconfig` (`MPV_EVENT_VIDEO_RECONFIG`)
Happens on video output or filter reconfig.
### `audio-reconfig` (`MPV_EVENT_AUDIO_RECONFIG`)
Happens on audio output or filter reconfig.
### `property-change` (`MPV_EVENT_PROPERTY_CHANGE`)
Happens when a property that is being observed changes value.
The event has the following fields:
- **`name`** โ the name of the property.
- **`data`** โ the new value of the property.
> The following events also happen, but are <yellow>deprecated</yellow>: `idle`, `tick`. Use `mpv_observe_property()` (Lua: `mp.observe_property()`) instead. ๐
---
## Hooks ๐ช
Hooks are synchronous events between the player core and a script or similar. This applies to the client API (including the Lua scripting interface). Normally, events are supposed to be asynchronous, and the hook API gives you a way to handle events that need stricter coordination. <red>Not following the protocol exactly can make the player freeze.</red> Use with caution, and honestly just avoid it if synchronous event handling isn't required. ๐ฅถ
The C API is described in the header files. The Lua API is described in the Lua section.
Before a hook is actually invoked on an API client, it will attempt to return new values for all observed properties that were changed before the hook. This may make it easier for an application to set defined "barriers" between property change notifications by registering hooks. (Which means these hooks will have an effect, even if you do nothing and make them continue immediately. iconic behavior fr fr. ๐
)
The following hooks are currently defined:
### `on_load`
Called when a file is to be opened, before anything is actually done. For example, you could read and write the `stream-open-filename` property to redirect a URL to something else (consider support for streaming sites which rarely give the user a direct media URL), or you could set per-file options by setting the property `file-local-options/<option name>`. The player will wait until all hooks are run.
Ordered after `start-file` and before `playback-restart`.
### `on_load_fail`
Called after a file has been opened, but failed to. This can be used to provide a fallback in case native demuxers failed to recognize the file, instead of always running before the native demuxers like `on_load`. Demux will only be retried if `stream-open-filename` was changed. If it fails again, this hook is *not* called again, and loading definitely fails. ๐ญ
Ordered after `on_load`, and before `playback-restart` and `end-file`.
### `on_preloaded`
Called after a file has been opened, and before tracks are selected and decoders are created. This has some usefulness if an API user 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.
Ordered after `on_load_fail` etc. and before `playback-restart`.
### `on_unload`
Run before closing a file, and before actually uninitializing everything. It's not possible to resume playback in this state.
Ordered before `end-file`. Will also happen in the error case (then after `on_load_fail`).
### `on_before_start_file`
Run before a `start-file` event is sent. (If any client changes the current playlist entry, or sends a quit command to the player, the corresponding event will not actually happen after the hook returns.) Useful to drain property changes before a new file is loaded.
### `on_after_end_file`
Run after an `end-file` event. Useful to drain property changes after a file has finished.
---
## Input Command Prefixes โจ๏ธโจ
These prefixes get placed between the key name and the actual command. You can stack multiple prefixes โ they're separated by whitespace.
- **`osd-auto`** โ use the default behavior for this command. This is the default for `input.conf` commands. Some libmpv/scripting/IPC APIs do not use this as default, but use `no-osd` instead.
- **`no-osd`** โ do not use any OSD for this command.
- **`osd-bar`** โ if possible, show a bar with this command. Seek commands will show the progress bar, property changing commands may show the newly set value.
- **`osd-msg`** โ if possible, show an OSD message with this command. Seek commands show the current playback time, property changing commands show the newly set value as text.
- **`osd-msg-bar`** โ combine `osd-bar` and `osd-msg`.
- **`raw`** โ do not expand properties in string arguments. (Like `"${property-name}"`.) This is the default for some libmpv/scripting/IPC APIs.
- **`expand-properties`** โ all string arguments are expanded as described in *Property Expansion*. This is the default for `input.conf` commands.
- **`repeatable`** โ for some commands, keeping a key pressed doesn't run the command repeatedly. This prefix forces enabling key repeat in any case. For a list of commands: the first command determines the repeatability of the whole list (up to and including version 0.33 โ a list was always repeatable).
- **`nonrepeatable`** โ for some commands, keeping a key pressed runs the command repeatedly. This prefix forces disabling key repeat in any case.
- **`nonscalable`** โ okay so picture this: some commands (like `add`) get bound to scalable keys on a high-precision input device, like a touchpad's `WHEEL_UP`. When that happens, the value you specified in the command gets scaled down into smaller steps based on the high-res input data, if there is any. This prefix just says "no thank you bestie" and disables that, so the value always moves in the discrete unit you actually wrote in the key binding. ๐
- **`async`** โ lets the command execute asynchronously, if possible. Heads up tho: only a *few* commands support this (usually it's explicitly documented per command). Some commands are async by default anyway โ or more like, their effects might show up after the command already finished. Ngl, the semantics of this flag might change in the future, so only set it if you're not relying on the command's effects being fully done by the time it returns. Peep <cyan>Synchronous vs. Asynchronous</cyan> below. ๐
- **`sync`** โ lets the command execute synchronously, if possible. Normally every command is synchronous by default, but a few are async by default for compatibility with how things used to be.
> ๐ธ All of the <pink>`osd`</pink> prefixes are still overridden by the global `--osd-level` settings. No exceptions, periodt.
---
## ๐ซ Synchronous vs. Asynchronous
The `async` and `sync` prefixes only matter for <hotpink>how the issuer of the command waits on the command's completion</hotpink>. Normally they don't change how the command behaves on its own. Here are the cases, bestie:
- Normal `input.conf` commands are <rainbow>always</rainbow> run asynchronously. Slow-running commands get queued up or run in parallel.
- "Multi" `input.conf` commands (that's 1 key binding, concatenated with `;`) get executed in order โ except for commands that are async (either prefixed with `async`, or async by default for certain commands). Those async commands run in a detached manner, possibly in parallel with the remaining sync commands in the list. ๐ฆ
- Normal Lua and libmpv commands (like `mpv_command()`) run in a blocking manner, unless the `async` prefix is used or the command is async by default. So in the sync case the caller *will* block, even if the core keeps on playing. Async mode runs the command detached.
- The async libmpv command API (like `mpv_command_async()`) <green>never</green> blocks the caller, and always notifies completion with a message. The `sync` and `async` prefixes make zero difference there.
- Lua also provides APIs for running async commands, which behave similarly to their C counterparts.
- In <purple>all</purple> cases, async mode can still run commands synchronously, even in detached mode. This can happen when a command just doesn't have an asynchronous implementation. But the async libmpv API still never blocks the caller in those cases. ๐
Before mpv 0.29.0, the `async` prefix was only used by screenshot commands, and it made them run the file-saving code detached. That's the default now, and `async` only changes behavior in the ways listed above.
Currently, these 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`.
---
## ๐ Asynchronous command details
On the API level, every asynchronous command is <hotpink>bound to the context that started it</hotpink>. So like, an async command started by `mpv_command_async` is bound to the `mpv_handle` passed to that function. Only *that* `mpv_handle` gets the completion notification (`MPV_EVENT_COMMAND_REPLY`), and only that handle can directly abort a still-running command. And if the `mpv_handle` gets destroyed, any still-running async commands it started are terminated too. Gone. ๐
The scripting APIs and JSON IPC give each script/connection its own implicit `mpv_handle`. Cute, right?
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 moment `MPV_EVENT_SHUTDOWN` is sent, and there is <red>no way to prevent this</red>. Sorry bestie. ๐ซ
---
## โจ๏ธ Input Sections
Input sections group a set of bindings together and enable or disable them all at once. In `input.conf`, each key binding gets assigned to an input section โ rather than there actually being explicit text sections. ๐
See also: `enable-section` and `disable-section` commands.
Predefined bindings:
- `default` โ bindings with no input section are implicitly assigned to this one. It's enabled by default during normal playback. ๐
- `encode` โ the section that's active in encoding mode. It's enabled exclusively, so bindings in the `default` sections get ignored.
---
## ๐ฎ Properties
Properties are how you set mpv options during runtime, or query arbitrary info. You can mess with them using the `set`/`add`/`cycle` commands, and retrieve them with `show-text`, or anything else that uses property expansion. (See <cyan>Property Expansion</cyan>.)
If an option is being referenced, the property will normally take/return <green>exactly the same values</green> as the option. In those cases, properties are basically just a way to change an option at runtime.
> โญ Heads up: a lot of properties are <red>unavailable at startup</red>. See <cyan>Details on the script initialization and lifecycle</cyan>.
---
### ๐ Property list
> ๐ก **Note:**
> Most options can be set at runtime via properties too. Just yeet the leading `--` off the option name. Those aren't documented below โ go see <cyan>OPTIONS</cyan> instead. Only the properties that *don't* exist as an option with the same name, or that behave very differently from the options, are documented down here.
>
> Properties marked as **(RW)** are writeable. The ones that aren't marked? Read-only, bestie. ๐
---
**`audio-speed-correction`, `video-speed-correction`**
Factor multiplied with `speed` at which the player attempts to play the file. Usually it's exactly `1`. (Display sync mode is what makes this useful.)
OSD formatting displays it in the form of `+1.23456%`, where the number is `(raw - 1) * 100` for the given raw property value. โจ
**`display-sync-active`**
Whether `--video-sync=display` is actually active.
**`filename`**
The currently played file, with the path stripped. If it's a URL, mpv also tries to undo percent encoding. (The result isn't necessarily correct, but it looks nicer for display purposes. Use the `path` property if you want an unmodified filename.)
This has a sub-property:
- `filename/no-ext` โ like the `filename` property, but if the text contains a `.`, it strips all text after the last `.`. Usually this removes the file extension. ๐
**`file-size`**
Length in bytes of the source file/stream. (This is the same as `${stream-end}`. For segmented/multi-part files, this returns the size of the main or manifest file, whatever that happens to be.)
**`estimated-frame-count`**
Total number of frames in the current file.
> ๐ **Note:**
> This is only an *estimate*. (It's computed from two unreliable quantities: fps and stream length.)
**`estimated-frame-number`**
Number of the current frame in the current stream.
> ๐ **Note:**
> This is only an *estimate*. (It's computed from two unreliable quantities: fps and possibly rounded timestamps.)
**`pid`**
Process-id of mpv.
**`path`**
Full absolute path of the currently played file.
**`stream-open-filename`**
The full path to the currently played media. This differs from `path` only in special cases. In particular, if `--ytdl=yes` is used and the URL is detected by youtube-dl, then the script will set this property to the actual media URL. This property should be set <hotpink>only</hotpink> during the `on_load` or `on_load_fail` hooks, otherwise it will have no effect (or may do something implementation defined in the future ๐). The property is reset if playback of the current media ends.
**`media-title`**
If the currently played file has a `title` tag, use that.
Otherwise, return the `filename` property.
**`file-format`**
Symbolic name of the file format. In some cases this is a comma-separated list of format names, e.g. `mp4` is `mov,mp4,m4a,3gp,3g2,mj2` (the list may grow in the future for any format). ๐
**`current-demuxer`**
Name of the current demuxer. (This is useless.)
(Renamed from `demuxer`.)
**`stream-path`**
Filename (full path) of the stream layer filename. (This is probably useless and is almost never different from `path`.)
**`stream-pos`**
Raw byte position in the source stream. Technically, this returns the position of the most recent packet passed to a decoder.
**`stream-end`**
Raw end position in bytes in the source stream.
**`duration`**
Duration of the current file in seconds. If the duration is unknown, the property is unavailable. Note that the file duration isn't 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.)
This has a sub-property:
- `duration/full` โ `duration` with milliseconds.
**`avsync`**
Last A/V synchronization difference. Unavailable if audio or video is disabled.
**`total-avsync-change`**
Total A-V sync correction done. Unavailable if audio or video is disabled.
**`decoder-frame-drop-count`**
Video frames dropped by the decoder, because the video is too far behind the audio (when using `--framedrop=decoder`). Sometimes this may get incremented in other situations, e.g. when video packets are damaged, or when the decoder doesn't follow the usual rules. Unavailable if video is disabled.
**`frame-drop-count`**
Frames dropped by the VO (when using `--framedrop=vo`).
**`mistimed-frame-count`**
Number of video frames that weren't timed correctly in display-sync mode, all for the sake of keeping A/V sync. This does <red>not</red> include external circumstances, like video rendering being too slow or the graphics driver somehow skipping a vsync. It doesn't include rounding errors either (which can happen especially with bad source timestamps). For example, using the `display-desync` mode should never change this value from `0`. ๐ค
**`vsync-ratio`**
For how many vsyncs a frame is displayed on average. This is only available if display-sync is active. For 30 FPS video on a 60 Hz screen, this will be `2`. This is the moving average of what actually got scheduled, so 24 FPS on 60 Hz will never stay exactly on `2.5` โ it'll jitter depending on the last frame displayed. ๐ฆ
- **`vo-delayed-frame-count`** โ an estimate of how many frames got held up by outside circumstances while you're in display-sync mode. <yellow>Real talk tho</yellow>: mpv literally has to *guess* that this is even happening, and the guess can be straight-up wrong. ๐
- **`percent-pos`** <pink>(RW)</pink> โ your position in the current file, `0`-`100`. The reason you'd reach for this instead of crunching the number yourself from other properties: it properly falls back to estimating the playback position from the byte position when the file duration isn't known. <mint>Built-in glow-up.</mint> ๐
- **`time-pos`** <pink>(RW)</pink> โ your position in the current file, in seconds. โฑ๏ธ
- **`time-pos/full`** โ `time-pos` but with milliseconds. bestie said *precision*.
- **`time-start`** โ <red>deprecated, babe</red>. Always returns `0`. Back before mpv 0.14 it used to hand you the start time of the file (which could mess with stuff like transport streams). See the `--rebase-start-time` option if you're curious.
- **`time-remaining`** โ how much of the file is left, in seconds. โณ And no, the file duration isn't always exactly known, so this is an estimate, not gospel.
- **`time-remaining/full`** โ `time-remaining` with milliseconds.
- **`audio-pts`** โ the current audio playback position in the current file, in seconds. Unlike `time-pos`, this refreshes more often than once per frame ๐ฅ โ and yeah, for audio-only files it's basically the same as `time-pos`, except it also factors in the audio driver delay. Which means it can go **negative** in certain cases, so honestly you probably just want plain `time-pos`.
- **`audio-pts/full`** โ `audio-pts` with milliseconds.
- **`playtime-remaining`** โ `time-remaining`, but scaled by the current speed. ๐โโ๏ธ
- **`playtime-remaining/full`** โ `playtime-remaining` with milliseconds.
- **`playback-time`** <pink>(RW)</pink> โ an alias for `time-pos`. Before mpv 0.39.0, `time-pos` and `playback-time` could report *different* values in certain edge cases. ๐ญ
- **`playback-time/full`** โ `playback-time` with milliseconds.
- **`remaining-file-loops`** โ how many more times the current file is gonna loop. It gets initialized from the value of `--loop-file`, and it counts the number of times it makes the player seek back to the beginning of the file โ so it's `0` on the last time it plays. `-1` means infinity, obviously. โพ๏ธ
- **`remaining-ab-loops`** โ same energy, but for the current A-B loop, *if* one is active. Initialized from `--ab-loop-count`, and it counts how many times it makes the player seek to `--ab-loop-a`, so it's `0` the last time the loop plays. `-1` = infinity. ๐
- **`chapter`** <pink>(RW)</pink> โ the current chapter number. The first chapter is `0`. A value of `-1` means your current playback position is before the start of the first chapter. Setting this property does an absolute seek to the start of the chapter. <yellow>But watch out</yellow>: if you change it with the `add` or `cycle` command and that results in a *decrement* in value, it might jump to the start of the current chapter instead of the previous one. See `--chapter-seek-threshold` for the deets.
- **`edition`** <pink>(RW)</pink> โ the current edition number. Setting it to a different value will restart playback. The first edition is `0`. For Matroska files this is the edition; for DVD/Blu-ray it's the title. ๐ Before mpv 0.31.0 this showed the actual edition selected at runtime if you hadn't set the option or property yourself. With mpv 0.31.0 and later, it *strictly* returns the user-set option or property value, and the `current-edition` property was added to hand you the runtime-selected edition instead (which matters with `--edition=auto`, the default).
- **`current-edition`** โ the edition that's actually selected right now. This property is unavailable if no file is loaded, or if the file has no editions. (Matroska files distinguish between having *no* editions and having a *single* edition, and the property reflects that โ although in practice it doesn't matter. ๐)
- **`chapters`** โ number of chapters. ๐ข
- **`editions`** โ number of editions.
- **`edition-list`** โ the list of editions, with the current one marked. ๐ It's got a bunch of sub-properties; swap *`N`* for the 0-based edition index.
- **`edition-list/count`** โ number of editions. If there are none, this can be `0` or `1` (`1` if there's a useless dummy edition).
- **`edition-list/N/id`** โ edition ID as an integer. Currently the same as the edition index.
- **`edition-list/N/default`** โ whether this is the default edition.
- **`edition-list/N/title`** โ the edition title as stored in the file. Not always available.
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua's `mp.get_property_native`, it returns a `mpv_node` that looks like this:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each edition) "id" MPV_FORMAT_INT64 "title" MPV_FORMAT_STRING "default" MPV_FORMAT_FLAG
- **`metadata`** โ metadata key/value pairs. ๐ท๏ธ If you access it with Lua's `mp.get_property_native`, you get a table with metadata keys mapping to metadata values. If you access it with the client API, you get a `MPV_FORMAT_NODE_MAP` with tag keys mapping to tag values. For OSD it returns a formatted list. And trying to grab this property as a raw string just doesn't work. ๐
โโ๏ธ
It's got a number of sub-properties:
- **`metadata/by-key/<key>`** โ value of the metadata entry *`<key>`*.
- **`metadata/list/count`** โ number of metadata entries.
- **`metadata/list/N/key`** โ key name of the Nth metadata entry. (The first entry is `0`.)
- **`metadata/list/N/value`** โ value of the Nth metadata entry.
- **`metadata/<key>`** โ the old version of `metadata/by-key/<key>`. <red>Use is discouraged</red>, because the metadata key string could conflict with other sub-properties. ๐
> The layout of this property might be subject to change, and suggestions are welcome on how exactly it should work.
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua's `mp.get_property_native`, it returns a `mpv_node` that looks like this:
MPV_FORMAT_NODE_MAP (key and string value for each metadata entry)
- **`filtered-metadata`** โ like `metadata`, except it only includes the fields listed in the `--display-tags` option. It's the same set of tags that gets printed to the terminal. ๐จ๏ธ
- **`chapter-metadata`** โ metadata of the current chapter. Works just like the `metadata` property, and it lets you use the same access methods (the sub-properties). Per-chapter metadata is *super* rare, ngl โ usually only the chapter name (`title`) is set. For other stuff like chapter start, go look at the `chapter-list` property instead. ๐
- **`vf-metadata/<filter-label>`** โ metadata added by video filters. You reach it by the filter label, which โ if you didn't explicitly set it with the `@filter-label:` syntax โ will be `<filter-name>.NN`. Works like the `metadata` property and allows the same access methods (via sub-properties). A cute example of this kind of metadata is the cropping parameters added by `--vf=lavfi=cropdetect`. โ๏ธ
- **`af-metadata/<filter-label>`** โ same as `vf-metadata/<filter-label>`, but for audio filters. ๐ง
- **`deinterlace-active`** โ returns `yes`/`true` if mpv's deinterlacing filter is active. Note that it will **not** detect any manually inserted deinterlacing filters you did via `--vf`. ๐
- **`idle-active`** โ returns `yes`/`true` if no file is loaded but the player is sticking around because of the `--idle` option. (Renamed from `idle`.)
- **`core-idle`** โ whether the playback core is paused. This can differ from `pause` in special situations, like when the player pauses itself because of low network cache. It also returns `yes`/`true` if playback is restarting, or if nothing is playing at all. In other words, it's only `no`/`false` if there's *actually* video playing. (Behavior since mpv 0.7.0.) โธ๏ธ
- **`cache-speed`** โ the current I/O read speed between the cache and the lower layer (like the network). This gives you the number of bytes per second over a 1 second window (using the type `MPV_FORMAT_INT64` for the client API). It's the same as `demuxer-cache-state/raw-input-rate`. ๐
- **`demuxer-cache-duration`** โ the approximate duration of video buffered in the demuxer, in seconds. The guess is *very* unreliable, and often the property won't be available at all, even when data is buffered. ๐ญ
- **`demuxer-cache-time`** โ the approximate time of video buffered in the demuxer, in seconds. Same as `demuxer-cache-duration` but it returns the last timestamp of the buffered data in the demuxer.
- **`demuxer-cache-idle`** โ whether the demuxer is idle, meaning the demuxer cache is filled to the requested amount and it's currently not reading more data. ๐ด
- **`demuxer-cache-state`** โ every entry in `seekable-ranges` represents a region in the demuxer cache you can seek to, with a `start` and `end` field holding the respective timestamps. If there are multiple demuxers active, this only returns info about the "main" demuxer โ though that might change in the future to return unified info about all of them. The ranges come in arbitrary order, and often they'll overlap a bit before getting joined. In broken corner cases, the 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.
- <pink>**`bof-cached`**</pink> โ tells you whether the seek range with the *lowest* timestamp points to the beginning of the stream (BOF). If it does, bestie, that literally means you **cannot seek before this position at all**. And <pink>**`eof-cached`**</pink> โ tells you whether the seek range with the *highest* timestamp points to the end of the stream (EOF). And if both `bof-cached` and `eof-cached` are true, and there's only **1** cache range, the entire stream is cached. Slay. โจ
- <pink>**`fw-bytes`**</pink> โ the number of bytes of packets buffered in the range starting from the current decoding position. This is a *rough* estimate (it may not account correctly for various overhead), and it stops at the demuxer position (so it ignores seek ranges after it).
- <pink>**`file-cache-bytes`**</pink> โ 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 wasn't enabled with `--cache-on-disk=yes`.
- <pink>**`cache-end`**</pink> โ is `demuxer-cache-time`. Missing if unavailable.
- <pink>**`reader-pts`**</pink> โ the approximate timestamp of the start of the buffered range. Missing if unavailable.
- <pink>**`cache-duration`**</pink> โ is `demuxer-cache-duration`. Missing if unavailable.
- <pink>**`raw-input-rate`**</pink> โ the estimated input rate of the network layer (or any other byte-oriented input layer) in **bytes per second**. May be inaccurate or missing. ๐
- <pink>**`ts-per-stream`**</pink> โ an array containing an entry for each stream type: <purple>video</purple>, <purple>audio</purple>, and <purple>subtitle</purple>. For each stream type, the details for the demuxer cache for that stream type are available as `cache-duration`, `reader-pts` and `cache-end`.
When you query this 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 "cache-end" MPV_FORMAT_DOUBLE "reader-pts" MPV_FORMAT_DOUBLE "cache-duration" MPV_FORMAT_DOUBLE "raw-input-rate" MPV_FORMAT_INT64 "ts-per-stream" MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP "type" MPV_FORMAT_STRING "cache-duration" MPV_FORMAT_DOUBLE "reader-pts" MPV_FORMAT_DOUBLE "cache-end" MPV_FORMAT_DOUBLE
Other fields (might be changed or removed in the future, so don't get too attached ๐):
- <pink>**`eof`**</pink> โ whether the reader thread has hit the end of the file.
- <pink>**`underrun`**</pink> โ whether the reader thread could not satisfy a decoder's request for a new packet.
- <pink>**`idle`**</pink> โ whether the thread is currently not reading.
- <pink>**`total-bytes`**</pink> โ sum of packet bytes (plus some overhead estimation) of the entire packet queue, including cached seekable ranges.
## ๐ฆ `demuxer-via-network`
Whether the stream demuxed via the main demuxer is most likely played via network. Okay so, what actually counts as "network" is not always clear, it might be used for other types of untrusted streams, it could be **wrong** in certain cases, and its definition might be changing. Also, external files (like separate audio files or streams) do **not** influence the value of this property (currently).
## ๐ฆ `demuxer-start-time`
The start time reported by the demuxer in fractional seconds.
## ๐ฆ `paused-for-cache`
Whether playback is paused because of waiting for the cache. (It's giving buffering, but make it fancy. ๐
)
## ๐ฆ `cache-buffering-state`
The percentage (<purple>0-100</purple>) of the cache fill status until the player will unpause (related to `paused-for-cache`).
## ๐ฆ `eof-reached`
Whether the end of playback was reached. Note that this is usually interesting only if `--keep-open` is enabled, since otherwise the player will immediately play the next file (or exit or enter idle mode), and in these cases the `eof-reached` property will logically be cleared immediately after it's set. So like, blink and you miss it. ๐ญ
## ๐ฆ `seeking`
Whether the player is currently seeking, or otherwise trying to restart playback. (It's possible that it returns yes/true while a file is loaded. This is because the same underlying code is used for seeking and resyncing.) iykyk.
## ๐ฆ `mixer-active`
Whether the audio mixer is active.
This option is relatively useless, ngl. Before mpv `0.18.1`, it could be used to infer behavior of the `volume` property.
## ๐ฆ `ao-volume` (RW)
System volume. This property is available **only** if mpv audio output is currently active, and **only** if the underlying implementation supports volume control. What this option does, or how the value is interpreted depends on the API. For example, on ALSA this usually changes system-wide audio volume on a linear curve, while with PulseAudio this controls per-application volume on a cubic curve. Different vibes, same slider. ๐๏ธ
## ๐ฆ `ao-mute` (RW)
Similar to `ao-volume`, but controls the mute state. May be unimplemented even if `ao-volume` works. Rude, but okay. ๐
## ๐ฆ `audio-params`
Audio format as output by the audio decoder. This has a number of sub-properties:
- <pink>**`audio-params/format`**</pink> โ the sample format as string. This uses the same names as used in other places of mpv.
- <pink>**`audio-params/samplerate`**</pink> โ samplerate.
- <pink>**`audio-params/channels`**</pink> โ the channel layout as a string. This is similar to what the `--audio-channels` accepts.
- <pink>**`audio-params/hr-channels`**</pink> โ as `channels`, but instead of the possibly cryptic actual layout sent to the audio device, return a hopefully more human readable form. (Usually only `audio-out-params/hr-channels` makes sense.)
- <pink>**`audio-params/channel-count`**</pink> โ number of audio channels. This is redundant to the `channels` field described above.
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
## ๐ฆ `audio-out-params`
Same as `audio-params`, but the format of the data written to the audio API.
## ๐ฆ `colormatrix`
Redirects to `video-params/colormatrix`. This parameter (as well as similar ones) can be overridden with the `format` video filter.
## ๐ฆ `colormatrix-input-range`
See `colormatrix`.
## ๐ฆ `colormatrix-primaries`
See `colormatrix`.
## ๐ฆ `hwdec` (RW)
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. Fingers crossed bestie. ๐ค
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. Noted. โจ
## ๐ฆ `hwdec-current`
The current hardware decoding in use. If decoding is active, return one of the values used by the `hwdec` option/property. `no` indicates software decoding. If no decoder is loaded, the property is unavailable.
## ๐ฆ `hwdec-interop`
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. It's giving "it depends". ๐ซ
## ๐ฆ `width`, `height`
Video size. This uses the size of the video as decoded, or if no video frame has been decoded yet, the (possibly incorrect) container indicated size. Bestie that container size may be lying to you, lowkey. ๐ญ
## ๐ฆ `video-params`
Video parameters, as output by the decoder (with overrides like `aspect` etc. applied). This has a number of sub-properties:
- <pink>**`video-params/pixelformat`**</pink> โ the pixel format as string. This uses the same names as used in other places of mpv.
- <pink>**`video-params/hw-pixelformat`**</pink> โ the underlying pixel format as string. This is relevant for some cases of hardware decoding and unavailable otherwise.
- <pink>**`video-params/average-bpp`**</pink> โ average bits-per-pixel as integer. Subsampled planar formats use a different resolution, which is the reason this value can sometimes be odd or confusing. Can be unavailable with some formats.
- <pink>**`video-params/w`**, **`video-params/h`**</pink> โ video size as integers, with **no** aspect correction applied.
- <pink>**`video-params/dw`**, **`video-params/dh`**</pink> โ video size as integers, scaled for correct aspect ratio.
- <pink>**`video-params/crop-x`**, **`video-params/crop-y`**</pink> โ crop offset of the source video frame.
- <pink>**`video-params/crop-w`**, **`video-params/crop-h`**</pink> โ video size after cropping.
- <pink>**`video-params/aspect`**</pink> โ display aspect ratio as double.
- <pink>**`video-params/aspect-name`**</pink> โ display aspect ratio name as string. The name corresponds to motion picture film format that introduced given aspect ratio in film. Cinema history lesson, no cap. ๐ฌ
- <pink>**`video-params/par`**</pink> โ pixel aspect ratio.
- <pink>**`video-params/sar`**</pink> โ storage aspect ratio.
- <pink>**`video-params/sar-name`**</pink> โ storage aspect ratio name as string.
### `video-params/colormatrix`
The colormatrix that's in use rn, as a string. (Exact values subject to change, so don't get too attached ๐
)
### `video-params/colorlevels`
The colorlevels as a string. (Exact values subject to change, bestie, they said what they said.)
### `video-params/primaries`
The primaries in use as a string. (Exact values subject to change.)
### `video-params/gamma`
The gamma function in use as a string. (Exact values subject to change.)
### `video-params/sig-peak` (deprecated)
The video file's tagged signal peak, as a float. <red>Deprecated</red>, so it's giving vintage, not giving recommended.
### `video-params/light`
The light type in use as a string. (Exact values subject to change.)
### `video-params/chroma-location`
Chroma location as a string. (Exact values subject to change.)
### `video-params/rotate`
Intended display rotation, in degrees, clockwise. ๐
### `video-params/stereo-in`
The source file's stereo 3D mode. (Peep the `format` video filter's `stereo-in` option for the lore.)
### `video-params/alpha`
Alpha type. If the format has no alpha channel, this will be **unavailable** โ but in future releases, it could change to `no`. If alpha *is* present, this gets set to `straight` or `premul`.
### `video-params/min-luma`
Minimum luminance, as reported by HDR10 metadata (in cd/mยฒ).
### `video-params/max-luma`
Maximum luminance, as reported by HDR10 metadata (in cd/mยฒ).
### `video-params/max-cll`
Maximum content light level, as reported by HDR10 metadata (in cd/mยฒ).
### `video-params/max-fall`
Maximum frame average light level, as reported by HDR10 metadata (in cd/mยฒ).
### `video-params/scene-max-r`
MaxRGB of a scene for the R component, as reported by HDR10+ metadata (in cd/mยฒ).
### `video-params/scene-max-g`
MaxRGB of a scene for the G component, as reported by HDR10+ metadata (in cd/mยฒ).
### `video-params/scene-max-b`
MaxRGB of a scene for the B component, as reported by HDR10+ metadata (in cd/mยฒ).
### `video-params/max-pq-y`
Maximum PQ luminance of a frame, as reported by peak detection (in PQ, 0-1).
### `video-params/avg-pq-y`
Average PQ luminance of a frame, as reported by peak detection (in PQ, 0-1).
### `video-params/prim-red-x`, `video-params/prim-red-y`
Red primary chromaticity coordinates โ only available if it differs from `video-params/primaries`.
### `video-params/prim-green-x`, `video-params/prim-green-y`
Green primary chromaticity coordinates โ only available if it differs from `video-params/primaries`.
### `video-params/prim-blue-x`, `video-params/prim-blue-y`
Blue primary chromaticity coordinates โ only available if it differs from `video-params/primaries`.
### `video-params/prim-white-x`, `video-params/prim-white-y`
White point chromaticity coordinates โ only available if it differs from `video-params/primaries`.
---
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, it hands back an `mpv_node` with these contents, fr fr:
MPV_FORMAT_NODE_MAP "pixelformat" MPV_FORMAT_STRING "hw-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 "average-bpp" MPV_FORMAT_INT64 "alpha" MPV_FORMAT_STRING "min-luma" MPV_FORMAT_DOUBLE "max-luma" MPV_FORMAT_DOUBLE "max-cll" MPV_FORMAT_DOUBLE "max-fall" MPV_FORMAT_DOUBLE "scene-max-r" MPV_FORMAT_DOUBLE "scene-max-g" MPV_FORMAT_DOUBLE "scene-max-b" MPV_FORMAT_DOUBLE "max-pq-y" MPV_FORMAT_DOUBLE "avg-pq-y" MPV_FORMAT_DOUBLE "prim-red-x" MPV_FORMAT_DOUBLE "prim-red-y" MPV_FORMAT_DOUBLE "prim-green-x" MPV_FORMAT_DOUBLE "prim-green-y" MPV_FORMAT_DOUBLE "prim-blue-x" MPV_FORMAT_DOUBLE "prim-blue-y" MPV_FORMAT_DOUBLE "prim-white-x" MPV_FORMAT_DOUBLE "prim-white-y" MPV_FORMAT_DOUBLE
---
## `dwidth`, `dheight`
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 though โ like, if the user resized the video window manually, that's a whole different number.
These have the same values as `video-out-params/dw` and `video-out-params/dh`.
## `video-dec-params`
Exactly like `video-params`, but with no overrides applied. Same vibe, cleaner receipts.
## `video-out-params`
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, because 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`.
## `video-target-params`
Same as `video-params`, but with the target properties that the VO outputs to.
Has the same sub-properties as `video-params`.
## `video-frame-info`
Approximate information of the current frame. Heads up bestie: if any of these are used on OSD, the information might be off by a few frames, because OSD redrawing and frame display are somewhat disconnected โ you might have to pause and force a redraw to get it right. ๐ญ
This has a number of sub-properties:
### `video-frame-info/picture-type`
The type of the picture. It can be `"I"` (intra), `"P"` (predicted), `"B"` (bi-dir predicted), or unavailable.
### `video-frame-info/interlaced`
Whether the content of the frame is interlaced.
### `video-frame-info/tff`
If the content is interlaced, whether the top field is displayed first.
### `video-frame-info/repeat`
Whether the frame must be delayed when decoding.
### `video-frame-info/gop-timecode`
String with the GOP timecode encoded in the frame.
### `video-frame-info/smpte-timecode`
String with the SMPTE timecode encoded in the frame.
### `video-frame-info/estimated-smpte-timecode`
Estimated timecode based on the current playback position and frame count.
## `container-fps`
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`.)
## `estimated-vf-fps`
Estimated/measured FPS of the video filter chain output. (If no filters are used, this corresponds to decoder output.) This uses the average of the 10 past frame durations to calculate the FPS. It will be inaccurate if frame-dropping is involved (such as when `framedrop` is explicitly enabled, or after precise seeking). Files with imprecise timestamps (such as Matroska) might lead to unstable results. So like, take it as a vibe, not a promise.
## `current-window-scale` (RW)
The `window-scale` value calculated from the current window size. This has the same value as `window-scale` if the window size was not changed since setting the option, and the window size was not restricted in other ways. If the window is fullscreened, this will return the scale value calculated from the last non-fullscreen size of the window. The property is unavailable if no video is active.
It is also possible to write to this property โจ. This has the same behavior as writing `window-scale`. Note that writing to `current-window-scale` will **not** affect the value of `window-scale`.
## `focused`
Whether the window has focus. Might not be supported by all VOs. ๐
## `ambient-light`
Ambient lighting condition in lux. Only observable on macOS (macOS and Linux only)
## `display-names`
Names of the displays that the mpv window covers. Let's break it down by platform, because it's a lot:
- On X11, these are the xrandr names (`LVDS1`, `HDMI1`, `DP1`, `VGA1`, etc.).
- On Windows, these are the GDI names (`\.DISPLAY1`, `\.DISPLAY2`, etc.) and the first display in the list will be the one that Windows considers associated with the window (as determined by the `MonitorFromWindow` API.)
- On macOS these are the Display Product Names as used in the System Information with a serial number in parentheses, and only one display name is returned, since a window can only be on one screen.
- On Wayland, these are the `wl_output` names if protocol version >= 4 is used (`LVDS-1`, `HDMI-A-1`, `X11-1`, etc.), or the `wl_output` model reported by the geometry event if protocol version < 4 is used.
## `display-fps`
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. ๐
## `estimated-display-fps`
The actual rate at which display refreshes seem to occur, measured by system time. Only available if display-sync mode (as selected by `--video-sync`) is active.
- **`vsync-jitter`** โ the estimated deviation factor of how long your vsync actually lasts. โจ
- **`display-width`, `display-height`** โ the current display's horizontal and vertical resolution, in pixels. Whether these values refresh when you drag the mpv window over to another display is <pink>totally up to the windowing backend</pink>, bestie. And ngl, it might just not be available on every platform. ๐
- **`display-hidpi-scale`** โ the HiDPI scale factor, as reported by the windowing backend. If there's no VO active, or the VO just doesn't report a value, this property is unavailable. Fr fr, reporting an absolute DPI might be the saner move, but this is literally how HiDPI support got implemented on most OS APIs. Also see `--hidpi-window-scale`. ๐
- **`osd-width`, `osd-height`** โ the last known OSD width (can be `0`, no drama). You need this if you wanna use the `overlay-add` command. It hands you the actual OSD/window size, *not* counting decorations drawn by the OS window manager. It's an alias to `osd-dimensions/w` and `osd-dimensions/h`. ๐
- **`osd-par`** โ last known OSD display pixel aspect (can be `0` too). Alias to `osd-dimensions/osd-par`.
- **`osd-dimensions`** โ last known OSD dimensions. ๐
It has these sub-properties (readable as `MPV_FORMAT_NODE` or as a Lua table via `mp.get_property_native`):
- **`osd-dimensions/w`** โ size of the VO window in OSD render units (usually pixels, but may be scaled pixels with VOs like `xv`).
- **`osd-dimensions/h`** โ size of the VO window in OSD render units,
- **`osd-dimensions/par`** โ pixel aspect ratio of the OSD (usually `1`).
- **`osd-dimensions/aspect`** โ display aspect ratio of the VO window. (Computed from the properties above.)
- **`osd-dimensions/mt`, `osd-dimensions/mb`, `osd-dimensions/ml`, `osd-dimensions/mr`** โ the OSD to video margins (top, bottom, left, right). This describes the area the video actually gets rendered into.
> Any of these properties may be unavailable or set to dummy values if the VO window isn't created or isn't visible. ๐ญ
- **`term-size`** โ the current terminal size. It's got two sub-properties:
- **`term-size/w`** โ width of the terminal in cells
- **`term-size/h`** โ height of the terminal in cells
> Heads up: this property is **not observable**. If you wanna react to size changes you have to poll for them. ๐ซ
- **`window-id`** โ read-only, it's mpv's window id. May not always be available, i.e. because the window isn't opened yet or the VO doesn't support it. ๐ช
- **`display-swapchain`** โ read-only, the Direct3D 11 swapchain address. Returns an `int64` type value representing the memory address of the D3D11 swapchain. May not always be available, i.e. when `d3d11-output-mode` isn't set to `composition` or the VO doesn't support it. ๐ฅ
- **`mouse-pos`** โ read-only, the last known mouse position, normalized to OSD dimensions. Sub-properties (readable as `MPV_FORMAT_NODE` or a Lua table via `mp.get_property_native`):
- **`mouse-pos/x`, `mouse-pos/y`** โ last known coordinates of the mouse pointer.
- **`mouse-pos/hover`** โ boolean, whether the mouse pointer hovers the video window. The coordinates should be **ignored** when this value is `false`, because the video backends only update them when the pointer is hovering the window. ๐ญ
- **`touch-pos`** โ read-only, the last known touch point positions, normalized to OSD dimensions. โจ
It has a bunch of sub-properties. Replace `N` with the 0-based touch point index. Whenever a new finger touches the screen, a new touch point gets added to the list of touch points with the smallest unused `N` available. ๐
- **`touch-pos/count`** โ number of active touch points.
- **`touch-pos/N/x`, `touch-pos/N/y`** โ position of the Nth touch point.
- **`touch-pos/N/id`** โ unique identifier of the touch point. Use this to identify individual touch points when their indexes change.
When you query the property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, this returns a `mpv_node` with the following contents:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each touch point) "x" MPV_FORMAT_INT64 "y" MPV_FORMAT_INT64 "id" MPV_FORMAT_INT64
- **`tablet-pos`** โ read-only, the last known tablet tool (pen) position, normalized to OSD dimensions, plus tool state. ๐๏ธ
Sub-properties:
- **`tablet-pos/x`, `tablet-pos/y`** โ last known coordinates of the tablet tool.
- **`tablet-pos/tool-in-proximity`** โ boolean, whether a tablet tool is currently in proximity of the tablet surface / hovers above the tablet surface.
- **`tablet-pos/tool-tip`,** โ the state of the tablet tool tip, up or down.
- **`tablet-pos/tool-stylus-btn1`, `tablet-pos/tool-stylus-btn2`, `tablet-pos/tool-stylus-btn3`** โ the state of tablet tool side buttons, pressed or released.
- **`tablet-pos/pad-focus`** โ boolean, whether a tablet pad is currently focused.
- **`tablet-pos/pad-btns/N`** โ the state of the Nth tablet pad button, pressed or released.
- **`sub-ass-extradata`** โ the current ASS subtitle track's extradata. There's no formatting done, like at all. The extradata gets returned as a string, as-is. This property is **not** available for non-ASS subtitle tracks. ๐
- **`sub-text`** โ the current subtitle text, regardless of sub visibility. Formatting is stripped. If the subtitle isn't text-based (i.e. DVD/BD subtitles), you get an empty string back. ๐
It's got sub-properties for different formats:
- **`sub-text/ass`** โ like `sub-text`, but returns the text in ASS format. Text subtitles in other formats get converted. For native ASS subtitles, events that don't contain any text (but vector drawings etc.) are **not** filtered out. If multiple events match the current playback time, they get concatenated with line breaks. Contains only the `"Text"` part of the events.
> This property is not enough to render ASS subtitles correctly, because the ASS header and per-event metadata aren't returned. Use `/ass-full` for that. ๐ค
- **`sub-text/ass-full`** โ like `sub-text-ass`, but returns the full event with all fields, formatted as lines in a `.ass` text file. Use it with `sub-ass-extradata` for style info.
- **`sub-text-ass` (deprecated)** โ deprecated alias for `sub-text/ass`. ๐
- **`secondary-sub-text`** โ same as `sub-text` (with the same sub-properties), but for the secondary subtitles. ๐
- **`sub-start`** โ the current subtitle start time (in seconds). If there's multiple current subtitles, it returns the first start time. If no current subtitle is present, `null` is returned instead.
Sub-property:
- **`sub-start/full`** โ `sub-start` with milliseconds. โญ
- **`secondary-sub-start`** โ same as `sub-start`, but for the secondary subtitles.
- **`sub-end`** โ the current subtitle end time (in seconds). If there's multiple current subtitles, it returns the last end time. If no current subtitle is present, or if it's present but has unknown or incorrect duration, `null` is returned instead.
Sub-property:
- **`sub-end/full`** โ `sub-end` with milliseconds. โจ
- **`secondary-sub-end`** โ same as `sub-end`, but for the secondary subtitles.
- **`playlist-pos` (RW)** โ the current position on the playlist. The first entry is at position `0`. Writing to this property may start playback at the new position. ๐ต
In some cases this isn't necessarily the currently playing file. See the explanation of the `current` and `playing` flags in `playlist`.
If the playlist is empty, or if it's non-empty but no entry is `"current"`, this property returns `-1`. Likewise, writing `-1` puts the player into idle mode (or exits playback if idle mode isn't enabled). If an out-of-range index is written to the property, this behaves as if writing `-1`. (Before mpv 0.33.0, instead of returning `-1`, this property was unavailable if no playlist entry was current.)
Writing the current value back to the property has **no effect**. Use `playlist-play-index` to restart the playback of the current entry if that's what you want. ๐
- **`playlist-pos-1` (RW)** โ same as `playlist-pos`, but 1-based. ๐ข
- **`playlist-current-pos` (RW)** โ index of the `"current"` item on the playlist. This is usually, but not necessarily, the currently playing item (see `playlist-playing-pos`). Depending on the exact internal state of the player, it may refer to the playlist item to play next, or the playlist item used to determine what to play next. ๐
For reading, this is exactly the same as `playlist-pos`.
For writing, this only sets the position of the `"current"` item, without stopping playback of the current file (or starting playback, if this is done in idle mode). Use `-1` to remove the current flag.
> This property is only vaguely useful, ngl. If you set it during playback, it will typically cause the playlist entry after it to be played next. Another possibly odd observable state: if `playlist-next` is run during playback, this property is set to the playlist entry to play next (unlike the previous case). There's an internal flag that decides whether the current playlist entry or the next one should be played, and this flag is currently inaccessible for API users. (Whether this behavior will be kept is possibly subject to change.) ๐ญ
---
- **`playlist-playing-pos`** โ the index of the item on the playlist that's currently <pink>"playing"</pink>. And bestie, "playing" here is generous: an item counts as playing if it's being loaded, actually playing, *or* being unloaded. mpv sets this property during the `MPV_EVENT_START_FILE` (start-file) and the `MPV_EVENT_START_END` (end-file) events. Any other time? It hands you `-1`. And if the playlist entry got removed mid-playback but playback hasn't stopped yet, or it's in the middle of being stopped, it *also* returns `-1`. (This can happen at least during state transitions.) ๐ฆ
When you're in that "playing" state, this is usually the same as `playlist-pos` โ except during state changes, or if `playlist-current-pos` was written explicitly. iykyk.
- **`playlist-count`** โ the number of total playlist entries. Just a count, nothing dramatic. โจ
- **`playlist-path`** โ the original path of the playlist for the current entry *before* mpv expanded the entries. Unavailable if the file wasn't originally associated with a playlist in some way. ๐
- **`playlist`** โ the playlist, with the current entry marked. Currently, the raw property value is useless (yes, fr, that's the actual documented vibe ๐).
This has a number of sub-properties. Replace *N* with the 0-based playlist entry index.
- **`playlist/count`** โ number of playlist entries (same as `playlist-count`).
- **`playlist/N/filename`** โ filename of the *N*th entry.
- **`playlist/N/playing`** โ `yes`/`true` if the `playlist-playing-pos` property points to this entry, `no`/`false` or unavailable otherwise.
- **`playlist/N/current`** โ `yes`/`true` if the `playlist-current-pos` property points to this entry, `no`/`false` or unavailable otherwise.
- **`playlist/N/title`** โ name of the *N*th entry. Available if the playlist file contains such fields and mpv's parser supports it for the given playlist format, or if the playlist entry has been opened before and a `media-title` other than filename has been acquired.
- **`playlist/N/id`** โ unique ID for this entry. This is an automatically assigned integer ID that is unique for the entire life time of the current mpv core instance. Other commands, events, etc. use this as `playlist_entry_id` fields.
- **`playlist/N/playlist-path`** โ the original path of the playlist for this entry before mpv expanded it. Unavailable if the file was not originally associated with a playlist in some way.
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, it returns a `mpv_node` with these 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) "id" MPV_FORMAT_INT64
---
- **`track-list`** โ the list of audio/video/sub tracks, current entry marked. ๐
This has a number of sub-properties. Replace *N* with the 0-based track index.
- **`track-list/count`** โ total number of tracks.
- **`track-list/video`** โ the list of video tracks. This is only usable for printing and its value can't be retrieved.
- **`track-list/audio`** โ the list of audio tracks. This is only usable for printing and its value can't be retrieved.
- **`track-list/sub`** โ the list of sub tracks. This is only usable for printing and its value can't be retrieved.
- **`track-list/N/id`** โ the ID as it's used for `--sid`/`--aid`/`--vid`. This is unique within tracks of the same type (sub/audio/video), but otherwise not.
- **`track-list/N/type`** โ string describing the media type. One of `audio`, `video`, `sub`.
- **`track-list/N/src-id`** โ track ID as used in the source file. Not always available. (It is missing if the format has no native ID, if the track is a pseudo-track that does not exist in this way in the actual file, or if the format is handled by libavformat, and the format was not whitelisted as having track IDs.)
- **`track-list/N/title`** โ track title as it is stored in the file. Not always available.
- **`track-list/N/lang`** โ track language as identified by the file. Not always available.
- **`track-list/N/image`** โ `yes`/`true` if this is a video track that consists of a single picture, `no`/`false` or unavailable otherwise. The heuristic used to determine if a stream is an image doesn't attempt to detect images in codecs normally used for videos. Otherwise, it is reliable.
- **`track-list/N/albumart`** โ `yes`/`true` if this is an image embedded in an audio file or external cover art, `no`/`false` or unavailable otherwise. ๐
- **`track-list/N/default`** โ `yes`/`true` if the track has the default flag set in the file, `no`/`false` or unavailable otherwise.
- **`track-list/N/forced`** โ `yes`/`true` if the track has the forced flag set in the file, `no`/`false` or unavailable otherwise.
- **`track-list/N/dependent`** โ `yes`/`true` if the track has the dependent flag set in the file, `no`/`false` or unavailable otherwise.
- **`track-list/N/visual-impaired`** โ `yes`/`true` if the track has the visual impaired flag set in the file, `no`/`false` or unavailable otherwise.
- **`track-list/N/hearing-impaired`** โ `yes`/`true` if the track has the hearing impaired flag set in the file, `no`/`false` or unavailable otherwise.
- **`track-list/N/hls-bitrate`** โ the bitrate of the HLS stream, if available.
- **`track-list/N/program-id`** โ the program ID of the HLS stream, if available.
- **`track-list/N/codec`** โ the codec name used by this track, for example `h264`. Unavailable in some rare cases.
- **`track-list/N/codec-desc`** โ the codec descriptive name used by this track.
- **`track-list/N/codec-profile`** โ the codec profile used by this track. Available only if the track has been already decoded.
- **`track-list/N/external`** โ `yes`/`true` if the track is an external file, `no`/`false` or unavailable otherwise. This is set for separate subtitle files.
- **`track-list/N/external-filename`** โ the filename if the track is from an external file, unavailable otherwise.
- **`track-list/N/selected`** โ `yes`/`true` if the track is currently decoded, `no`/`false` or unavailable otherwise.
- **`track-list/N/main-selection`** โ it indicates the selection order of tracks for the same type. If a track is not selected, or is selected by the `--lavfi-complex`, it is not available. For subtitle tracks, `0` represents the sid, and `1` represents the secondary-sid.
- **`track-list/N/ff-index`** โ the stream index as usually used by the FFmpeg utilities. Note that this can be potentially wrong if a demuxer other than libavformat (`--demuxer=lavf`) is used. For mkv files, the index will usually match even if the default (builtin) demuxer is used, but there is no hard guarantee. ๐
- **`track-list/N/decoder`** โ if this track is being decoded, the short decoder name,
- **`track-list/N/decoder-desc`** โ if this track is being decoded, the human-readable decoder name,
- **`track-list/N/demux-w`, `track-list/N/demux-h`** โ video size hint as indicated by the container. (Not always accurate.)
- **`track-list/N/demux-crop-x`, `track-list/N/demux-crop-y`** โ crop offset of the source video frame.
- **`track-list/N/demux-crop-w`, `track-list/N/demux-crop-h`** โ video size after cropping.
- **`track-list/N/demux-channel-count`** โ number of audio channels as indicated by the container. (Not always accurate โ in particular, the track could be decoded as a different number of channels.)
- **`track-list/N/demux-channels`** โ channel layout as indicated by the container. (Not always accurate.)
- **`track-list/N/demux-samplerate`** โ audio sample rate as indicated by the container. (Not always accurate.)
- **`track-list/N/demux-fps`** โ video FPS as indicated by the container. (Not always accurate.)
- **`track-list/N/demux-bitrate`** โ audio average bitrate, in bits per second. (Not always accurate.)
- **`track-list/N/demux-rotation`** โ video clockwise rotation metadata, in degrees.
- **`track-list/N/demux-par`** โ pixel aspect ratio.
- **`track-list/N/format-name`** โ short name for format from ffmpeg. If the track is audio, this will be the name of the sample format. If the track is video, this will be the name of the pixel format.
- **`track-list/N/audio-channels`** <red>(deprecated)</red> โ deprecated alias for `track-list/N/demux-channel-count`.
- **`track-list/N/replaygain-track-peak`, `track-list/N/replaygain-track-gain`** โ per-track replaygain values. Only available for audio tracks with corresponding information stored in the source file.
- **`track-list/N/replaygain-album-peak`, `track-list/N/replaygain-album-gain`** โ per-album replaygain values. If the file has per-track but no per-album information, the per-album values will be copied from the per-track values currently. It's possible that future mpv versions will make these properties unavailable instead in this case.
- **`track-list/N/dolby-vision-profile`, `track-list/N/dolby-vision-level`** โ Dolby Vision profile and level. May not be available if the container does not provide this information. ๐
### ๐ธ `track-list/N/metadata`
Okay so this is literally the `metadata` property but make it <pink>per-track</pink> ๐
Like, instead of the global values for the whole entire file, you get the metadata that's set per track/stream. iykyk.
When you're querying this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, bestie, it's gonna hand you back an `mpv_node` that looks exactly like this:
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 "image" MPV_FORMAT_FLAG "albumart" MPV_FORMAT_FLAG "default" MPV_FORMAT_FLAG "forced" MPV_FORMAT_FLAG "dependent" MPV_FORMAT_FLAG "visual-impaired" MPV_FORMAT_FLAG "hearing-impaired" MPV_FORMAT_FLAG "hls-bitrate" MPV_FORMAT_INT64 "program-id" MPV_FORMAT_INT64 "selected" MPV_FORMAT_FLAG "main-selection" MPV_FORMAT_INT64 "external" MPV_FORMAT_FLAG "external-filename" MPV_FORMAT_STRING "codec" MPV_FORMAT_STRING "codec-desc" MPV_FORMAT_STRING "codec-profile" MPV_FORMAT_STRING "ff-index" MPV_FORMAT_INT64 "decoder" MPV_FORMAT_STRING "decoder-desc" MPV_FORMAT_STRING "demux-w" MPV_FORMAT_INT64 "demux-h" MPV_FORMAT_INT64 "demux-crop-x" MPV_FORMAT_INT64 "demux-crop-y" MPV_FORMAT_INT64 "demux-crop-w" MPV_FORMAT_INT64 "demux-crop-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 "format-name" MPV_FORMAT_STRING "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 "dolby-vision-profile" MPV_FORMAT_INT64 "dolby-vision-level" MPV_FORMAT_INT64 "metadata" MPV_FORMAT_NODE_MAP (key and string value for each metadata entry)
---
### ๐ฆ `current-tracks/...`
This one gives you access to the tracks that are <hotpink>currently selected</hotpink> โจ It just redirects you to the correct entry in `track-list`.
Here are the sub-entries that are defined: `video`, `audio`, `sub`, `sub2`
So like, for example, `current-tracks/audio/lang` returns the current audio track's `lang` field โ same value as `track-list/N/lang`, no cap ๐ซถ
If tracks of the type you asked for are selected via `--lavfi-complex`, then the first one is what gets returned.
---
### ๐ `chapter-list` (RW)
A list of chapters, with the current one marked. So cute, so organized ๐
It's got a bunch of sub-properties. Just replace `N` with the <purple>0-based</purple> chapter index.
#### `chapter-list/count`
The number of chapters. That's it, that's the whole vibe.
#### `chapter-list/N/title`
The chapter title exactly as it's stored in the file. Not always available, bestie โ sometimes it's just not there ๐ญ
#### `chapter-list/N/time`
Chapter start time in seconds, as a float.
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, you get an `mpv_node` that looks like this:
MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP (for each chapter) "title" MPV_FORMAT_STRING "time" MPV_FORMAT_DOUBLE
---
### ๐ `af`, `vf` (RW)
Go look at `--vf`/`--af` and the `vf`/`af` command. That's where the tea is โ
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, you get an `mpv_node` with these 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
And plot twist โ you can also <mint>write</mint> this property using that exact format. Iconic.
---
### โญ `seekable`
Whether it's generally possible to seek in the current file. Simple. Clean. We love her.
---
### ๐ธ `partially-seekable`
Whether the current file is considered seekable, but <yellow>only</yellow> because the cache is active. Basically: small relative seeks might be fine, but bigger seeks might still fail anyway. Whether a seek is actually gonna succeed or not is generally not known in advance โ it's giving mystery, it's giving suspense ๐
If this property returns `yes`/`true`, then `seekable` will too.
---
### ๐
`playback-abort`
Whether playback is stopped, or is about to be stopped. Super useful in obscure situations, like during `on_load` hook processing, when the user can stop playback but the script has to explicitly end processing. Niche but vital, fr fr.
---
### ๐ `cursor-autohide` (RW)
See `--cursor-autohide`. Setting this to a new value will always update the cursor <cyan>and</cyan> reset the internal timer. Two for one, slay.
---
### ๐ง `term-clip-cc`
Inserts the symbol that forces line truncation to the current terminal width. You can use this for `show-text` and other OSD messages. It <red>must</red> be the first character in the line, and it takes effect until the end of the line. Periodt.
---
### ๐ `osd-sym-cc`
Inserts the current OSD symbol as an opaque OSD control code (cc). This only makes sense with the `show-text` command, or with options that set OSD messages. Heads up though โ the control code is implementation specific and is useless for anything else. Don't try to get creative with it ๐
---
### โจ `osd-ass-cc`
`${osd-ass-cc/0}` disables escaping ASS sequences of text in the OSD, and `${osd-ass-cc/1}` enables it again. By default, ASS sequences get escaped to avoid accidental formatting, and this property is how you turn that behavior off. Lowkey important: the properties return an opaque OSD control code, which only makes sense for the `show-text` command or options which set OSD messages.
#### Example
- `--osd-msg3='This is ${osd-ass-cc/0}{\b1}bold text'`
- `show-text "This is ${osd-ass-cc/0}{\b1}bold text"`
Any ASS override tags as understood by libass can be used ๐ฅ
> Not me forgetting this part: you <red>need</red> to escape the `\` character, because the string is processed for C escape sequences <bold>before</bold> it gets passed to the OSD code. See Flat command syntax for details.
A list of tags can be found here: <https://aegisub.org/docs/latest/ass_tags/>
---
### ๐ฆ `vo-configured`
Whether the VO is configured right now. Usually this corresponds to whether the video window is visible. If the `--force-window` option is used, this usually always returns `yes`/`true`. No thoughts, just window ๐
---
### ๐ `vo-passes`
Contains introspection about the VO's active render passes and their execution times. Not implemented by all VOs, so don't come for her if it's missing ๐ญ
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 <yellow>can change from frame to frame</yellow>, and should not be relied upon. Fr fr, do not build your whole life on it.
Each frame type has a number of further sub-properties. Replace `TYPE` with the frame type, `N` with the <purple>0-based</purple> pass index, and `M` with the <purple>0-based</purple> sample index.
#### `vo-passes/TYPE/count`
Number of passes.
#### `vo-passes/TYPE/N/desc`
Human-friendy description of the pass.
#### `vo-passes/TYPE/N/last`
Last measured execution time, in nanoseconds.
#### `vo-passes/TYPE/N/avg`
Average execution time of this pass, in nanoseconds. The exact timeframe varies, but it should generally be a handful of seconds.
#### `vo-passes/TYPE/N/peak`
The peak execution time (highest value) within this averaging range, in nanoseconds.
#### `vo-passes/TYPE/N/count`
The number of samples for this pass.
#### `vo-passes/TYPE/N/samples/M`
The raw execution time of a specific sample for this pass, in nanoseconds.
When you query this property with the client API using `MPV_FORMAT_NODE`, or with Lua `mp.get_property_native`, you get an `mpv_node` with these 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
> Real talk: directly accessing this structure via subkeys is <red>not supported</red>. The only access is through the aforementioned `MPV_FORMAT_NODE`. That's the only door, bestie ๐ช
---
### ๐ `perf-info`
Further performance data. Plot twist though โ querying this property <red>triggers internal collection of some data, and may slow down the player</red> ๐ญ Each query will reset some internal state. And property change notification doesn't and won't work. All of this may change in the future, so likeโฆ <bold>don't use this</bold>. The builtin `stats` script is supposed to be the only user; since it's bundled and built with the source code, it can use knowledge of mpv internal to render the information properly. See the `stats` script description for some details. iykyk ๐ซถ
### <rainbow>**`video-bitrate`**, **`audio-bitrate`**, **`sub-bitrate`**</rainbow>
Okay so these three are the bitrate besties ๐ They're calculated at the <pink>packet level</pink> โ literally, it works by dividing the bit size of all packets between two keyframes by their presentation timestamp distance. (And yes, it uses the timestamps stored in the file, so like, playback speed does <pink>not</pink> influence the returned values. slay.) Heads up though: the video bitrate will update <purple>only per keyframe</purple>, and it shows you the *"past"* bitrate, not the now-now. And to make the property more UI friendly, updates to these properties are throttled in a certain way. โจ
The unit is <yellow>bits per second</yellow>. OSD formatting turns these values into kilobits (or megabits, if that's the vibe), which you can prevent by using the raw property value, e.g. with `${=video-bitrate}`.
> Accuracy check ๐ซถ 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. And if timestamps are bad or jittery (like in Matroska), even constant bitrate streams might show fluctuating bitrate. it's giving timestamp chaos ngl.
How exactly these values are calculated might change in the future. Also, in earlier versions of mpv, these properties returned a static (but bad) guess using a completely different method ๐ so if you're on ancient mpv, that's why it's weird.
---
### <purple>**`audio-device-list`**</purple>
The list of discovered audio devices ๐ง This is mostly for use with the client API, and it 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 <mint>`auto`</mint> 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.)
---
### <purple>**`audio-device`** (RW)</purple>
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 <hotpink>not</hotpink> 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`.)
Also, this property doesn't tell you which audio device is *actually* in use. it's giving mystery ๐ป
How these details are handled may change in the future.
---
### <cyan>**`current-vo`**</cyan>
Current video output driver (name as used with `--vo`).
### <cyan>**`current-gpu-context`**</cyan>
Current GPU context of video output driver (name as used with `--gpu-context`). Valid for `--vo=gpu` and `--vo=gpu-next`.
### <cyan>**`current-ao`**</cyan>
Current audio output driver (name as used with `--ao`).
---
### <rainbow>**`user-data`** (RW)</rainbow>
This is a recursive key/value map of arbitrary nodes shared between clients for general use (i.e. scripts, IPC clients, host applications, etc). The player itself does <pink>not</pink> use any data in it (although some builtin scripts may). The property is <red>not preserved</red> across player restarts. ๐
Sub-paths can be accessed directly; e.g. `user-data/my-script/state/a` can be read, written, or observed.
The top-level object itself <hotpink>cannot be written directly</hotpink>; write to sub-paths instead.
Converting this property or its sub-properties to strings will give a JSON representation. If converting a leaf-level object (i.e. not a map or array) and not using raw mode, the underlying content will be given (e.g. strings will be printed directly, rather than quoted and JSON-escaped).
The following sub-paths are reserved for internal uses or have special semantics: `user-data/osc`, `user-data/mpv`. Unless noted otherwise, the semantics of any properties under these sub-paths can change at any time and may not be relied upon, and writing to these properties may prevent builtin scripts from working properly. โ ๏ธ
Currently, the following properties have defined special semantics:
- **`user-data/osc/margins`** โ This property is written by an OSC implementation to indicate the margins that it occupies. Its sub-properties `l`, `r`, `t`, and `b` should all be set to the left, right, top, and bottom margins respectively. Values are between <yellow>`0.0`</yellow> and <yellow>`1.0`</yellow>, normalized to window width/height.
- **`user-data/mpv/ytdl`** โ Data shared by the builtin ytdl hook script.
- **`user-data/mpv/ytdl/path`** โ Path to the ytdl executable, if found, or an empty string otherwise. The property is not set until the script attempts to find the ytdl executable, i.e. until an URL is being loaded by the script.
- **`user-data/mpv/ytdl/json-subprocess-result`** โ Result of executing ytdl to retrieve the JSON data of the URL being loaded. The format is the same as subprocess's result, capturing `stdout` and `stderr`.
- **`user-data/mpv/console/open`** โ Whether the console is open.
---
### <purple>**`menu-data`** (RW)</purple>
This property stores the raw menu definition. See <cyan>Context Menu</cyan> section for details.
- **`type`** โ Menu item type. Can be: `separator`, `submenu`, or empty.
- **`title`** โ Menu item title. Required if `type` is not `separator`.
- **`cmd`** โ Command to execute when the menu item is clicked.
- **`shortcut`** โ Menu item shortcut key which appears to the right of the menu item. A shortcut key does not have to be functional; it's just a visual hint. ๐
- **`state`** โ Menu item state. Can be: `checked`, `disabled`, `hidden`, or empty.
- **`submenu`** โ Submenu items, which is required if `type` is `submenu`.
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 (menu item) "type" MPV_FORMAT_STRING "title" MPV_FORMAT_STRING "cmd" MPV_FORMAT_STRING "shortcut" MPV_FORMAT_STRING "state" MPV_FORMAT_NODE_ARRAY[MPV_FORMAT_STRING] "submenu" MPV_FORMAT_NODE_ARRAY[menu item]
Writing to this property with the client API using `MPV_FORMAT_NODE` or with Lua `mp.set_property_native` will trigger an <hotpink>immediate update</hotpink> of the menu if mpv video output is currently active. You may observe the `current-vo` property to check if this is the case. ๐
---
### <cyan>**`working-directory`**</cyan>
The working directory of the mpv process. Can be useful for JSON IPC users, because the command line player usually works with relative paths.
### <cyan>**`current-watch-later-dir`**</cyan>
The directory in which watch later config files are stored. This returns `--watch-later-dir`, or the default directory if `--watch-later-dir` has not been modified, with tilde placeholders expanded.
### <cyan>**`protocol-list`**</cyan>
List of protocol prefixes potentially recognized by the player. They are returned without trailing `://` suffix (which is still always required). In some cases, the protocol will not actually be supported (consider `https` if ffmpeg is not compiled with TLS support). ๐ฆ
---
### <purple>**`decoder-list`**</purple>
List of decoders supported. This lists decoders which can be passed to `--vd` and `--ad`.
- **`codec`** โ Canonical codec name, which identifies the format the decoder can handle.
- **`driver`** โ The name of the decoder itself. Often, this is the same as `codec`. Sometimes it can be different. It is used to distinguish multiple decoders for the same codec.
- **`description`** โ Human readable description of the decoder and codec.
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
---
### <purple>**`encoder-list`**</purple>
List of libavcodec encoders. This has the same format as `decoder-list`. The encoder names (`driver` entries) can be passed to `--ovc` and `--oac` (without the `lavc:` prefix required by `--vd` and `--ad`). โจ
### <cyan>**`demuxer-lavf-list`**</cyan>
List of available libavformat demuxers' names. This can be used to check for support for a specific format or use with `--demuxer-lavf-format`.
### <cyan>**`input-key-list`**</cyan>
List of <cyan>Key</cyan> names, same as output by `--input-keylist`.
---
### <cyan>**`mpv-version`**</cyan>
The mpv version/copyright string. Depending on how the binary was built, it might contain either a release version, or just a git hash. ๐
### <cyan>**`mpv-configuration`**</cyan>
The configuration arguments that were passed to the build system. If the meson version used to compile mpv is older than `1.1.0`, then a hardcoded string of a few, arbitrary options is displayed instead.
### <cyan>**`ffmpeg-version`**</cyan>
The contents of the `av_version_info()` API call. This is a string which identifies the build in some way, either through a release version number, or a git hash. This property is <red>unavailable</red> if mpv is linked against older FFmpeg versions. ๐ญ
### `libass-version`
The value of `ass_library_version()`. It's an integer, encoded in a <purple>kinda weird form</purple> (apparently <rainbow>"hex BCD"</rainbow> ๐), and it tells you the release version of the libass library that's linked to mpv. So basically libass's little birth certificate fr.
### `platform`
Returns a string describing what target platform mpv was built for. What you actually get depends on whatever the underlying build system managed to detect. Some of the most common values are: `windows`, `darwin` (that's macos *or* ios bestie), `linux`, `android`, and `freebsd`. But heads up โ this is **not** a complete listing, so don't come for me if yours isn't here ๐.
### `options/<name>` (RW)
The value of option `--<name>`. Most options can be changed at runtime by writing to this property โจ. But note that many options need the file to be **reloaded** for changes to actually kick in. And if there's an equivalent property, prefer setting *that* property instead, okay? ๐
There shouldn't really be any reason to touch `options/<name>` instead of just `<name>`, except in situations where the properties have different behavior or conflicting semantics. So like... edge cases only, iykyk.
### `file-local-options/<name>` (RW)
Similar to `options/<name>`, except when you set an option through *this* property, the option gets reset back to its old value once the current file stops playing. And trying to write an option while no file is playing (or is being loaded) results in an <red>error</red>. Not me getting yelled at by mpv ๐ญ.
(Note that if an option is marked as file-local, even `options/` will access the local value, and the old value โ the one that gets restored on end of playback โ cannot be read or written until end of playback. She's locked in fr fr.)
### `option-info/<name>`
Extra per-option info, bestie. This one has a bunch of sub-properties. Replace `<name>` with the name of a top-level option. And no guarantee of stability for any of these sub-properties โ they may change radically in the future ๐.
- **`option-info/<name>/name`** โ the name of the option.
- **`option-info/<name>/type`** โ the name of the option type, like `String` or `Integer`. For many complex types this isn't very accurate though, she's approximating.
- **`option-info/<name>/set-from-commandline`** โ whether the option was set from the mpv command line. What this is set to if the option is, like, changed at runtime is left undefined (meaning it could change in the future). Vibes are unspecified ๐.
- **`option-info/<name>/set-locally`** โ whether the option was set per-file. This happens with automatically loaded profiles, file-dir configs, and other cases. It means the option value will be restored to the value before playback start when playback ends.
- **`option-info/<name>/expects-file`** โ whether the option takes file paths as arguments.
- **`option-info/<name>/default-value`** โ the default value of the option. May not always be available.
- **`option-info/<name>/min`, `option-info/<name>/max`** โ integer minimum and maximum values allowed for the option. Only available if the options are numeric, and the minimum/maximum has been set internally. It's also possible that only *one* of these is set. Asymmetric, iconic.
- **`option-info/<name>/choices`** โ if the option is a choice option, the possible choices. Choices that are integers may or may not be included (they can be implied by `min` and `max`). Note that options which behave like choice options but aren't *actual* choice options internally may not have this info available. So close yet so far ๐ซถ.
### `property-list`
The list of top-level properties. That's it, that's the whole thing โจ.
### `profile-list`
The list of profiles and their contents. This is **highly** implementation-specific and may change any time. Currently, it returns an array of options for each profile. Each option has a name and a value, with the value currently always being a string. Note that the options array is **not** a map, because order matters and duplicate entries are possible. Recursive profiles are not expanded, and show up as special profile options.
The `profile-restore` field is currently missing if it holds the default value (either because it was not set, or set explicitly to `default`), but in the future it might hold the value `default`. So like... watch this space ๐.
### `command-list`
The list of input commands. This returns an array of maps, where each map node represents a command. This map has the following entries:
- **`name`** โ the name of the command.
- **`vararg`** โ whether the command accepts a variable number of arguments.
- **`args`** โ an array of maps, where each map node represents an argument with the following entries:
- **`name`** โ the name of the argument.
- **`type`** โ the name of the argument type, like `String` or `Integer`.
- **`optional`** โ whether the argument is optional.
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 command entry) "name" MPV_FORMAT_STRING "vararg" MPV_FORMAT_FLAG "args" MPV_FORMAT_NODE_ARRAY MPV_FORMAT_NODE_MAP "name" MPV_FORMAT_STRING "type" MPV_FORMAT_STRING "optional" MPV_FORMAT_FLAG
### `input-bindings`
The list of current input key bindings. Returns an array of maps, where each map node represents a binding for a single key/command. This map has the following entries:
- **`key`** โ the key name. This is normalized and may look slightly different from how it was specified in the source (e.g. in `input.conf`).
- **`cmd`** โ the command mapped to the key. (Currently, this is exactly the same string as specified in the source, other than stripping whitespace and comments. It's possible that it will be normalized in the future.)
- **`is_weak`** โ if set to true, any existing and active user bindings will take priority.
- **`owner`** โ if this entry exists, the name of the script (or similar) which added this binding.
- **`section`** โ name of the section this binding is part of. This is a rarely used mechanism. This entry may be removed or change meaning in the future.
- **`priority`** โ a number. Bindings with a higher value are preferred over bindings with a lower value. If the value is negative, this binding is **inactive** and will not be triggered by input. Note that mpv does not use this value internally, and matching of bindings may work slightly differently in some cases. In addition, this value is dynamic and can change around at runtime. Chaotic queen behavior honestly.
- **`comment`** โ if available, the comment following the command on the same line. (For example, the `input.conf` entry `f cycle bla # toggle bla` would result in an entry with `comment = "toggle bla"`, `cmd = "cycle bla"`.)
This property is <hotpink>read-only</hotpink>, and change notification is **not** supported. Sorry bestie, she doesn't do updates ๐
.
### `clipboard`
The clipboard contents. Only works when native clipboard is supported on the platform. Depending on the platform, some sub-properties, writing to properties, or change notifications are not currently functional. So results may vary, lowkey.
This has a number of sub-properties:
- **`clipboard/text` (RW)** โ the text content in the clipboard. Writing to this property sets the text clipboard content.
- **`clipboard/text-primary` (RW)** โ the text content in the primary selection (X11 and Wayland only).
> **Note:** On Wayland with the `vo` clipboard backend, the clipboard content is only updated when the compositor sends a selection data offer (typically when the VO window is focused). The wayland backend typically does **not** have this limitation. See `current-clipboard-backend` property for more details.
### `current-clipboard-backend`
A string containing the currently active clipboard backend. See `--clipboard-backends` option for the list of available backends.
### `clock`
The current local time in `hour:minutes` format. Adorable, she tells the time ๐.
---
## โ ๏ธ Inconsistencies between options and properties โ ๏ธ
You can access (almost) all options as properties, though there are some caveats with some properties (due to historical reasons). Yes it's messy, no we don't talk about it ๐.
### `vid`, `aid`, `sid`
While playback is active, these return 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`. Rude but honest ๐.
Before mpv 0.31.0, you could set existing tracks at runtime only.
### `display-fps`
This inconsistent behavior is <red>deprecated</red>. Post-deprecation, the reported value and the option value are cleanly separated (`override-display-fps` for the option value). Growth and healing โจ.
### `vf`, `af`
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. So you get the worst of both worlds, slay ๐ญ.
This behavior changed in mpv 0.31.0. Before this, the new value was rejected *iff* a video (for `vf`) or an audio (for `af`) track was active. If playback was not active, the behavior was the same as the current one.
### `playlist`
The property is <hotpink>read-only</hotpink> and returns the current internal playlist. The option is for loading a playlist during command line parsing. For client API uses, you should use the `loadlist` command instead. Pick the right tool bestie, iykyk.
### `profile`, `include`
These are **write-only**, and will perform actions as they are written to, exactly as if they were used on the mpv CLI commandline. Their only use is when using libmpv before `mpv_initialize()`, which in turn is probably only useful in encoding mode. Normal libmpv users should use other mechanisms, such as the `apply-profile` command, and the `mpv_load_config_file` API function. Avoid these properties. Like, genuinely avoid them ๐.
### โจ Property Expansion โจ
Okay bestie, this is the glow-up that makes mpv actually *talk back* to you. ๐ Every string argument you hand to input commands โ plus a few specific options (like `--term-playing-msg`) โ gets run through **property expansion**. It's literally substitution, but make it fashion. โจ
> Lowkey important: property expansion does **not** work in places where, like, numeric parameters are expected. For example, the `add` command does *not* do property expansion. The `set` command is the exception, not a general rule. Don't @ me. ๐
Here's the vibe, an example for `input.conf`:
i show-text "Filename: ${filename}"
...and boom, that shows the filename of the current file when you press the `i` key. ๐
Whether property expansion is on by default depends on which API you're using (peep *Flat command syntax*, *Commands specified as arrays* and *Named arguments*), but you can **always** force it on with the `expand-properties` prefix, or off with the `raw` prefix โ all explained over in *Input Command Prefixes*. ๐
The following expansions are supported:
- **`${NAME}`** โ expands to the value of the property `NAME`. If getting that property fails, it expands to an error string. (Want an empty string instead? Use `${NAME:}` with a trailing `:`.) If `NAME` is prefixed with `=`, it expands to the **raw** value of the property โ see the next section for that whole deal. ๐
- **`${NAME:STR}`** โ expands to the value of the property `NAME`, or `STR` if the property can't be retrieved. `STR` itself gets expanded recursively, so it's turtles all the way down. ๐ข
- **`${?NAME:STR}`** โ expands to `STR` (recursively) if the property `NAME` is available.
- **`${!NAME:STR}`** โ expands to `STR` (recursively) if the property `NAME` **cannot** be retrieved.
- **`${?NAME==VALUE:STR}`** โ expands to `STR` (recursively) if the property `NAME` expands to a string equal to `VALUE`. You can prefix `NAME` with `=` to compare the raw value of the property (again, see below). If the property is unavailable, or other errors pop off while retrieving it, the value is *never* considered equal. Heads up: `VALUE` can't contain any of the characters `:` or `}`. Also, escaping with `"` or `%` might get added in the future if the need arises. ๐ฎ
- **`${!NAME==VALUE:STR}`** โ same as the `?` variant, except `STR` is expanded if the value is **not** equal. (Same semantics as with `?`.) ๐ฆ
- **`$$`** โ expands to `$`.
- **`$}`** โ expands to `}`. (You use this to produce that character inside recursive expansion.)
- **`$>`** โ disables property expansion *and* special handling of `$` for the rest of the string. Bye bestie. ๐
Wherever property expansion is allowed, C-style escapes are often accepted too. Like:
- `\n` becomes a newline character
- `\\` expands to `\`
---
### ๐ธ Raw and Formatted Properties ๐ธ
So normally, properties come formatted as human-readable text โ the kind of thing you'd show on the OSD or in the terminal. But you can pull an **unformatted (raw)** value out of a property by prefixing its name with `=`. These raw values are parseable by other programs and follow the exact same conventions as the options associated with the properties. ๐ง
There's also a `>` prefix that formats human-readable text with **fixed precision** for floating-point values โ super useful when you're printing stuff where a constant width actually matters. Periodt.
Examples, let's go:
- `${time-pos}` expands to `00:14:23` (if the playback position is at 14 minutes 23 seconds)
- `${=time-pos}` expands to `863.4` (same time, plus 400 milliseconds โ milliseconds normally aren't shown in the formatted case)
- `${avsync}` expands to `+0.003`
- `${>avsync}` expands to `+0.0030`
- `${=avsync}` expands to `0.003028`
Sometimes the difference in how much info is carried by raw vs formatted values is, like, *a lot*. In some cases raw values carry more โ like higher precision than seconds with `time-pos`. And sometimes it's the other way around: `aid` shows track title and language in the formatted case, but only the track number when it's raw. It's giving โจsituationship with your dataโจ, fr fr.
---
# ๐ ON SCREEN CONTROLLER ๐
The On Screen Controller (short: **OSC**) is a minimal GUI baked right into mpv to give you basic mouse-controllability. It's made to make interaction easier for new users and to enable precise and direct seeking. Main character energy for your mouse, honestly. ๐ฑ๏ธโจ
The OSC is **enabled by default** if mpv was compiled with Lua support. And you can disable it entirely with the `--osc=no` option. ๐
## ๐ฆ Using the OSC ๐ฆ
By default, the OSC pops up whenever the mouse is moved inside the player window, and it hides if the mouse isn't moved outside the OSC for **0.5 seconds**, or if the mouse leaves the window. Iconic behaviour, no notes. ๐
## ๐ The Interface ๐
+------+---------+---------+-----------------------------------------------+
| menu | pl prev | pl next | title cache |
+------+------+------+---------+-----------+------+-------+-----+-----+----+
| play | skip | skip | time | seekbar | time | audio | sub | vol | fs |
|---|---|---|---|---|---|---|---|---|---|
| back | frwd | elapsed | left |
+------+------+------+---------+-----------+------+-------+-----+-----+----+
**menu**
- left-click โ open the menu
**pl prev**
- left-click โ play previous file in playlist
- shift+L-click โ show the playlist
- middle-click โ show the playlist
- right-click โ open the playlist menu
**pl next**
- left-click โ play next file in playlist
- shift+L-click โ show the playlist
- middle-click โ show the playlist
- right-click โ open the playlist menu
**title**
Displays the current playlist position and media-title, filename or custom title, or the target chapter name while hovering the seekbar. ๐ซถ
- left-click โ show file and track info
- shift+L-click โ show the path
- middle-click โ show the path
- right-click โ open the history menu
**cache**
Shows current cache fill status. ๐
**play**
- left-click โ toggle play/pause
- shift+L-click โ toggle infinite looping of the playlist
- middle-click โ toggle infinite looping of the playlist
- right-click โ toggle infinite looping of the current file
**skip back**
- left-click โ go to beginning of chapter / previous chapter
- shift+L-click โ show chapters
- middle-click โ show chapters
- right-click โ open the chapter menu
**skip frwd** ๐
- <cyan>left-click</cyan> โ go to next chapter
- <cyan>shift+L-click</cyan> โ show chapters
- <cyan>middle-click</cyan> โ show chapters
- <cyan>right-click</cyan> โ open the chapter menu
**time elapsed** โจ
Shows current playback position timestamp, bestie. That little clock? Iconic.
- <cyan>left-click</cyan> โ toggle displaying timecodes with milliseconds
**seekbar** ๐
Indicates current playback position and position of chapters.
- <cyan>left-click</cyan> โ seek to position
- <cyan>right-click</cyan> โ seek to the nearest chapter
- <cyan>mouse wheel</cyan> โ seek forward/backward
**time left** โณ
Shows remaining playback time timestamp.
- <cyan>left-click</cyan> โ toggle between total and remaining time
**audio and sub** ๐
Displays selected track and amount of available tracks. Very "how many of these even are there" energy.
- <cyan>left-click</cyan> โ cycle audio/sub tracks forward
- <cyan>shift+L-click</cyan> โ cycle audio/sub tracks backwards
- <cyan>middle-click</cyan> โ cycle audio/sub tracks backwards
- <cyan>right-click</cyan> โ open the audio/sub track menu
- <cyan>mouse wheel</cyan> โ cycle audio/sub tracks forward/backwards
**vol** ๐
- <cyan>left-click</cyan> โ toggle mute
- <cyan>right-click</cyan> โ open the audio device menu
- <cyan>mouse wheel</cyan> โ volume up/down
**fs** ๐
- <cyan>left-click</cyan> โ toggle fullscreen
- <cyan>right-click</cyan> โ toggle whether the window is maximized
---
> Since mpv 0.40.0, it is possible to configure the commands to run with mouse actions on some interface elements, and the default behaviors of several elements were changed. If you miss some older behaviors, look at `etc/restore-osc-bindings.conf` in the mpv git repository. ๐ซถ (they really said "here's your nostalgia back")
### ๐ธ Key Bindings ๐ธ
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
### ๐ Configuration ๐
This script can be customized through a config file `script-opts/osc.conf` placed in mpv's user directory and through the `--script-opts` command-line option. The configuration syntax is described in `mp.options` functions.
### ๐ฆ Command-line Syntax ๐ฆ
To avoid collisions with other scripts, all options need to be prefixed with `osc-`.
Example:
--script-opts=osc-optionA=value1,osc-optionB=value2
### โญ Configurable Options โญ
- **`layout`** โ Default: `bottombar`. The layout for the OSC. Currently available are: `box`, `slimbox`, `bottombar`, `topbar`, `slimbottombar` and `slimtopbar`. Default pre-0.21.0 was `'box'`.
- **`seekbarstyle`** โ Default: `bar`. Sets the style of the playback position marker and overall shape of the seekbar: `bar`, `diamond` or `knob`.
- **`seekbarhandlesize`** โ Default: `0.6`. Size ratio of the seek handle if `seekbarstyle` is set to `diamond` or `knob`. This is relative to the full height of the seekbar.
- **`seekbarkeyframes`** โ Default: `yes`. Controls the mode used to seek when dragging the seekbar. If set to `yes`, default seeking mode is used (usually keyframes, but player defaults and heuristics can change it to exact). If set to `no`, 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. ๐ญ
- **`seekrangestyle`** โ 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`. ๐
- **`seekrangeseparate`** โ Default: `yes`. Controls whether to show line-style seekable ranges on top of the seekbar or separately if `seekbarstyle` is set to `bar`.
- **`seekrangealpha`** โ Default: `20`. Alpha of the seekable ranges, `0` (opaque) to `255` (fully transparent).
- **`scrollcontrols`** โ Default: `yes`. By default, going up or down with the mouse wheel can trigger certain actions (such as seeking) if the mouse is hovering an OSC element. Set to `no` to disable any special mouse wheel behavior.
- **`deadzonesize`** โ 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`. ๐
- **`minmousemove`** โ 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`.
- **`showwindowed`** โ Default: `yes`. Enable the OSC when windowed.
- **`showfullscreen`** โ Default: `yes`. Enable the OSC when fullscreen.
- **`idlescreen`** โ Default: `yes`. Show the mpv logo and message when idle. ๐
- **`scalewindowed`** โ Default: `1.0`. Scale factor of the OSC when windowed.
- **`scalefullscreen`** โ Default: `1.0`. Scale factor of the OSC when fullscreen.
- **`vidscale`** โ Default: `auto`.
โฆand the OSC options just keep on coming, bestie, we're so back ๐
- **Scale the OSC with the video.** `no` tries to keep the OSC size constant as much as the window size allows. `auto` scales the OSC with the OSD, which is scaled with the window or kept at a constant size, depending on the `--osd-scale-by-window` option.
- **`valign`** โ Default: `0.8`. Vertical alignment in `box` and `slimbox` layouts, from `-1` (top) to `1` (bottom).
- **`halign`** โ Default: `0.0`. Horizontal alignment in `box` and `slimbox` layouts, from `-1` (left) to `1` (right).
- **`barmargin`** โ Default: `0`. Margin from the bottom (`bottombar`, `slimbottombar`) or the top (`topbar`, `slimtopbar`), in pixels.
- **`boxalpha`** โ Default: `80`. Alpha of the background box, `0` (opaque) to `255` (fully transparent).
- **`hidetimeout`** โ Default: `500`. Duration in ms until the OSC hides if no mouse movement. <red>Must not be negative</red> โ no cap.
- **`fadeduration`** โ Default: `200`. Duration of fade effects in ms, `0` = no fade.
- **`fadein`** โ Default: `no`. Enable fade-in. โจ
- **`title`** โ Default: `${!playlist-count==1:[${playlist-pos-1}/${playlist-count}]}${media-title}`. A string that supports property expansion and gets displayed as the OSC title. ASS tags are escaped and newlines are converted to spaces.
- **`tooltipborder`** โ Default: `1`. Size of the tooltip outline when you're using the `bottombar` or `topbar` layouts.
- **`timetotal`** โ Default: `no`. Show total time instead of time remaining.
- **`remaining_playtime`** โ Default: `yes`. Whether the time-remaining display takes speed into account. `yes` โ how much playback time remains at the current speed. `no` โ how much video-time remains.
- **`timems`** โ Default: `no`. Display timecodes with milliseconds.
- **`tcspace`** โ Default: `100` (allowed: `50`-`200`). Adjust space reserved for timecodes (current time and time remaining) in the `bottombar` and `topbar` layouts. The timecode width depends on the font, and with some fonts the spacing near the timecodes becomes too small. Use values above `100` to increase that spacing, or below `100` to decrease it.
- **`visibility`** โ Default: `auto` (auto hide/show on mouse move). Also supports `never` and `always`.
- **`visibility_modes`** โ Default: `never_auto_always`. The list of visibility modes to cycle through when calling the `osc-visibility cycle` script message. Modes are separated by `_`.
- **`boxmaxchars`** โ 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.
- **`boxvideo`** โ 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.) Additionally, `visibility` must be set to `always`. Otherwise, this option does nothing.
Currently, this is supported for the `bottombar`, `slimbottombar`, `topbar` and `slimtopbar` layouts 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.
> Heads up: this does not work correctly with video outputs like `--vo=xv`, which render OSD into the unscaled video. ๐
- **`windowcontrols`** โ 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.
- **`windowcontrols_alignment`** โ 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.
- **`windowcontrols_title`** โ Default: `${media-title}`. String that supports property expansion that will be displayed as the windowcontrols title. ASS tags are escaped, and newlines and trailing slashes are stripped.
- **`greenandgrumpy`** โ Default: `no`. Set to `yes` to reduce festivity (i.e. disable santa hat in December.) ๐
- **`livemarkers`** โ Default: `yes`. Update chapter markers positions on duration changes, e.g. live streams. The updates are unoptimized โ consider disabling it on very low-end systems.
- **`chapter_fmt`** โ Default: `Chapter: %s`. Template for the chapter-name display when hovering the seekbar. Use `no` to disable chapter display on hover. Otherwise it's a lua `string.format` template and `%s` is replaced with the actual name.
- **`unicodeminus`** โ Default: `no`. Use a Unicode minus sign instead of an ASCII hyphen when displaying the remaining playback time.
- **`background_color`** โ Default: `#000000`. Sets the background color of the OSC.
- **`timecode_color`** โ Default: `#FFFFFF`. Sets the color of the timecode and seekbar, of the OSC.
- **`title_color`** โ Default: `#FFFFFF`. Sets the color of the video title. Formatted as `#RRGGBB`.
- **`time_pos_color`** โ Default: `#FFFFFF`. Sets the color of the timecode at hover position in the seekbar.
- **`time_pos_outline_color`** โ Default: `#FFFFFF`. Sets the color of the timecode's outline at hover position in the seekbar. Also affects the timecode in the `slimbox` layout.
- **`buttons_color`** โ Default: `#FFFFFF`. Sets the colors of the big buttons.
- **`top_buttons_color`** โ Default: `#FFFFFF`. Sets the colors of the top buttons.
- **`small_buttonsL_color`** โ Default: `#FFFFFF`. Sets the colors of the small buttons on the left in the `box` layout.
- **`small_buttonsR_color`** โ Default: `#FFFFFF`. Sets the colors of the small buttons on the right in the `box` layout.
- **`held_element_color`** โ Default: `#999999`. Sets the colors of the elements that are being pressed or held down.
- **`tick_delay`** โ Default: `1/60`. Sets the minimum interval between OSC redraws in seconds. This can be decreased on fast systems to make OSC rendering smoother.
Ignored if `tick_delay_follow_display_fps` is set to `yes` and the VO supports the `display-fps` property.
- **`tick_delay_follow_display_fps`** โ Default: `no`. Use display fps to calculate the interval between OSC redraws.
---
<purple>The following options configure what commands are run when the buttons are clicked. `mbtn_mid` commands are also triggered with `shift+mbtn_left`.</purple> ๐
- `menu_mbtn_left_command=script-binding select/menu; script-message-to osc osc-hide`
- `menu_mbtn_mid_command=`
- `menu_mbtn_right_command=`
- `playlist_prev_mbtn_left_command=playlist-prev; show-text ${playlist} 3000`
- `playlist_prev_mbtn_mid_command=show-text ${playlist} 3000`
- `playlist_prev_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide`
- `playlist_next_mbtn_left_command=playlist-next; show-text ${playlist} 3000`
- `playlist_next_mbtn_mid_command=show-text ${playlist} 3000`
- `playlist_next_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide`
- `title_mbtn_left_command=script-binding stats/display-page-5`
- `title_mbtn_mid_command=show-text ${path}`
- `title_mbtn_right_command=script-binding select/select-watch-history; script-message-to osc osc-hide`
- `play_pause_mbtn_left_command=cycle pause`
- `play_pause_mbtn_mid_command=cycle-values loop-playlist inf no`
- `play_pause_mbtn_right_command=cycle-values loop-file inf no`
- `chapter_prev_mbtn_left_command=osd-msg add chapter -1`
- `chapter_prev_mbtn_mid_command=show-text ${chapter-list} 3000`
- `chapter_prev_mbtn_right_command=script-binding select/select-chapter; script-message-to osc osc-hide`
- `chapter_next_mbtn_left_command=osd-msg add chapter 1`
- `chapter_next_mbtn_mid_command=show-text ${chapter-list} 3000`
- `chapter_next_mbtn_right_command=script-binding select/select-chapter; script-message-to osc osc-hide`
- `audio_track_mbtn_left_command=cycle audio`
- `audio_track_mbtn_mid_command=cycle audio down`
- `audio_track_mbtn_right_command=script-binding select/select-aid; script-message-to osc osc-hide`
- `audio_track_wheel_down_command=cycle audio`
- `audio_track_wheel_up_command=cycle audio down`
- `sub_track_mbtn_left_command=cycle sub`
- `sub_track_mbtn_mid_command=cycle sub down`
- `sub_track_mbtn_right_command=script-binding select/select-sid; script-message-to osc osc-hide`
- `sub_track_wheel_down_command=cycle sub`
- `sub_track_wheel_up_command=cycle sub down`
- `volume_mbtn_left_command=no-osd cycle mute`
- `volume_mbtn_mid_command=`
- `volume_mbtn_right_command=script-binding select/select-audio-device; script-message-to osc osc-hide`
- `volume_wheel_down_command=add volume -5`
- `volume_wheel_up_command=add volume 5`
- `fullscreen_mbtn_left_command="cycle fullscreen"`
- `fullscreen_mbtn_mid_command=`
- `fullscreen_mbtn_right_command="cycle window-maximized"`
---
### ๐ Custom Buttons ๐
Additional script-opts are available to define custom buttons in `bottombar` and `topbar` layouts. yesss, your OSC, your rules ๐
**Example to add loop, shuffle and speed buttons**
custom_button_1_content=๐ custom_button_1_mbtn_left_command=cycle-values loop-file inf no custom_button_1_mbtn_right_command=cycle-values loop-playlist inf no
custom_button_2_content=๐ custom_button_2_mbtn_left_command=playlist-shuffle
see the pattern? content, then your `mbtn` commands, and it's giving iconic button energy โจ <hotpink>(also: yes, the example title says three buttons and shows two โ that's literally what the page says, I'm not editing it, don't come for me ๐)</hotpink>
custom_button_3_content=โฑ custom_button_3_mbtn_left_command=add speed 1 custom_button_3_mbtn_right_command=set speed 1 custom_button_3_wheel_up_command=add speed 0.25 custom_button_3_wheel_down_command=add speed -0.25
---
## ๐
Script Commands ๐
okay so bestie, the OSC script is *listening* โ it takes certain script commands, and you can bind them in `input.conf`, or other scripts can just send them over. <pink>iconic little message-passing moment</pink> ๐
- **`osc-visibility`** โ controls the visibility mode: `never` / `auto` (on mouse move) / `always`, and also `cycle` to cycle between the modes. If a second argument is passed (any value), then the output on the OSD will be silenced. ๐คซ
- **`osc-show`** โ triggers the OSC to show up, just as if user moved mouse. โจ
- **`osc-hide`** โ Hide the OSC when visibility is `auto`.
### 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
- **`osc-idlescreen`** โ Controls the visibility of the mpv logo on idle. Valid arguments are `yes`, `no`, and `cycle` to toggle between `yes` and `no`. If a second argument is passed (any value), then the output on the OSD will be silenced. ๐
---
# ๐ธ STATS ๐ธ
This builtin script displays information and statistics for the currently played file. <rainbow>the numbers!! the data!!</rainbow> It is enabled by default if mpv was compiled with Lua support. It can be disabled entirely using the `--load-stats-overlay=no` option.
## Usage ๐
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)
- `?` โ Toggle displaying the key bindings
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 (scroll)
- `3` โ Input cache stats
- `4` โ Active key bindings (scroll)
- `5` โ Selected Tracks Info (scroll)
- `0` โ Internal stuff (scroll)
If stats were displayed by toggling, these key bindings are also active:
- `ESC` โ Close the stats
On pages which support scroll, these key bindings are also active:
- `UP` โ Scroll one line up
- `DOWN` โ Scroll one line down
On page 4, these key bindings are also active:
- `/` โ Search key bindings
## Configuration ๐ง
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 `mp.options` functions. ๐
## Configurable Options โจ
- **`key_page_1`** โ Default: `1`
- **`key_page_2`** โ Default: `2`
- **`key_page_3`** โ Default: `3`
- **`key_page_4`** โ Default: `4`
- **`key_page_5`** โ Default: `5`
- **`key_page_0`** โ Default: `0`
- **`key_exit`** โ Default: `ESC`
Key bindings for page switching while stats are displayed.
- **`key_scroll_up`** โ Default: `UP`
- **`key_scroll_down`** โ Default: `DOWN`
- **`key_scroll_search`** โ Default: `/`
- **`scroll_lines`** โ Default: `1`
Scroll key bindings and number of lines to scroll on pages which support it.
- **`duration`** โ Default: `4`
How long the stats are shown in seconds (oneshot).
- **`redraw_delay`** โ Default: `1`
How long it takes to refresh the displayed stats in seconds (toggling).
- **`persistent_overlay`** โ 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.
- **`file_tag_max_length`** โ Default: `128`
Only show file tags shorter than this length, in bytes.
- **`file_tag_max_count`** โ Default: `16`
Only show the first specified amount of file tags.
- **`term_clip`** โ Default: `yes`
Whether to clip lines to the terminal width.
- **`plot_perfdata`** โ Default: `no`
Show graphs for performance data (page 2).
- **`plot_vsync_ratio`** โ Default: `no`
- **`plot_vsync_jitter`** โ Default: `no`
Show graphs for vsync and jitter values (page 1). Only when toggled.
- **`plot_cache`** โ Default: `yes`
Show graphs for cache values (page 3). Only when toggled.
- **`plot_tonemapping_lut`** โ Default: `no`
Enable tone-mapping LUT visualization automatically. Only when toggled.
- **`flush_graph_data`** โ Default: `yes`
Clear data buffers used for drawing graphs when toggling.
- **`font`** โ Default: same as `osd-font`
Font name. Should support as many font weights as possible for optimal visual experience.
- **`font_mono`** โ Default: `monospace`
Font name for parts where monospaced characters are necessary to align text. Currently, monospaced digits are sufficient.
- **`font_size`** โ Default: `20`
Font size used to render text.
- **`font_color`** โ Default: same as `osd-color`
Color of the text.
- **`border_size`** โ Default: `1.65`
Size of border drawn around the font.
- **`border_color`** โ Default: same as `osd-border-color`
Color of the text border.
- **`shadow_x_offset`** โ Default: same as `--osd-shadow-offset`
The horizontal distance from the text to position the shadow at.
- **`shadow_y_offset`** โ Default: same as `--osd-shadow-offset`
The vertical distance from the text to position the shadow at.
- **`shadow_color`** โ Default: same as `osd-shadow-color`
Color of the text shadow.
- **`alpha`** โ Default: `11`
Transparency of text when `font_color` is specified, of text borders when `border_color` is specified, and of text shadows when `shadow_color` is specified.
- **`plot_bg_border_color`** โ Default: `0000FF`
Border color used for drawing graphs.
- **`plot_bg_border_width`** โ Default: `1.25`
Border width used for drawing graphs.
- **`plot_bg_color`** โ Default: `262626`
Background color used for drawing graphs.
- **`plot_color`** โ Default: `FFFFFF`
Color used for drawing graphs.
- **`vidscale`** โ Default: `auto`
Scale the text and graphs with the video. `no` tries to keep the sizes constant. `auto` scales the text and graphs with the OSD, which is scaled with the window or kept at a constant size, depending on the `--osd-scale-by-window` option.
> Note: colors are given as hexadecimal values and use ASS tag order: `BBGGRR` (blue green red). <peach>yes bestie that's backwards from what you'd expect, it's giving BGR, write it down ๐</peach>
## Different key bindings ๐
Additional keys can be configured in `input.conf` to display the stats:
e script-binding stats/display-stats E script-binding stats/display-stats-toggle
And to display a certain page directly:
i script-binding stats/display-page-1 h script-binding stats/display-page-4-toggle
## Active key bindings page ๐ฅ
Lists the active key bindings and the commands they're bound to, excluding the interactive keys of the stats script itself. See also `--input-test` for more detailed view of each binding. ๐
The keys are grouped automatically using a simple analysis of the command string, and one should not expect documentation-level grouping accuracy, however, it should still be reasonably useful. <lavender>fr fr it's vibes-based grouping, but it works</lavender>
Using `--idle --script-opt=stats-bindlist=yes` will print the list to the terminal and quit immediately. Long lines are clipped to the terminal width unless this is disabled with `--script-opt=stats-term_clip=no`. Escape sequences can be disabled by adding `-` before `yes`, i.e. `--script-opt=stats-bindlist=-yes`.
Like with `--input-test`, the list includes bindings from `input.conf` and from user scripts. Use `--no-config` to list only built-in bindings.
## Internal stuff page ๐
Most entries shown on this page have rather vague meaning. Likely none of this is useful for you. Don't attempt to use it. Forget its existence. <red>not even joking bestie, forget it. it was never here. ๐</red>
So the very first time you select this, it starts collecting some internal performance data โ which means <yellow>performance will be a tiny bit lower than normal for the rest of the time the player is running</yellow>, <pink>even if you close the stats page</pink>. And heads up: the stats page itself is a whole CPU *and* even GPU snack, so it can have a <red>heavy impact on performance</red>. ๐
Everything displayed is accumulated over the redraw delay (that's the `poll-time` field, bestie, iykyk).
This adds entries for each Lua script. Run too many scripts and parts of the list just fall right off the screen โ but it can be scrolled, so we recover. ๐ซถ
If the underlying platform doesn't support pthread per thread times, the displayed times will be `0` or something random (the author suspects that at the time of writing, only Linux provides the correct per-thread times via pthread APIs). ๐
Most entries get added lazily and only during data collection, which is why entries may just pop up randomly after some time. It's also why the memory usage entries for scripts that have been inactive since the start of data collection are missing. ๐
Memory usage is approximate and does not reflect internal fragmentation. That's just how it is.
JS scripts memory reporting is disabled by default, because collecting the data at the JS side has an overhead and will increase memory usage. Want it? Set the `--js-memory-report` option **before** starting mpv. โจ
If entries have `/time` and `/cpu` variants: the former gives the real time (monotonic clock), while the latter gives the thread CPU time (only if the corresponding pthread API works and is supported).
---
# ๐ CONSOLE ๐
This script gives you the ability to process the user's textual input to other scripts through the `mp.input` API. It can be displayed on both the video window and the terminal, your choice bestie. It can be disabled entirely using the `--load-console=no` option.
Console can either process free-form text or select from a predefined list of items.
## Free-form text mode keybindings
- **`ESC`** and **`Ctrl+[`** โ Hide the console.
- **`ENTER`**, **`Ctrl+j`** and **`Ctrl+m`** โ Select the first completion if one wasn't already manually selected, and run the typed command.
- **`Shift+ENTER`** โ Type a literal newline character.
- **`LEFT`** and **`Ctrl+b`** โ Move the cursor to the previous character.
- **`RIGHT`** and **`Ctrl+f`** โ Move the cursor to the next character.
- **`Ctrl+LEFT`** and **`Alt+b`** โ Move the cursor to the beginning of the current word, or if between words, to the beginning of the previous word.
- **`Ctrl+RIGHT`** and **`Alt+f`** โ Move the cursor to the end of the current word, or if between words, to the end of the next word.
- **`HOME`** and **`Ctrl+a`** โ Move the cursor to the start of the current line.
- **`END`** and **`Ctrl+e`** โ Move the cursor to the end of the current line.
- **`BACKSPACE`** and **`Ctrl+h`** โ Delete the previous character.
- **`Ctrl+d`** โ Hide the console if the current line is empty, otherwise delete the next character.
- **`Ctrl+BACKSPACE`** and **`Ctrl+w`** โ Delete text from the cursor to the beginning of the current word, or if between words, to the beginning of the previous word.
- **`Ctrl+DEL`** and **`Alt+d`** โ Delete text from the cursor to the end of the current word, or if between words, to the end of the next word.
- **`Ctrl+u`** โ Delete text from the cursor to the beginning of the current line.
- **`Ctrl+k`** โ Delete text from the cursor to the end of the current line.
- **`Ctrl+c`** โ Clear the current line.
- **`UP`** and **`Ctrl+p`** โ Move back in the command history.
- **`DOWN`** and **`Ctrl+n`** โ Move forward in the command history.
- **`PGUP`** โ Go to the first command in the history.
- **`PGDN`** โ Stop navigating the command history.
- **`Ctrl+r`** โ Search the command history. See `SELECT` for the key bindings in this mode.
- **`INSERT`** โ Toggle insert mode.
- **`Ctrl+v`** โ Paste text (uses the clipboard on X11 and Wayland).
- **`Shift+INSERT`** โ Paste text (uses the primary selection on X11 and Wayland).
- **`Ctrl+y`** โ Copy the current line to the clipboard.
- **`TAB`** and **`Ctrl+i`** โ Cycle through completions.
- **`Shift+TAB`** โ Cycle through the completions backwards.
- **`Ctrl+l`** โ Clear all log messages from the console.
- **`MBTN_MID`** โ Paste text (uses the primary selection on X11 and Wayland).
- **`WHEEL_UP`** โ Move back in the command history.
- **`WHEEL_DOWN`** โ Move forward in the command history.
## Known issues
- Non-ASCII keyboard input has restrictions ๐ญ
- The cursor keys move between Unicode code-points, not grapheme clusters
## Configuration
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 `mp.options` functions.
## Configurable Options
- **`monospace_font`** โ Default: platform dependent
The monospace font used when there are completions to align in a grid.
When there are no completions, `--osd-font` is used.
- **`font_size`** โ Default: `24`
The font size. This will be multiplied by `display-hidpi-scale` when the console is not scaled with the window.
- **`border_size`** โ Default: `1.65`
The font border size.
- **`background_alpha`** โ Default: `80`
The transparency of the menu's background. Ranges from `0` (opaque) to `255` (fully transparent).
- **`gap`** โ Default: `0.2`
The gap between menu items, specified as a percentage the font size.
- **`padding`** โ Default: `10`
The padding of the menu.
- **`menu_outline_size`** โ Default: `0`
The size of the menu's border.
- **`menu_outline_color`** โ Default: `#FFFFFF`
The color of the menu's border.
- **`corner_radius`** โ Default: `8`
The radius of the menu's corners.
- **`margin_x`** โ Default: same as `--osd-margin-x`
The margin from the left of the window.
- **`margin_y`** โ Default: same as `--osd-margin-y`
The margin from the bottom of the window.
- **`scale_with_window`** โ Default: `auto`
Whether to scale the console with the window height. Can be `yes`, `no`, or `auto`, which follows the value of `--osd-scale-by-window`.
- **`focused_color`** โ Default: `#222222`
The color of the focused item.
- **`focused_back_color`** โ Default: `#FFFFFF`
The background color of the focused item.
- **`match_color`** โ Default: `#0088FF`
The color of characters that match the searched string.
- **`exact_match`** โ Default: `no`
Whether to match menu search queries exactly instead of fuzzily. Without this option, prefixing queries with `'` enables exact matching.
- **`case_sensitive`** โ Default: `no`
Whether exact searches are case sensitive. Only works with ASCII characters.
- **`history_dedup`** โ Default: `true`
Remove duplicate entries in history as to only keep the latest one.
- **`font_hw_ratio`** โ Default: `auto`
The ratio of font height to font width. Adjusts grid width of completions. Values in the range `1.8..2.5` make sense for common monospace fonts.
---
# ๐ COMMANDS ๐
This script allows running and completing input commands in the console interactively, and also adds mpv's log to the console's log. Two jobs, both iconic.
## Keybindings
- **`` ` ``** โ Open the console to enter commands.
## Commands
- **`script-binding commands/open`** โ Open the console to enter commands.
- **`script-message-to commands type <text> [<cursor_pos>]`** โ Show the console and pre-fill it with the provided text, optionally specifying the initial cursor position as a positive integer starting from `1`. The console is automatically closed after running the command.
Examples for input.conf
% script-message-to commands type "seek absolute-percent" 6 Ctrl+o script-message-to console type "loadfile ''" 11
- The first one: enter a percent position to seek to.
- The second one: enter a file or URL to play, with autocompletion of paths in the filesystem.
## Configuration
This script can be customized through a config file `script-opts/commands.conf` placed in mpv's user directory and through the `--script-opts` command-line option. The configuration syntax is described in `mp.options` functions.
## Configurable Options
- **`persist_history`** โ Default: `no`
Whether to save the command history to a file and load it.
- **`history_path`** โ Default: `~~state/command_history.txt`
The file path for `persist_history` (see FILES).
- **`remember_input`** โ Default: `yes`
Whether to remember the input line and cursor position when closing the console, and prefill it the next time it is opened.
# ๐ SELECT ๐
okay bestie so the console can literally hand you a whole list of items to browse and pick from, using the `mp.input.select` API โจ. And `select.lua`? It's a builtin client of that API, and what it does is provide script bindings that gather + format the data you're gonna select in the console, then do stuff to the item you picked ๐
. Wanna turn it off? Just use `--load-select=no`, easy.
---
## Key bindings
When you're using `mp.input.select`, the key bindings from **CONSOLE** get *extended* with these cuties:
- **`ENTER`**, **`Ctrl+j`** and **`Ctrl+m`** โ Select the focused item. ๐
- **`UP`** and **`Ctrl+p`** โ Focus the item above, or the last one when the first item is selected.
- **`DOWN`** and **`Ctrl+n`** โ Focus the item below, or the first one when the last item is selected.
- **`PGUP`** and **`Ctrl+b`** โ Scroll up one page.
- **`PGDN`** and **`Ctrl+f`** โ Scroll down one page.
- **`Ctrl+y`** โ Copy the focused item to the clipboard. ๐
- **`MBTN_LEFT`** โ Select the item under the cursor, or close the console if you're clicking outside of the menu rectangle.
- **`WHEEL_UP`** โ Scroll up.
- **`WHEEL_DOWN`** โ Scroll down.
Typing printable characters does a fuzzy search of the items being presented to you ๐ฆ.
And if your query starts with `'`, only exact matches get filtered. You can also throw down multiple search terms delimited by spaces, and only items matching *all* the terms get filtered. periodt.
---
## Script bindings
By default, `select.lua`'s script bindings are bound to key sequences starting with `g`, listed in **Keyboard Control**. But the names of the script bindings below can be used to bind them to *different* keys, so go wild.
> Example to rebind playlist selection in `input.conf`
Ctrl+p script-binding select/select-playlist
Available script bindings are:
- **`select-playlist`** โ Select a playlist entry. `--osd-playlist-entry` determines how playlist entries are formatted.
- **`select-sid`** โ Select a subtitle track, or disable the current one.
- **`select-secondary-sid`** โ Select a secondary subtitle track, or disable the current one.
- **`select-aid`** โ Select an audio track, or disable the current one.
- **`select-vid`** โ Select a video track, or disable the current one.
- **`select-track`** โ Select a track of any type, or disable a selected track.
- **`select-chapter`** โ Select a chapter.
- **`select-edition`** โ Select an MKV edition or DVD/Blu-ray title.
- **`select-subtitle-line`** โ Select a subtitle line to seek to. Heads up: this doesn't work with image subtitles. ๐ญ
Also, this currently requires `ffmpeg` in `PATH`, or in the same folder as `mpv` on Windows.
- **`select-audio-device`** โ Select an audio device.
- **`select-watch-history`** โ Select a file from the watch history. Requires `--save-watch-history`.
If you don't already use `--autocreate-playlist`, it is recommended to enable it with this script binding to populate the playlist with the other files in the entry's directory.
> Example for `input.conf` to play files adjacent to the history entry
g-h script-binding select/select-watch-history; no-osd set autocreate-playlist filter
- **`select-watch-later`** โ Select a file from watch later config files (see **RESUMING PLAYBACK**) to resume playing. Requires `--write-filename-in-watch-later-config`. And nope, this doesn't work with `--ignore-path-in-watch-later-config`.
If you don't already use `--autocreate-playlist`, it is recommended to enable it with this script binding to populate the playlist with the other files in the entry's directory.
> Example for `input.conf` to play files adjacent to the watch later entry
g-w script-binding select/select-watch-later; no-osd set autocreate-playlist filter
- **`select-binding`** โ List the defined input bindings. You can also select one to run the associated command.
- **`show-properties`** โ List the names and values of all properties. You can also select one to print its value on the OSD, which is super useful for long values that get clipped. ๐
- **`edit-config-file`** โ Open `mpv.conf` in the system text editor, creating it if it doesn't already exist.
- **`edit-input-conf`** โ Open `input.conf` in the system text editor, creating it if it doesn't already exist.
- **`open-docs`** โ Open mpv's online documentation in the browser.
- **`menu`** โ Show a menu with miscellaneous entries.
---
## Configuration
This script can be customized through a config file `script-opts/select.conf` placed in mpv's user directory, and through the `--script-opts` command-line option โจ. The configuration syntax is described in **mp.options functions**.
---
## Configurable options
- **`history_date_format`** โ Default: `%Y-%m-%d %H:%M:%S`
The format of dates of history entries. This gets passed to Lua's `os.date`, which uses the same formats as `strftime(3)`.
- **`hide_history_duplicates`** โ Default: `yes`
Whether to show only the last of history entries with the same path.
---
# ๐ CONTEXT MENU SCRIPT ๐
This script gives you a context menu for platforms that don't have integration with a native context menu. On those platforms, you can disable it entirely with `--load-context-menu=no`. And on platforms where the integration *is* implemented, it's already disabled by default. ๐
---
## Script messages
- **`open`** โ Show the context menu.
- **`select`** โ Select the focused item when there is one.
---
## Configuration
This script can be customized through a config file `script-opts/context_menu.conf` placed in mpv's user directory, and through the `--script-opts` command-line option. The configuration syntax is described in **mp.options functions**.
---
## Configurable Options
- **`font_size`** โ Default: `14`
The font size.
- **`gap`** โ Default: `0.2`
The gap between menu items, specified as a percentage of the font size.
- **`padding_x`** โ Default: `8`
The horizontal padding of the menu.
- **`padding_y`** โ Default: `4`
The vertical padding of the menu.
- **`menu_outline_size`** โ Default: `0`
The size of the menu's border.
- **`menu_outline_color`** โ Default: `#FFFFFF`
The color of the menu's border.
- **`corner_radius`** โ Default: `5`
The radius of the menu's corners.
- **`scale_with_window`** โ Default: `auto`
Whether to scale sizes with the window height. Can be `yes`, `no`, or `auto`, which follows the value of `--osd-scale-by-window`.
When sizes aren't scaled with the window, they are scaled by `display-hidpi-scale`.
- **`focused_color`** โ Default: `#222222`
The color of the focused item.
- **`focused_back_color`** โ Default: `#FFFFFF`
The background color of the focused item.
- **`disabled_color`** โ Default: `#555555`
The color of disabled items.
- **`seconds_to_open_submenus`** โ Default: `0.2`
The number of seconds to open submenus after the cursor enters items associated with one.
- **`seconds_to_close_submenus`** โ Default: `0.2`
The number of seconds to close submenus after the cursor enters a parent menu.
---
# ๐ POSITIONING ๐
This script provides script bindings to pan videos and images ๐ฆ. You can disable it with `--load-positioning=no`.
---
## Script bindings
- **`pan-x <amount>`** โ Adjust `--video-align-x` *relatively to the OSD width*, rather than relatively to the video width like the option does. This is useful for panning large images consistently.
*amount* is a number such that an amount of `1` scrolls as much as the OSD width.
- **`pan-y <amount>`** โ Adjust `--video-align-y` relatively to the OSD height, rather than relatively to the video height like the option.
*amount* is a number such that an amount of `1` scrolls as much as the OSD height.
- **`drag-to-pan`** โ Pan the video while holding a mouse button, keeping the clicked part of the video under the cursor.
- **`align-to-cursor`** โ Pan through the whole video while holding a mouse button, or after clicking once if `toggle_align_to_cursor` is `yes`.
- **`cursor-centric-zoom <amount>`** โ Increase `--video-zoom` by *amount* while keeping the part of the video hovered by the cursor under it, or the average position of touch points if known.
---
## Configuration
This script can be customized through a config file `script-opts/positioning.conf` placed in mpv's user directory, and through the `--script-opts` command-line option. The configuration syntax is described in **mp.options functions**.
---
## Configurable Options
- **`toggle_align_to_cursor`** โ Default: `no`
Whether `align-to-cursor` requires holding down a mouse button to pan. If `no`, dragging pans. If `yes`, clicking the first time makes pan follow the cursor, and clicking a second time disables this. ๐ฑ๏ธ
- **`suppress_osd`** โ Default: `no`
Whether to *not* print the new value of `--video-zoom` when using `cursor-centric-zoom`.
---
# ๐ LUA SCRIPTING ๐
mpv can load Lua scripts. (See **Script location**.)
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. ๐
Technically, the Lua code uses the client API internally.
---
## Example
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)
---
## Script location
Scripts can be passed to the `--script` option, and are automatically loaded from the `scripts` subdirectory of the mpv configuration directory (usually `~/.config/mpv/scripts/`). โจ
A script can be a single file. The file extension is used to select the scripting backend to use for it. For Lua, it is `.lua`. If the extension is not recognized, an error is printed. (If an error happens, the extension is either mistyped, or the backend was not compiled into your mpv binary.) ๐
mpv internally loads the script's name by stripping the `.lua` extension and replacing all nonalphanumeric characters with `_`. E.g., `my-tools.lua` becomes `my_tools`. If there are several scripts with the same name, it is made unique by appending a number. This is the name returned by `mp.get_script_name()`.
Entries with `.disable` extension are always ignored. ๐
- If a script is a directory (whether someone hands a directory to <lavender>`--script`</lavender>, or it's one of the sub-directories hanging out in the script directory, like say `~/.config/mpv/scripts/something/`), then that whole directory **is** one script, bestie. mpv will go looking for a file named `main.x`, where that `x` gets swapped for whatever the file extension is. So if `main.lua` is there? Boom, it gets loaded with the Lua scripting backend. ๐
- Okay but listen โ you must **not** put any other files or directories that start with `main.` at the top level of the script's directory. Rude, I know. If your script directory has, like, both `main.lua` and `main.js` in it, only **one** of them gets loaded โ and *which* one depends on mpv internals that could change literally any time. ๐ Same energy if you've got a `main.foo` sitting there: your script will break the second mpv adds a backend that uses the `.foo` file extension. Not a vibe.
- mpv also appends the top level directory of the script to the start of Lua's package path, so you can import scripts from there too. ๐ Just be aware that this will **shadow** Lua libraries that use the same package path. (Single file scripts do *not* include mpv specific directories in the Lua package path. This was silently changed in mpv `0.32.0` โ sneaky.)
- Using a script directory is <mint>the recommended way</mint> to package a script that's made of multiple source files, or that needs other files (you can use `mp.get_script_directory()` to get the location and, like, load data files and stuff). ๐ซถ
- Making a script a git repository โ basically a repo with a `main.lua` file chillin' in the root directory โ makes scripts easily updateable (without the dangers of auto-updates, which is giving chaos). Another suggestion is to use git submodules to share common files or libraries. โจ
---
### ๐ฑ Details on the script initialization and lifecycle
Your script gets loaded by the player at program start, from the `scripts` configuration subdirectory, or from a path you specified with the <lavender>`--script`</lavender> option. Some scripts are loaded internally (like <lavender>`--osc`</lavender>). Every script runs in its own thread. ๐งต
Your script is first run "as is", and once that's done, the event loop is entered. This event loop will dispatch events received by mpv and call your own event handlers โ the ones you registered with `mp.register_event`, or timers you added with `mp.add_timeout` or similar. ๐ฌ
> Heads up bestie: since the script starts executing **concurrently** with player initialization, some properties may not be populated with meaningful values until the relevant subsystems have initialized. Instead of grabbing these properties at the top of scripts, you should use `mp.observe_property` or read them inside event handlers. Trust. ๐
When the player quits, all scripts get asked to terminate. This happens via a `shutdown` event, which by default will make the event loop return. If your script got itself into an endless loop, mpv will probably behave fine during playback, but it **won't terminate when quitting**, because it's stuck waiting on your script. ๐ญ So don't do that.
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. ๐
---
### ๐ mp functions
The `mp` module is preloaded, although it can be loaded manually with `require 'mp'`. It provides the core client API. ๐ฅ
- **`mp.command(string)`** โ 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* for how to influence OSD usage per command.
Returns `true` on success, or `nil, error` on error.
- **`mp.commandv(arg1, arg2, ...)`** โ Similar to `mp.command`, but pass each command argument as a 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).
- **`mp.command_native(table [,def])`** โ Similar to `mp.commandv`, but pass the argument list as a 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.
- **`mp.command_native_async(table [,fn])`** โ Like `mp.command_native()`, but the command is ran asynchronously (as far as possible), and upon completion, `fn` is called. `fn` has three arguments: `fn(success, result, error)`:
- `success` โ Always a Boolean and is `true` if the command was successful, otherwise `false`.
- `result` โ The result value (can be `nil`) in case of success, `nil` otherwise (as returned by `mp.command_native()`).
- `error` โ 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.
`fn` is **always** called asynchronously, even if the command failed to start.
- **`mp.abort_async_command(t)`** โ Abort a `mp.command_native_async` call. The argument is the return value of that command (which starts asynchronous execution of the command). Whether this works and how long it takes depends on the command and the situation. The abort call itself is asynchronous. Does not return anything.
- **`mp.del_property(name)`** โ Delete the given property. See `mp.get_property` and *Properties* for more information about properties. Most properties cannot be deleted. ๐ซ
Returns `true` on success, or `nil, error` on error.
- **`mp.get_property(name [,def])`** โ 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.
- **`mp.get_property_osd(name [,def])`** โ 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.
- **`mp.get_property_bool(name [,def])`** โ Similar to `mp.get_property`, but return the property value as Boolean.
Returns a Boolean on success, or `def, error` on error.
- **`mp.get_property_number(name [,def])`** โ 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.
- **`mp.get_property_native(name [,def])`** โ 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.
- **`mp.set_property(name, value)`** โ 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.
- **`mp.set_property_bool(name, value)`** โ Similar to `mp.set_property`, but set the given property to the given Boolean value.
- **`mp.set_property_number(name, value)`** โ 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.
- **`mp.set_property_native(name, value)`** โ Similar to `mp.set_property`, but set the given property using its native type. ๐ฆ
Since there are several data types that straight up cannot be represented natively in Lua, this might not always work the way you'd expect ๐ญ. For example, the Lua wrapper can do a lil bit of guesswork to figure out whether a Lua table is an array or a map, but that guesswork **fails with empty tables**. Also, there aren't many properties where doing this even makes sense, instead of just using `set_property`, `set_property_bool`, or `set_property_number`. For these reasons, bestie, this function should probably be avoided for now โ except for properties that use tables natively. ๐
---
### `mp.get_time()`
Returns the current mpv internal time in seconds, as a number. It's basically the system time, just with an arbitrary offset. โฐ
### `mp.add_key_binding(key, name|fn [,fn [,flags]])`
Registers a callback that runs on a key binding โจ. The binding gets mapped to the given `key`, which is a string describing the physical key. It uses the same key names as in `input.conf`, and it also allows combinations (e.g. `ctrl+a`). If the key is empty or `nil`, **no physical key is registered**, but you can still create your own bindings (more on that below).
After you call this function, key presses will make the function `fn` get called โ unless the user remapped the key with another binding. However, if the key binding is *canceled*, the function will **not** be called, unless the `complex` flag is set to `true`, in which case the function gets called with the `canceled` entry set to `true`.
For example, a canceled key binding can happen in these situations:
- If key `A` is pressed while key `B` is being held down, key `B` is logically released ("canceled" by key `A`), which stops the current autorepeat action key `B` has.
- If key `A` is pressed while a mouse button is being held down, the mouse button is logically released โ but the mouse button's action will not be called, unless the `complex` flag is set to `true`.
The `name` argument should be a short symbolic string. It lets the user remap the key binding via `input.conf` using the `script-message` command, plus the name of the key binding (there's an example below). The name should be **unique** across other bindings in the same script โ if it isn't, the previous binding with the same name gets overwritten. You can omit the name, in which case a random name is generated internally. (Omitting works like this: either pass `nil` for `name`, or pass the `fn` argument in place of the name. The latter is *not recommended* and is only handled for compatibility.)
The `flags` argument is for optional parameters. It's a table, and it can have these entries:
- **`repeatable`** โ If set to `true`, enables key repeat for this specific binding. This option only makes sense when `complex` is **not** set to `true`.
- **`scalable`** โ If set to `true`, enables key scaling for this specific binding. This option only makes sense when `complex` **is** set to `true`. Note that this has no effect if the key binding is invoked by the `script-binding` command, where the scalability of the command takes precedence.
- **`complex`** โ If set to `true`, then `fn` is called on key down, repeat and up events, with the first argument being a table. That table has these entries (and may contain undocumented ones too ๐):
- **`event`** โ Set to one of the strings `down`, `repeat`, `up` or `press` (the latter if key up/down/repeat can't be tracked), which indicates the key's logical state.
- **`is_mouse`** โ Boolean: whether the event was caused by a mouse button.
- **`canceled`** โ Boolean: whether the event was canceled. Not all types of cancellations set this flag.
- **`key_name`** โ The name of the 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 the description of the `script-binding` command for details (this field is equivalent to the 5th argument).
- **`scale`** โ The scale of the key, such as the ones produced by `WHEEL_*` keys. The scale is `1` if the key is nonscalable.
- **`arg`** โ User-provided string in the `arg` argument in the `script-binding` command, if the key binding is invoked by that command.
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
### `mp.add_forced_key_binding(...)`
This works *almost* the same as `mp.add_key_binding`, but it registers the key binding in a way that will **overwrite the user's custom bindings** in their `input.conf`. (`mp.add_key_binding` overwrites default key bindings only, not the ones from the user's `input.conf`.) ๐ฅ
### `mp.remove_key_binding(name)`
Removes a key binding that was added with `mp.add_key_binding` or `mp.add_forced_key_binding`. Use the same `name` you used when adding the binding. It's **not possible** to remove bindings for which you omitted the name ๐.
### `mp.register_event(name, fn)`
Calls 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 gets put into a Lua table and passed as an argument to `fn`. By default, that Lua table contains a `name` field, which is a string holding the event name. If the event has an error associated with it, 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 run in registration order, so the first registered function runs before all the others.
Returns `true` if such an event exists, `false` otherwise.
See **Events** and **List of events** for details.
### `mp.unregister_event(fn)`
Undoes `mp.register_event(..., fn)`. This removes all event handlers that are equal to the `fn` parameter. It uses normal Lua `==` comparison, so be careful when you're dealing with closures ๐ซ .
### `mp.observe_property(name, type, fn)`
Watches a property for changes ๐. If the property `name` is changed, then the function `fn(name)` will be called. `type` can be `nil`, or it can 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 the 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(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`, the change function `fn` will be called sporadically even if the property doesn't actually change. So you should **avoid** using these types ๐
.
You always get an initial change notification. This is meant to initialize the user's state to the current value of the property.
### `mp.unobserve_property(fn)`
Undoes `mp.observe_property(..., fn)`. This removes all property handlers that are equal to the `fn` parameter. It uses normal Lua `==` comparison, so be careful when dealing with closures ๐ซถ.
### `mp.add_timeout(seconds, fn [, disabled])`
Calls 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.
If the `disabled` argument is set to `true` or a truthy value, the timer will wait to be manually started with a call to its `resume()` method.
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.
### `mp.add_periodic_timer(seconds, fn [, disabled])`
Calls the given function **periodically** ๐. This is like `mp.add_timeout`, but the timer is re-added after the function `fn` is run.
Returns a timer object. The timer object provides the following methods:
- **`stop()`** โ turns the timer off. Already off? It does literally nothing, bestie ๐
. But it *does* remember the current elapsed time while stopping, so `resume()` is basically an unpause.
- **`kill()`** โ also turns the timer off, except this one *resets* the elapsed time. So `resume()` restarts it from scratch. โจ
- **`resume()`** โ restarts the timer. If it got disabled with `stop()`, it picks back up at the time it was stopped. If it got disabled with `kill()`, or if it's a previously fired one-shot timer (added with `add_timeout()`), it starts from the beginning using the timeout you configured initially.
- **`is_enabled()`** โ tells you whether the timer is currently enabled, or was previously disabled (like by `stop()` or `kill()`).
- **`timeout` (RW)** โ this field holds the current timeout period. Heads up: this value does **not** update as time passes. It's only used to calculate when the timer should fire next, when the timer expires.
If you write to it, you can call `t:kill()` ; `t:resume()` to reset the current timeout to the new one. (`t:stop()` won't use the new timeout, noted ๐ซถ.)
- **`oneshot` (RW)** โ is the timer periodic (`false`) or does it fire just once (`true`)? This value is used when the timer expires (but before the timer callback function `fn` is run).
> okay so these are **methods**, meaning you have to call them with `:` instead of `.` (go read up at `https://www.lua.org/manual/5.2/manual.html#3.4.9` if you want the lore ๐ซ).
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)
**`mp.get_opt(key)`** โ returns a setting from the `--script-opts` option. How this mechanism actually gets used is up to the user and the script. Rn, all scripts can access this equally, so be careful about collisions, bestie ๐.
**`mp.get_script_name()`** โ returns the name of the current script. Usually that's the script's filename with the directory and file extension removed. If there are several scripts that would have the same name, it gets made unique by appending a number. Any nonalphanumeric characters get replaced with `_`.
> **Example** ๐ธ
>
> The script `/path/to/foo-script.lua` becomes `foo_script`.
**`mp.get_script_directory()`** โ returns the directory if this is a script packaged as a directory (peep "Script location" for a description). Returns nothing if this is a single file script.
**`mp.osd_message(text [,duration])`** โ shows an OSD message on the screen. `duration` is in seconds, and it's optional (uses `--osd-duration` by default).
---
## โจ Advanced mp functions โจ
These also live in the `mp` module, but they're documented separately since they're only useful in special situations. ๐ซ
**`mp.get_wakeup_pipe()`** โ calls `mpv_get_wakeup_pipe()` and returns the read end of the wakeup pipe. This is deprecated, but it still works. (See `client.h` for details.)
**`mp.get_next_timeout()`** โ returns the relative time in seconds for when the next timer (`mp.add_timeout` and similar) expires. If there's no timer, it returns `nil`.
**`mp.dispatch_events([allow_wait])`** โ this one's for running custom event loops. If you want direct control over what the Lua script does (instead of getting called by the default event loop), set the global variable `mp_event_loop` to your own function that runs 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 blocks 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 care about properly working notification of new events and working timers. ๐
**`mp.register_idle(fn)`** โ registers an event loop idle handler. Idle handlers get called before the script goes to sleep after handling all new events. This is useful for stuff like delaying processing of property change events: if you're observing multiple properties at once, you might not want to act on each individual property change, but only once all the change notifications have been received.
**`mp.unregister_idle(fn)`** โ undoes `mp.register_idle(fn)`. Removes all idle handlers that are equal to the `fn` parameter. This uses normal Lua `==` comparison, so be careful when dealing with closures ๐ซฃ.
**`mp.enable_messages(level)`** โ sets the minimum log level of which mpv message output to receive. These messages are normally printed to the terminal. By calling this function, you can set the minimum log level of messages that should be received with the `log-message` event. See that event's description for details. `level` is a string โ see `msg.log` for the allowed log levels.
**`mp.register_script_message(name, fn)`** โ 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 the first parameter. The other parameters get passed to `fn`. If a message with the given name is already registered, it gets overwritten.
> Used by `mp.add_key_binding`, so be careful about name collisions. ๐
**`mp.unregister_script_message(name)`** โ undoes a previous registration with `mp.register_script_message`. Does nothing if the name wasn't registered.
**`mp.create_osd_overlay(format)`** โ creates 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 initializes the `format` field. The `data` field contains the text to be used as the overlay. For details, see the `osd-overlay` command.
On top of that, it provides these methods:
- **`update()`** โ commits the OSD overlay to the screen, or in other words, runs the `osd-overlay` command with the current fields of the overlay table. Returns the result of the `osd-overlay` command itself.
- **`remove()`** โ removes the overlay from the screen. An `update()` call will add it again.
Example:
ov = mp.create_osd_overlay("ass-events") ov.data = "{\an5}{\b1}hello world!" ov:update()
The perk of using this wrapper (as opposed to running `osd-overlay` directly) is that the `id` field gets allocated automatically. โจ
**`mp.get_osd_size()`** โ returns a tuple of `osd_width`, `osd_height`, `osd_par`. The first two give the size of the OSD in pixels (for video outputs like `--vo=xv`, these may be "scaled" pixels). The third is the display pixel aspect ratio.
> May return invalid/nonsense values if OSD isn't initialized yet. ๐
**`exit()` (global)** โ makes the script exit at the end of the current event loop iteration. This does **not** terminate mpv itself or other scripts.
This can be polyfilled to support mpv versions older than 0.40 with:
if not _G.exit then function exit() mp.keep_running = false end end
## ๐ฌ mp.msg functions ๐ฌ
This module lets you output messages to the terminal, and you can load it with `require 'mp.msg'`.
**`msg.log(level, ...)`** โ 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 decide which of these messages are visible. Normally, all messages are visible except `v`, `debug` and `trace`.
The parameters after that all get converted to strings. Spaces are inserted to separate multiple parameters.
You don't need to add newlines. ๐
**`msg.fatal(...)`, `msg.error(...)`, `msg.warn(...)`, `msg.info(...)`, `msg.verbose(...)`, `msg.debug(...)`, `msg.trace(...)`** โ all of these are shortcuts and equivalent to the corresponding `msg.log(level, ...)` call.
## ๐ mp.options functions ๐
mpv comes with a built-in module to manage options from config-files and the command-line. All you have to do is supply a table with default options to the `read_options` function. The function overwrites the default values with values found in the config-file and the command-line (in that order). ๐
**`options.read_options(table [, identifier [, on_update]])`** โ 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 need to be 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:**
local options = { optionA = "defaultvalueA", optionB = -0.5, optionC = true, }
require "mp.options".read_options(options, "myscript") print(options.optionA)
The config file gets stashed at <pink>`script-opts/identifier.conf`</pink> inside mpv's user folder. Comment lines start with <mint>`#`</mint>, and bestie, <red>stray spaces are NOT removed</red> โ so don't be messy. Booleans show up as <yellow>`yes`</yellow>/<yellow>`no`</yellow>.
Example config:
comment
optionA=Hello World optionB=9999 optionC=no
Command-line options get read from the <cyan>`--script-opts`</cyan> parameter. And to keep everybody from stepping on each other's toes, every key has to be prefixed with <hotpink>`identifier-`</hotpink>. Collisions? not on my watch ๐
Example command-line:
--script-opts=myscript-optionA=TEST,myscript-optionB=0,myscript-optionC=yes
---
## โจ mp.utils functions โจ
This built-in module hands you generic helper functions for Lua, and honestly it has <purple>strictly speaking nothing to do with mpv or video/audio playback</purple>. It's just there for convenience โ most of it is patching up for Lua's kinda-scarce standard library ๐ซถ
> โ ๏ธ <red>Be warned</red>: any of these functions might <yellow>disappear any time</yellow>. They are **not** strictly part of the guaranteed API. So likeโฆ don't build your whole personality around them, bestie ๐ญ
**`utils.getcwd()`**
Returns the directory that mpv was launched from. On error, returns `nil, error`.
**`utils.readdir(path [, filter])`**
Enumerate all the entries at the given `path` on the filesystem, and return them as an array. Each entry is a directory entry (<pink>without</pink> the path). The list is <yellow>unsorted</yellow> โ it comes back in whatever order the operating system felt like returning it. Chaos, but make it โจfilesystemโจ.
If the `filter` argument is given, it must be one of these strings:
- `files` โ list regular files only. This excludes directories, special files (like UNIX device files or FIFOs), and dead symlinks. It <green>includes</green> UNIX symlinks to regular files.
- `dirs` โ list directories only, or symlinks to directories. `.` and `..` are <red>not</red> 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, returns `nil, error`.
**`utils.file_info(path)`**
Stats the given `path` for information and returns a table with these 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
- `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 <italic>are</italic> derived from `mode`.
On error (e.g. `path` does not exist), returns `nil, error`.
**`utils.split_path(path)`**
Split a path into a directory component and a filename component, and return them. The first return value is <pink>always</pink> the directory. The second return value is the trailing part of the path, the directory entry.
**`utils.join_path(p1, p2)`**
Return the concatenation of the 2 paths. Tries to be clever ๐ง โจ For example, if `p2` is an absolute path, `p2` is returned without change.
**`utils.subprocess(t)`**
Runs an external process and waits until it exits. Returns the process status and the captured output. This is a <yellow>legacy wrapper</yellow> around calling the `subprocess` command with `mp.command_native`. It does the following things:
- copy the table `t`
- rename `cancellable` field to `playback_only`
- rename `max_size` to `capture_size`
- set `capture_stdout` field to `true` if unset
- set `name` field to `subprocess`
- call `mp.command_native(copied_t)`
- if the command failed, create a dummy result table
- copy `error_string` to `error` field if the string is non-empty
- return the result table
> ๐ It is <hotpink>recommended</hotpink> to use `mp.command_native` or `mp.command_native_async` directly, instead of calling this legacy wrapper. It is for <purple>compatibility only</purple>.
See the `subprocess` documentation for semantics and further parameters.
**`utils.subprocess_detached(t)`**
Runs an external process and <rainbow>detaches</rainbow> 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.
**`utils.getpid()`**
Returns the process ID of the running mpv process. You can use this to identify the calling mpv when launching (detached) subprocesses ๐
**`utils.get_env_list()`**
Returns the C environment as a list of strings. (Do <red>not</red> confuse this with the Lua "environment", which is a completely unrelated concept, iykyk.)
**`utils.parse_json(str [, trail])`**
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. Fr fr. That's it. That's the error.)
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 <green>tolerated</green> by the function, and the trailing text is returned as the 3rd return value. (The 3rd return value is <italic>always</italic> there, but with `trail` set, no error is raised.)
**`utils.format_json(v)`**
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. Rude of them tbh.)
The argument value uses similar conventions as `mp.set_property_native()` to distinguish empty objects and arrays.
**`utils.to_string(v)`**
Turn the given value into a string. Formats tables and their contents. This doesn't do anything special; it is only needed because <pink>Lua is terrible</pink> ๐ and we love her anyway.
---
## ๐ธ mp.input functions ๐ธ
This module lets scripts get textual input from the user using the console REPL. Cute, interactive, iconic ๐
**`input.get(table)`**
Show the console to let the user enter text.
The following entries of `table` are read:
- `prompt` โ the string to be displayed before the input field.
- `submit` โ a callback invoked when the user presses <cyan>Enter</cyan>. The first argument is the text in the console.
- `keep_open` โ whether to keep the console open on submit. Defaults to `false`.
- `opened` โ a callback invoked when the console is shown. This can be used to present a list of options with `input.set_log()`.
- `edited` โ a callback invoked when the text changes. The first argument is the text in the console.
- `complete` โ a callback invoked when the user edits the text or moves the cursor. The first argument is the text before the cursor. The callback should return a table of the string candidate completion values and the 1-based cursor position from which the completion starts. `console` will show the completions that fuzzily match the text between this position and the cursor and allow selecting them.
The third and optional return value is a string that will be appended to the input line <purple>without displaying it</purple> in the completions.
- `autoselect_completion` โ whether to automatically select the first completion on submit if one wasn't already manually selected. Defaults to `false`.
- `closed` โ a callback invoked when the console is hidden, either because `input.terminate()` was invoked from the other callbacks, or because the user closed it with a key binding. The first argument is the text in the console, and the second argument is the cursor position.
- `default_text` โ a string to pre-fill the input field with.
- `cursor_position` โ the initial cursor position, starting from 1.
- `history_path` โ if specified, the path to save and load the history of the entered lines.
- `id` โ an identifier that determines which input history and log buffer to use among the ones stored for `input.get()` calls. Defaults to the calling script name with `prompt` appended.
**`input.terminate()`**
Close the console. Bye bestie ๐
**`input.log(message, style, terminal_style)`**
Add a line to the log buffer. `style` can contain additional ASS tags to apply to `message`, and `terminal_style` can contain escape sequences that are used when the console is displayed in the terminal.
**`input.log_error(message)`**
Helper to add a line to the log buffer with the <red>same color as the one used for commands that error</red>. Useful when the user submits invalid input. Gentle shame, but make it aesthetic โจ
**`input.set_log(log)`**
Replace the <hotpink>entire</hotpink> log buffer.
`log` is a table of strings, or tables with `text`, `style` and `terminal_style` keys.
Example:
input.set_log({ "regular text", { text = "error text", style = "{\c&H7a77f2&}", terminal_style = "\027[31m", } })
**`input.select(table)`**
Specify a list of items that are presented to the user for selection.
The following entries of `table` are read:
- `prompt` โ the string to be displayed before the input field.
- `items` โ the table of the entries to choose from.
- `default_item` โ the 1-based integer index of the preselected item.
- `submit` โ the callback invoked when the user presses <cyan>Enter</cyan>. The first argument is the 1-based index of the selected item.
- `keep_open` โ whether to keep the console open on submit. Defaults to `false`.
Example:
โฆand the rest of that snippet? bestie it wraps up like this:
input.select({ items = { "First playlist entry", "Second playlist entry", }, submit = function (id) mp.commandv("playlist-play-index", id - 1) end, })
---
## ๐ Events ๐
Events are the player core sliding into your script's DMs โ pure notifications, one direction, no reply needed. You sign yourself up with `mp.register_event`.
> Heads up bestie: **all** scripts (and every other part of the player) receive events <hotpink>equally</hotpink>, and there's no such thing as blocking other scripts from receiving events. Nobody gets to gatekeep the event stream. periodt. ๐
Example:
function my_fn(event) print("start of playback!") end
mp.register_event("file-loaded", my_fn)
Wanna see all the event types that exist? Go peek at <purple>List of events</purple>. โจ
---
## ๐ง Extras ๐ง
This is the <yellow>experimental</yellow> corner of the docs โ features that are "too special" to guarantee a stable interface. iykyk, tread lightly. ๐
- **`mp.add_hook(type, priority, fn)`** โ registers a hook callback for *type* (a string that identifies a certain kind of hook). Hooks are the moment where the player gets to call script functions and <cyan>wait for their result</cyan> (normally, the Lua scripting interface is asynchronous from the point of view of the player core, so this is kind of a big deal ๐). *priority* is an arbitrary integer that decides ordering among hooks of the same kind. Using the value `50` is recommended as a neutral default value.
`fn(hook)` is the function that gets called during execution of the hook. The parameter handed to it (`hook`) is a Lua object that can control further aspects about the currently invoked hook. It provides these methods:
- **`defer()`** โ returning from the hook function should <red>not</red> automatically continue the hook. Instead, the API user wants to call `hook:cont()` on its own at a later point in time (before or after the function has returned).
- **`cont()`** โ continue the hook. Doesn't need to be called unless `defer()` was called.
See <purple>Hooks</purple> 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 ๐
JavaScript support in mpv is <mint>near identical</mint> to its Lua support, fr fr. Use this section as your reference on differences and availability of APIs โ but otherwise you should refer to the Lua documentation for API details and general scripting in mpv.
## โจ Example โจ
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);
## ๐ฆ Similarities with Lua ๐ฆ
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. all apply to JavaScript files too. Same energy. ๐
Script initialization and lifecycle is the same as with Lua, and most of the Lua functions in the modules `mp`, `mp.utils`, `mp.msg`, `mp.options` and `mp.input` are available to JavaScript with <cyan>identical APIs</cyan> โ including running commands, getting/setting properties, registering events/key-bindings/hooks, etc.
## ๐ Differences from Lua ๐
- **No need to load modules.** `mp`, `mp.utils`, `mp.msg`, `mp.options` and `mp.input` are preloaded, and you can use e.g. `var cwd = mp.utils.getcwd();` without prior setup. iconic, no boilerplate. ๐
- **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.
## ๐ธ Language features - ECMAScript 5 ๐ธ
The scripting backend which mpv currently uses is <hotpink>MuJS</hotpink> โ a compatible minimal ES5 interpreter. As such, `String.substring` is implemented for instance, while the common but non-standard `String.substr` is <red>not</red>. Please consult the MuJS pages on language features and platform support โ `<https://mujs.com>` .
## ๐ฅ Unsupported Lua APIs and their JS alternatives ๐ฅ
- `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 <purple>dump</purple> below.
- `mp.get_next_timeout()` โ see <purple>event loop</purple> below.
- `mp.dispatch_events([allow_wait])` โ see <purple>event loop</purple> below.
## ๐ Scripting APIs - identical to Lua ๐
`(LE)` means **Last-Error** โ it 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, error is empty string on success.
- `mp.abort_async_command(id)`
- `mp.del_property(name)` (LE)
- `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.get_script_directory()`
- `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) Note: like lua โ this does <red>NOT</red> expand meta-paths like `~~/foo` (other JS file functions do expand meta paths).
- `mp.utils.split_path(path)`
- `mp.utils.join_path(p1, p2)`
- `mp.utils.subprocess(t)`
- `mp.utils.subprocess_detached(t)`
- `mp.utils.get_env_list()`
- `mp.utils.getpid()` (LE)
- `mp.add_hook(type, priority, fn(hook))`
- `mp.options.read_options(obj [, identifier [, on_update]])` (types: string/boolean/number)
- `mp.input.get(obj)`
- `mp.input.select(obj)`
- `mp.input.terminate()`
- `mp.input.log(message, style)`
- `mp.input.log_error(message)`
- `mp.input.set_log(log)`
- `exit()` (global)
## ๐ Additional utilities ๐
- **`mp.last_error()`** โ if used after an API call which updates last error, returns an empty string if the API call succeeded, or a non-empty error reason string otherwise.
- **`Error.stack`** (string) โ when using `try { ... } catch(e) { ... }`, then `e.stack` is the stack trace of the error โ if it was created using the `Error(...)` constructor.
- **`print`** (global) โ a convenient alias to `mp.msg.info`.
- **`dump`** (global) โ like `print` but also expands objects and arrays recursively.
- **`mp.utils.getenv(name)`** โ returns the value of the host environment variable *name*, or `undefined` if the variable is not defined.
- **`mp.utils.get_user_path(path)`** โ trivial wrapper of the `expand-path` mpv command, returns a string. `read_file`, `write_file`, `append_file` and `require` already expand the path internally and accept mpv meta-paths like `~~desktop/foo`.
- **`mp.utils.read_file(fname [,max])`** โ returns the content of file *fname* as string. If *max* is provided and not negative, limit the read to *max* bytes.
- **`mp.utils.write_file(fname, str)`** โ (over)write file *fname* with text content *str*. *fname* must be prefixed with `file://` as simple protection against accidental arguments switch, e.g. `mp.utils.write_file("file://~/abc.txt", "hello world")`.
- **`mp.utils.append_file(fname, str)`** โ same as `mp.utils.write_file` if the file *fname* does not exist. If it does exist then append instead of overwrite.
> Note: `read_file`, `write_file` and `append_file` throw on errors, allow text content only.
- **`mp.get_time_ms()`** โ same as `mp.get_time()` but in ms instead of seconds.
- **`mp.get_script_file()`** โ returns the file name of the current script.
- **`mp.utils.compile_js(fname, content_str)`** โ compiles the JS code *content_str* as file name *fname* (without loading anything from the filesystem), and returns it as a function. Very similar to a `Function` constructor, but shows at stack traces as *fname*.
- **`mp.module_paths`** โ global modules search paths array for the `require` function (see below).
## โฐ Timers (global) โฐ
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 <red>irreversible</red>. no takebacks, bestie. ๐ญ
> Note: timers <hotpink>always</hotpink> 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.
<purple>okay bestie, one more tiny thing about timers before we move on:</purple> timers get processed **after** the event queue is empty, so it's totally valid to use `setTimeout(fn)` as a one-time idle observer. cute, right? โจ
---
## ๐งฉ CommonJS modules and require(id) ๐งฉ
CommonJS Modules are, like, a standard system where scripts can export common functions for use by other scripts. Specifically? A module is a script that adds properties (functions, etc.) to its pre-existing `exports` object, and then another script can get at all that goodness 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. no re-running, we love a cached queen ๐
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. it's giving "mpv only, bestie" ๐
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* which starts with `./` or `../` is relative to the script or module which require it. 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 according to `mp.module_paths` in normal array order, e.g. `require("x")` tries to load `x.js` at one of the array paths, and id `foo/x` tries to load `x.js` inside dir `foo` at one of the paths.
The `mp.module_paths` array is empty by default except for scripts which are loaded as a directory where it contains one item โ `<directory>/modules/` . The array may be updated from a script (or using custom init โ see below) which will affect future calls to `require` for 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. good. clean. respectful. ๐ธ
## ๐ ๏ธ Custom initialization ๐ ๏ธ
After mpv initializes the JavaScript environment for a script but **before** it loads the script โ it tries to run the file `init.js` at the root of the mpv configuration directory. Code at this file can update the environment further for all scripts. E.g. if it contains `mp.module_paths.push("/foo")` then `require` at all scripts will search global module id's also at `/foo`.
> do **NOT** do `mp.module_paths = ["/foo"];` because this will remove existing paths โ like `<script-dir>/modules` for scripts which load from a directory. bestie. don't. ๐ญ
The custom-init file is ignored if mpv is invoked with `--no-config`.
Before mpv 0.34, the file name was `.init.js` (with dot) at the same dir.
## ๐ The event loop ๐
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. forever and ever, iconic behavior โจ
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`.
---
# ๐ฐ๏ธ JSON IPC ๐ฐ๏ธ
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`, or the file descriptor number of a unix socket or a named pipe using `--input-ipc-client`. Clients can connect to this socket and send commands to the player or receive events from it. it's giving โจ remote control โจ
> **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.
>
> fr fr bestie, do not expose this to the internet. no cap. ๐
## ๐ Socat example ๐
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.) rude of it, but okay ๐ซถ
## ๐ช Command Prompt example ๐ช
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`.)
You can open the pipe in PuTTY as "serial" device. This is not very comfortable, but gives a way to test interactively without having to write code.
## ๐ Protocol ๐
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. minify that message bestie, no whitespace allowed ๐
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 interpret 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. ๐ noted.
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`.
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.
## ๐ Data flow ๐
Currently, the mpv-side IPC implementation does **not** service the socket while a command is executed and the reply is written. It is for example not possible that other events, that happened during the execution of the command, are written to the socket before the reply is written.
This might change in the future. The only guarantee is that replies to IPC messages are sent in sequence.
Also, since socket I/O is inherently asynchronous, it is possible that you read unrelated event messages from the socket, before you read the reply to the previous command you sent. In this case, these events were queued by the mpv side before it read and started processing your command message.
---
<pink>Okay so</pink> if the mpv-side IPC implementation ever switches away from blocking writes and blocking command execution, it might start yeeting events at you at literally any time. No schedule, no warning. ๐
You can also use asynchronous commands, bestie โ those can come back in any order, and they don't block IPC protocol interaction <purple>at all</purple> while the command chugs along in the background. Slay.
---
## โจ Asynchronous commands โจ
A command can be run asynchronously. This behaves *exactly* as with normal command execution, except that execution is <hotpink>not blocking</hotpink>. Other commands can be sent while it's executing, and command completion can be arbitrarily reordered. Chaos, but make it functional. ๐ฆ
The `async` field controls this. If present, it **must** be a boolean. If it's missing, `false` is assumed.
For example, this initiates an asynchronous command:
{ "command": ["screenshot"], "request_id": 123, "async": true }
And this is the completion:
{"request_id":123,"error":"success","data":null}
By design, you will **not** get a confirmation that the command was started. That's just how it is, no cap. If a command is long running, sending the message will not lead to any reply until much later when the command finishes. ๐
Some commands execute synchronously, but these will behave like asynchronous commands that finished execution immediately.
Cancellation of asynchronous commands is available in the libmpv API, but has not yet been implemented in the IPC protocol. Soon-ish, maybe, not yet. ๐
---
## ๐ Commands with named arguments ๐
If the `command` field is a JSON object, named arguments are expected. This is described in the C API `mpv_command_node()` documentation (the `MPV_FORMAT_NODE_MAP` case). In some cases, this may make commands more readable, while some obscure commands basically **require** using named arguments. iykyk.
Currently, only "proper" commands (as listed by *List of Input Commands*) support named arguments.
---
## ๐ Commands ๐
In addition to the commands described in *List of Input Commands*, a few extra commands can also be used as part of the protocol:
- **`client_name`** โ Return the name of the client as string. This is the string `ipc-N` with `N` being an integer number.
- **`get_time_us`** โ Return the current mpv internal time in microseconds as a number. This is basically the system time, with an arbitrary offset.
- **`get_property`** โ 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" }
- **`get_property_string`** โ Like `get_property`, but the resulting data will always be a string.
Example:
{ "command": ["get_property_string", "volume"] } { "data": "50.000000", "error": "success" }
- **`set_property`** โ Set the given property to the given value. See *Properties* for more information about properties.
Example:
{ "command": ["set_property", "pause", true] } { "error": "success" }
- **`set_property_string`** โ Alias for `set_property`. Both commands accept native values and strings.
- **`observe_property`** โ 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" }
> <red>Warning:</red> 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, actually. Don't close it. ๐ซถ
- **`observe_property_string`** โ 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" }
- **`unobserve_property`** โ 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" }
- **`request_log_messages`** โ 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. <yellow>Do not parse the log, bestie, it will betray you.</yellow> ๐ญ
- **`enable_event`, `disable_event`** โ 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.
- **`get_version`** โ Returns the client API version the C API of the remote mpv instance provides.
See also: `DOCS/client-api-changes.rst`.
---
## ๐ UTF-8 ๐
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.
---
## ๐ง JSON extensions ๐ง
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" }
---
## ๐ฆ Alternative ways of starting clients ๐ฆ
You can create an anonymous IPC connection without having to set `--input-ipc-server`. This is achieved through a mpv pseudo scripting backend that starts processes.
You can put `.run` file extension in the mpv scripts directory in its config directory (see the *FILES* section for details), or load them through other means (see *Script location*). These scripts are simply executed with the OS native mechanism (as if you ran them in the shell). They must have a proper shebang and have the executable bit set. ๐
When executed, a socket (the IPC connection) is passed to them through file descriptor inheritance. The file descriptor is indicated as the special command line argument `--mpv-ipc-fd=N`, where `N` is the numeric file descriptor.
The rest is the same as with a normal `--input-ipc-server` IPC connection. mpv does not attempt to observe or other interact with the started script process.
> This does not work in Windows yet. ๐
---
# โญ CHANGELOG โญ
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:
`https://github.com/mpv-player/mpv/releases`
- The git log, which is the "real" changelog
- The file `https://github.com/mpv-player/mpv/blob/master/DOCS/interface-changes.rst` documents changes to the command and user interface, such as options and properties.
- C API changes are listed in `https://github.com/mpv-player/mpv/blob/master/DOCS/client-api-changes.rst`
- 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.)
---
# ๐ EMBEDDING INTO OTHER PROGRAMS (LIBMPV) ๐
mpv can be embedded into other programs as video/audio playback backend. The recommended way to do so is using libmpv. See `include/mpv/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:
- `https://github.com/mpv-player/mpv/blob/master/include/mpv/client.h`
- `https://mpv.io/manual/master/#options`
- `https://mpv.io/manual/master/#list-of-input-commands`
- `https://mpv.io/manual/master/#properties`
- `https://github.com/mpv-player/mpv-examples/tree/master/libmpv`
# ๐งฉ C PLUGINS ๐งฉ
Okay bestie, so you can literally write C plugins for mpv?? Yes. They use the <pink>libmpv API</pink>, BUT โ plot twist โ they don't use the libmpv library itself. It's giving "I know the API but I'm not linking you." ๐
They're <green>enabled by default</green> if the compiler supports linking with the `-rdynamic` flag on Linux/BSD platforms. On Windows they are <hotpink>always enabled</hotpink>. No gatekeeping over there. ๐ชโจ
## ๐ C plugins location
C plugins go into the <purple>mpv scripts directory</purple> inside its config directory (peep the <cyan>FILES</cyan> section for the deets). They gotta have a `.so` or `.dll` file extension โ no exceptions, the file extension is the vibe check. ๐
You can also load them explicitly with the `--script` option. So extra, so iconic. ๐
## ๐ API
A C plugin <red>must</red> export the following function:
int mpv_open_cplugin(mpv_handle *handle)
The plugin function gets called on loading time. And listen โ this function <hotpink>must not return</hotpink> as long as your plugin is loaded (it runs in its own thread, main character energy fr). The handle will be deallocated as soon as the plugin function returns. So like... don't return. ๐ญ
The return value is interpreted as error status:
- A value of `0` is interpreted as <green>success</green>
- `-1` signals an <red>error</red>. In that case, the player prints an uninformative error message that loading failed. Not helpful but okay. ๐
> Return values other than `0` and `-1` are **reserved**, and trigger **undefined behavior**. Do not do this. Periodt. ๐ซ
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. However โ <red>do not call `mpv_destroy()` or `mpv_terminate_destroy()` on this handle.</red> Just don't. ๐
Note that the player might <yellow>block</yellow> until your plugin calls `mpv_wait_event()` for the first time. That's actually a gift, bestie โ it gives you a chance to install initial hooks etc. before playback begins. Slay. ๐
The details are quite similar to Lua scripts. If you've done those, you're already eating. ๐ฝ๏ธ
## ๐ Linkage to libmpv
The current implementation requires that your plugins are <hotpink>not linked against libmpv</hotpink>. What your plugins use are not symbols from a libmpv binary, but symbols from the <purple>mpv host binary</purple>. Subtle but crucial, iykyk. ๐
On Windows, to make symbols from the host binary available, you have to define `MPV_CPLUGIN_DYNAMIC_SYM` when compiling cplugin. This will load symbols dynamically, before calling `mpv_open_cplugin()`. Windows girlies stay winning. ๐ช๐
## ๐ก Examples
See:
- <https://github.com/mpv-player/mpv-examples/tree/master/cplugins>
Go look, the examples are right there, they're serving. โจ
---
# ๐ ENVIRONMENT VARIABLES ๐
There are a number of environment variables that can be used to control the behavior of mpv. Let's get into it. ๐ง
- **`HOME`, `XDG_CONFIG_HOME`** โ 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 <yellow>lower priority</yellow>. It's the backup bestie, not the main one. ๐
- **`MPV_HOME`** โ Directory where mpv looks for user settings. Overrides `HOME`, and mpv will try to load the config file as `$MPV_HOME/mpv.conf`.
- **`MPV_VERBOSE`** (see also `-v` and `--msg-level`) โ Set the initial verbosity level across all message modules (default: `0`). This is an integer, and the resulting verbosity corresponds to the number of `--v` options passed to the command line.
- **`MPV_LEAK_REPORT`** โ If set to `1`, enable internal talloc leak reporting. If set to another value, disable leak reporting. Yes, we're checking for leaks, we're responsible. ๐ซถ
- **`LADSPA_PATH`** โ Specifies the search path for LADSPA plugins. If it is unset, <red>fully qualified path names must be used.</red>
- **`DISPLAY`** โ Standard X11 display name to use. Classic X11 behavior, no notes. ๐ฅ๏ธ
## ๐ฌ FFmpeg:
This library accesses various environment variables. However, they are <yellow>not centrally documented</yellow>, and documenting them is not our job. Therefore, this list is <hotpink>incomplete</hotpink>. We're being honest about it, that's growth. ๐ฑ
Notable environment variables:
- **`http_proxy`** โ URL to proxy for `http://` and `https://` URLs.
- **`no_proxy`** โ List of domain patterns for which no proxy should be used. List entries are separated by `,`. Patterns can include `*`.
## ๐ฟ libdvdcss:
- **`DVDCSS_CACHE`** โ Specify a directory in which to store title key values. This will speed up descrambling of DVDs which are in the cache. The `DVDCSS_CACHE` directory is created if it does not exist, and a subdirectory is created named after the DVD's title or manufacturing date. If `DVDCSS_CACHE` is not set or is empty, libdvdcss will use the default value which is `${HOME}/.dvdcss/` under Unix and the roaming application data directory (`%APPDATA%`) under Windows. The special value `"off"` disables caching.
- **`DVDCSS_METHOD`** โ Sets the authentication and decryption method that libdvdcss will use to read scrambled discs. Can be one of `title`, `key` or `disc`.
- `key` โ is the <green>default</green> method. libdvdcss will use a set of calculated player keys to try to get the disc key. This can fail if the drive does not recognize any of the player keys.
- `disc` โ is a fallback method when `key` has failed. Instead of using player keys, libdvdcss will crack the disc key using a brute force algorithm. This process is <red>CPU intensive</red> and requires <yellow>64 MB of memory</yellow> to store temporary data. It's giving main character of a heist movie. ๐ฅ
- `title` โ is the fallback when all other methods have failed. It does not rely on a key exchange with the DVD drive, but rather uses a crypto attack to guess the title key. On rare cases this may fail because there is not enough encrypted data on the disc to perform a statistical attack, but on the other hand it is the <green>only way</green> to decrypt a DVD stored on a hard disc, or a DVD with the wrong region on an RPC2 drive. Last resort queen. ๐
- **`DVDCSS_RAW_DEVICE`** โ Specify the raw device to use. Exact usage will depend on your operating system, the Linux utility to set up raw devices is `raw(8)` for instance. Please note that on most operating systems, using a raw device requires <hotpink>highly aligned buffers</hotpink>: Linux requires a `2048` bytes alignment (which is the size of a DVD sector).
- **`DVDCSS_VERBOSE`** โ Sets the libdvdcss verbosity level.
- `0` โ Outputs <yellow>no messages at all</yellow>.
- `1` โ Outputs error messages to `stderr`.
- `2` โ Outputs error messages and debug messages to `stderr`.
- **`DVDREAD_NOKEYS`** โ Skip retrieving all keys on startup. Currently <red>disabled</red>. Rip. ๐
- **`HOME`** โ FIXME: Document this. Yeah they said what they said, we're leaving it exactly as is, no cap. ๐ญ
---
# ๐ช EXIT CODES ๐ช
Normally mpv returns `0` as exit code after finishing playback successfully. If errors happen, the following exit codes can be returned:
1. `1` โ Error initializing mpv. This is also returned if unknown options are passed to mpv.
2. `2` โ The file passed to mpv couldn't be played. This is somewhat <yellow>fuzzy</yellow>: currently, playback of a file is considered to be successful if initialization was mostly successful, even if playback fails immediately after initialization.
3. `3` โ There were some files that could be played, and some files which couldn't (using the definition of success from above). A mixed bag, a little bit of both, we love balance. โ๏ธ
4. `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 <hotpink>manually</hotpink> will <green>always</green> 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. So you can literally choose your own ending. ๐
---
# ๐ฝ OPTICAL DRIVES ๐ฝ
Depending on the OS, mpv will choose a different disc device by default. This applies for <purple>all optical disc playback</purple> (CDDA, DVD, and BD). Here's the tea by platform:
- **Linux** โ `/dev/sr0`
- **Windows** โ `D:`
- **macOS** โ `/dev/disk1`
- **FreeBSD** โ `/dev/cd0`
- **OpenBSD** โ `/dev/rcd0c`
Default drive vibes vary by OS and honestly? That's just how it is. ๐
# ๐ FILES ๐
okay bestie, quick heads up: this whole section is assuming <cyan>Linux/BSD</cyan>. On other platforms the paths may be different. For Windows-specifics, see the **FILES ON WINDOWS** section below. ๐
All configuration files should be encoded in <yellow>UTF-8</yellow>. no cap.
- **`/usr/local/etc/mpv/mpv.conf`** โ mpv system-wide settings. This depends on the `--prefix` passed to configure. mpv in default configuration will use `/usr/local/etc/mpv/` as config directory, while most Linux distributions will set it to `/etc/mpv/`. ๐ ๏ธ
- **`~/.cache/mpv`** โ the standard cache directory. Certain options within mpv may cause it to write cache files to disk. This can be overridden by environment variables, in ascending order:
1. If `$XDG_CACHE_HOME` is set, then the derived cache directory will be `$XDG_CACHE_HOME/mpv`.
2. If `$MPV_HOME` is set, then the derived cache directory will be `$MPV_HOME`.
If the directory does not exist, mpv will try to create it automatically. โจ
- **`~/.config/mpv`** โ the standard configuration directory. This can be overridden by environment variables, in ascending order:
1. If `$XDG_CONFIG_HOME` is set, then the derived configuration directory will be `$XDG_CONFIG_HOME/mpv`.
2. If `$MPV_HOME` is set, then the derived configuration directory will be `$MPV_HOME`.
If this directory, nor the original configuration directory (see below) do not exist, mpv tries to create this directory automatically. ๐ซถ
- **`~/.mpv/`** โ the original (pre 0.5.0) configuration directory. It will continue to be read if present. If this directory is present and the standard configuration directory is not present, then cache files and watch later config files will also be written to this directory.
If both this directory and the standard configuration directory are present, configuration will be read from both with the standard configuration directory content taking precedence. However, you should fully migrate to the standard directory and a warning will be shown in this situation. โ ๏ธ
- **`~/.config/mpv/mpv.conf`** โ mpv user settings (see **CONFIGURATION FILES** section).
- **`~/.config/mpv/input.conf`** โ key bindings (see **INPUT.CONF** section).
- **`~/.config/mpv/fonts.conf`** โ 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 <purple>libass</purple> is built with <purple>fontconfig</purple>. ๐
- **`~/.config/mpv/subfont.ttf`** โ fallback subtitle font.
- **`~/.config/mpv/fonts/`** โ default location for `--sub-fonts-dir` (see **Subtitles**) and `--osd-fonts-dir` (see **OSD**).
- **`~/.config/mpv/scripts/`** โ all files in this directory are loaded as if they were passed to the `--script` option. They are loaded in alphabetical order.
The `--load-scripts=no` option disables loading these files.
See **Script location** for details. ๐
- **`~/.local/state/mpv/watch_later/`** โ 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.
This can be overridden by environment variables, in ascending order:
1. If `$XDG_STATE_HOME` is set, then the derived watch later directory will be `$XDG_STATE_HOME/mpv/watch_later`.
2. If `$MPV_HOME` is set, then the derived watch later directory will be `$MPV_HOME/watch_later`.
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. ๐ฅ
- **`~/.config/mpv/script-opts/osc.conf`** โ 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. ๐
---
# ๐ช FILES ON WINDOWS ๐ช
On win32 (if compiled with <cyan>MinGW</cyan>, but not <cyan>Cygwin</cyan>), 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 cache directory is located at `%LOCALAPPDATA%/mpv/cache`.
The watch_later directory is located at `%LOCALAPPDATA%/mpv/watch_later`.
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 and cache 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. ๐
---
# ๐ FILES ON MACOS ๐
On macOS the watch later directory is located at `~/.config/mpv/watch_later/` and the cache directory is set to `~/Library/Caches/io.mpv/`. These directories can't be overwritten by environment variables. Everything else is the same as **FILES**. ๐
---
# ๐ Copyright ๐
`GPLv2+`
and that's literally the whole `mpv(1)` manual page, bestie โ copyright `GPLv2+`, footer says `mpv(1)` with no date in this snippet, just that source/version tag. go forth and config slay ๐
โจ
๐ฆ where this page comes from
- fedora 44: mpv 0.41.0-5.fc44 ยท GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
- nixos 26.05: mpv 0.41.0
- ubuntu resolute: mpv 0.41.0-2ubuntu4 ยท LGPL-2.1-or-later
- ubuntu stonking: mpv 0.41.0-2ubuntu5 ยท LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms