Mpv: Difference between revisions

From ArchWiki
m (→‎Key bindings: format)
(5 intermediate revisions by the same user not shown)
Line 9: Line 9:
{{Related articles end}}
{{Related articles end}}


[https://mpv.io/ mpv] is a media player based on [[MPlayer]] and the now unmaintained ''mplayer2''. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. A comprehensive (although admittedly incomplete) list of differences between ''mpv'' and the aforementioned players can be found [https://github.com/mpv-player/mpv/blob/master/DOCS/mplayer-changes.rst here].
[https://mpv.io/ mpv] is a media player based on [[MPlayer]] and the now unmaintained mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. A comprehensive (although admittedly incomplete) list of differences between mpv and the aforementioned players can be found [https://github.com/mpv-player/mpv/blob/master/DOCS/mplayer-changes.rst here].


== Installation ==
== Installation ==
Line 21: Line 21:
== Configuration ==
== Configuration ==


''mpv'' comes with good all-around defaults that should work well on computers with weaker/older video cards. However, if you have a computer with a more modern video card then mpv allows you to do a great deal of configuration to achieve better video quality (limited only by the power of your video card). To do this one only needs to create a few configuration files (they do not exist by default).
mpv comes with good all-around defaults that should work well on computers with weaker/older video cards. However, if you have a computer with a more modern video card then mpv allows you to do a great deal of configuration to achieve better video quality (limited only by the power of your video card). To do this one only needs to create a few configuration files (they do not exist by default).


{{Note| Configuration files are read system-wide from {{ic|/etc/mpv}} and per-user from {{ic|~/.config/mpv}} (unless the [[environment variable]] {{ic|XDG_CONFIG_HOME}} is set), where per-user settings override system-wide settings, all of which are overridden by the command line. User specific configuration is suggested since it may require some trial and error.}}
{{Note| Configuration files are read system-wide from {{ic|/etc/mpv}} and per-user from {{ic|~/.config/mpv}} (unless the [[environment variable]] {{ic|XDG_CONFIG_HOME}} is set), where per-user settings override system-wide settings, all of which are overridden by the command line. User specific configuration is suggested since it may require some trial and error.}}


To help you get you started ''mpv'' provides some sample configuration files with default settings. Copy them to use as a starting point:
To help you get started mpv provides sample configuration files with default settings. Copy them to use as a starting point:


  $ cp -r /usr/share/doc/mpv/ ~/.config/
  $ cp -r /usr/share/doc/mpv/ ~/.config/


{{ic|mpv.conf}} contains the majority of ''mpv'''s settings, {{ic|input.conf}} contains key bindings. Read through both of them to get an idea of how they work and what options are available.
{{ic|mpv.conf}} contains the majority of mpv's settings, {{ic|input.conf}} contains key bindings. Read through both of them to get an idea of how they work and what options are available.


=== General settings ===
=== General settings ===
Line 81: Line 81:
  log-file=~~/log          #Sets a location for writing a log file, ~~/ translates to ~/.config/mpv
  log-file=~~/log          #Sets a location for writing a log file, ~~/ translates to ~/.config/mpv


There are only two lines within the top level area and there are two separate profiles defined below it. When ''mpv'' starts it sees the first line, loads the options in {{ic|myprofile2}} (which means it loads the options in {{ic|gpu-hq}} and {{ic|1=log-file=~~/log}}) finally it loads {{ic|1=ontop=yes}} and finishes starting up. Note, {{ic|myprofile1}} is never loaded because it's never called in the top level area.
There are only two lines within the top level area and there are two separate profiles defined below it. When mpv starts it sees the first line, loads the options in {{ic|myprofile2}} (which means it loads the options in {{ic|gpu-hq}} and {{ic|1=log-file=~~/log}}) finally it loads {{ic|1=ontop=yes}} and finishes starting up. Note, {{ic|myprofile1}} is never loaded because it's never called in the top level area.


Alternatively one could call mpv from the command line with:
Alternatively one could call mpv from the command line with:
Line 118: Line 118:
=== Additional configuration files ===
=== Additional configuration files ===


In addition there are a few more configuration files one can create:
In addition there are a few more configuration files and directories that can be created, among which:
* {{ic|~/.config/mpv/script-opts/osc.conf}} manages the [https://mpv.io/manual/master/#on-screen-controller On Screen Controller]
 
* If you are using any Lua scripts then you can create a corresponding conf file for each one here: {{ic|~/.config/mpv/script-opts/''scriptname''.conf}}  
* {{ic|~/.config/mpv/script-opts/osc.conf}} manages the [https://mpv.io/manual/master/#on-screen-controller On Screen Controller].
* [https://mpv.io/manual/master/#files lots more]
* {{ic|~/.config/mpv/scripts/''script-name''.lua}} for Lua scripts. See [https://github.com/mpv-player/mpv/issues/3500#issuecomment-305646994] for an example.
 
See https://mpv.io/manual/master/#files for more.


== Scripts ==
== Scripts ==


''mpv'' has a [https://github.com/mpv-player/mpv/wiki/User-Scripts large variety of scripts] that extend the functionality of the player. To this end, it has internal bindings for both Lua and JavaScript (added recently).
mpv has a [https://github.com/mpv-player/mpv/wiki/User-Scripts large variety of scripts] that extend the functionality of the player. To this end, it has internal bindings for both Lua and JavaScript (added recently).


Scripts are typically installed by putting them in the {{ic|~/.config/mpv/scripts/}} directory (you may have to create it first). After that they will be automatically loaded when mpv starts (this behavior can be altered with other mpv options). Some scripts come with their own installation and configuration instructions, so make sure to have a look. In addition some scripts are old, broken, and unmaintained.
Scripts are typically installed by putting them in the {{ic|~/.config/mpv/scripts/}} directory (you may have to create it first). After that they will be automatically loaded when mpv starts (this behavior can be altered with other mpv options). Some scripts come with their own installation and configuration instructions, so make sure to have a look. In addition some scripts are old, broken, and unmaintained.
Line 157: Line 159:
== Vapoursynth ==
== Vapoursynth ==


Vapoursynth is an alternative to AviSynth that can be used on Linux and allows for Video manipulation via python scripts. Vapoursynths python scripts can be used as video filters for ''mpv''.
Vapoursynth is an alternative to AviSynth that can be used on Linux and allows for Video manipulation via python scripts. Vapoursynths python scripts can be used as video filters for mpv.


To use vapoursynth filters you have to install the {{Pkg|vapoursynth}} package (or {{AUR|vapoursynth-git}}) and compile ''mpv'' with the {{ic|--enable-vapoursynth}} build flag.
To use vapoursynth filters you have to install the {{Pkg|vapoursynth}} package (or {{AUR|vapoursynth-git}}) and compile mpv with the {{ic|--enable-vapoursynth}} build flag.


This is easier to do by first installing Vapoursynth and then installing (or re-installing if it's already installed) {{AUR|mpv-git}}. The configure script for {{AUR|mpv-git}} will auto-detect Vapoursynth (as long as it has already been installed) and it will automatically compile mpv with support for Vapoursynth without having to manually change any configure options or anything (this makes it very easy to update mpv as well).
This is easier to do by first installing Vapoursynth and then installing (or re-installing if it's already installed) {{AUR|mpv-git}}. The configure script for {{AUR|mpv-git}} will auto-detect Vapoursynth (as long as it has already been installed) and it will automatically compile mpv with support for Vapoursynth without having to manually change any configure options or anything (this makes it very easy to update mpv as well).
Line 201: Line 203:
{{Note|The main difference between hardware decoding and software decoding is that in software decoding the file will be decompressed and then moved onto the video card whereas with hardware decoding it will be moved to the video card first and then decompressed. In either case, video ''playback'' will still be hardware accelerated via the video card.}}
{{Note|The main difference between hardware decoding and software decoding is that in software decoding the file will be decompressed and then moved onto the video card whereas with hardware decoding it will be moved to the video card first and then decompressed. In either case, video ''playback'' will still be hardware accelerated via the video card.}}


Unlike ''mplayer'' and ''mplayer2'', ''mpv'' has both VA-API and VDPAU support built-in. To enable it, run ''mpv'' with the {{ic|1=--hwdec='method'}} option. You can find list of all available methods looking in the {{man|1|mpv}} manual. To make this persistent, add the line {{ic|1=hwdec=''method''}} to your configuration file. If hardware decoding cannot be used, ''mpv'' will automatically fall back to software decoding.
Unlike mplayer and mplayer2, mpv has both VA-API and VDPAU support built-in. To enable it, run ''mpv'' with the {{ic|1=--hwdec='method'}} option. You can find list of all available methods looking in the {{man|1|mpv}} manual. To make this persistent, add the line {{ic|1=hwdec=''method''}} to your configuration file. If hardware decoding cannot be used, mpv will automatically fall back to software decoding.


The default video output driver, {{ic|gpu}}, is the preferred video output driver and all others are offered only for compatibility purposes. If one encounters problems they may choose to use either {{ic|1=vo=vdpau}} (if using {{ic|1=hwdec=vdpau}}) or {{ic|1=vo=vaapi}} (if using {{ic|1=hwdec=vaapi}}) instead. This can affect the framedrop code used and cause other small differences.
The default video output driver, {{ic|gpu}}, is the preferred video output driver and all others are offered only for compatibility purposes. If one encounters problems they may choose to use either {{ic|1=vo=vdpau}} (if using {{ic|1=hwdec=vdpau}}) or {{ic|1=vo=vaapi}} (if using {{ic|1=hwdec=vaapi}}) instead. This can affect the framedrop code used and cause other small differences.
Line 213: Line 215:
Because GNOME in Wayland mode also runs an Xorg server, video acceleration will fail with {{ic|1=[vaapi] libva: va_getDriverName() failed with unknown libva error,driver_name=(null)}}.
Because GNOME in Wayland mode also runs an Xorg server, video acceleration will fail with {{ic|1=[vaapi] libva: va_getDriverName() failed with unknown libva error,driver_name=(null)}}.


To make ''mpv'' use the Wayland compositor, add the mpv option {{ic|1=opengl-backend=wayland}}[https://github.com/01org/intel-vaapi-driver/issues/203#issuecomment-311299852]. Note however that this will prevent the display of window decorations (titlebar and border).
To make mpv use the Wayland compositor, add the {{ic|1=--opengl-backend=wayland}} option. However this will prevent the display of window decorations, see [https://github.com/01org/intel-vaapi-driver/issues/203#issuecomment-311299852].


=== Save position on quit ===
=== Save position on quit ===
Line 227: Line 229:


=== Play a DVD ===
=== Play a DVD ===
To start the main stream of a video DVD, use the command:
To start the main stream of a video DVD, use the command:
  $ mpv dvd://
  $ mpv dvd://
Line 243: Line 246:
=== Draw to the root window ===
=== Draw to the root window ===


Run ''mpv'' with {{ic|1=--wid=0}}. ''mpv'' will draw to the window with a window ID of 0.
Run ''mpv'' with {{ic|1=--wid=0}}. mpv will draw to the window with a window ID of 0.


=== Always show GUI ===
=== Always show GUI ===


It may be useful to always show the GUI window, even for audio files, especially when ''mpv'' is not started from terminal. This can be done by using {{ic|--force-window}} option.
It may be useful to always show the GUI window, even for audio files, especially when mpv is not started from terminal. This can be done by using {{ic|--force-window}} option.


=== Hide GUI for video files ===
=== Hide GUI for video files ===
Line 255: Line 258:
=== Restoring old OSC ===
=== Restoring old OSC ===


Since version 0.21.0, ''mpv'' has replaced the on-screen controls by a bottombar. In case you want on-screen controls back, you can edit the ''mpv'' configuration [https://github.com/mpv-player/mpv/wiki/FAQ#i-want-the-old-osc-back as described here].
Since version 0.21.0, mpv has replaced the on-screen controls by a bottombar. In case you want on-screen controls back, you can edit the mpv configuration [https://github.com/mpv-player/mpv/wiki/FAQ#i-want-the-old-osc-back as described here].


=== Use as a browser plugin ===
=== Use as a browser plugin ===


With the help of {{AUR|mozplugger}}, ''mpv'' can be used in a supported browser to play video. See [[Browser plugins#MozPlugger]] for configuration details. This coupled with a user script such as [http://isebaro.com/viewtube/?ln=en ViewTube], allows you to use ''mpv'' in place of a site's integrated video player.
With the help of {{AUR|mozplugger}}, mpv can be used in a supported browser to play video. See [[Browser plugins#MozPlugger]] for configuration details. This coupled with a user script such as [http://isebaro.com/viewtube/?ln=en ViewTube], allows you to use mpv in place of a site's integrated video player.


It may be needed to specify a valid user agent for HTTP streaming, e.g. {{ic|1=user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"}}.
It may be needed to specify a valid user agent for HTTP streaming, e.g. {{ic|1=user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"}}.
Line 267: Line 270:
=== Improving mpv as a music player with Lua scripts ===
=== Improving mpv as a music player with Lua scripts ===


The development of ''mpv'''s Lua scripts are documented in [https://github.com/mpv-player/mpv/blob/master/DOCS/man/lua.rst DOCS/man/lua.rst]
The development of mpv's Lua scripts are documented in [https://github.com/mpv-player/mpv/blob/master/DOCS/man/lua.rst DOCS/man/lua.rst]
and examples are shown in [https://github.com/mpv-player/mpv/tree/master/TOOLS/lua TOOLS/lua]
and examples are shown in [https://github.com/mpv-player/mpv/tree/master/TOOLS/lua TOOLS/lua]
of the [https://github.com/mpv-player/mpv mpv repository].
of the [https://github.com/mpv-player/mpv mpv repository].
Line 276: Line 279:
=== Twitch.tv streaming over mpv ===
=== Twitch.tv streaming over mpv ===


If [[youtube-dl]] is installed, ''mpv'' can directly open a Twitch livestream.
If [[youtube-dl]] is installed, mpv can directly open a Twitch livestream.


Alternatively, see [[Streamlink#Twitch]].
Alternatively, see [[Streamlink#Twitch]].
Line 316: Line 319:
=== General debugging ===
=== General debugging ===


If you are having trouble with ''mpv'''s playback (or if it's flat out failing to run) then the first three things you should do are:
If you are having trouble with mpv's playback (or if it's flat out failing to run) then the first three things you should do are:
 
# Run ''mpv'' from the command line (the -v flag increases verbosity). If you are lucky there will be an error message there telling you what is wrong.<br>{{ic|$ mpv -v video.mkv}}
# Run ''mpv'' from the command line (the -v flag increases verbosity). If you are lucky there will be an error message there telling you what is wrong.<br>{{ic|$ mpv -v video.mkv}}
# Have ''mpv'' output a log file. The log file might be difficult to sift through but if something is broken you might see it there.<br>{{ic|1=$ mpv -v --log-file=./log video.mkv}}
# Have mpv output a log file. The log file might be difficult to sift through but if something is broken you might see it there.<br>{{ic|1=$ mpv -v --log-file=./log video.mkv}}
# Run ''mpv'' without a configuration. If this runs well then the problem is somewhere in your configuration (perhaps your hardware cannot keep up with your settings).<br>{{ic|$ mpv --no-config video.mkv}}
# Run ''mpv'' without a configuration. If this runs well then the problem is somewhere in your configuration (perhaps your hardware cannot keep up with your settings).<br>{{ic|$ mpv --no-config video.mkv}}


Line 355: Line 359:
=== GNOME Blank screen (Wayland) ===
=== GNOME Blank screen (Wayland) ===


''mpv'' may not suspend GNOME's Power Saving Settings if using Wayland resulting in screen saver turning off the monitor during video playback. A workaround is to add {{ic|gnome-session-inhibit}} to the beginning of the {{ic|1=Exec=}} line in {{ic|mpv.desktop}}.
mpv may not suspend GNOME's Power Saving Settings if using Wayland resulting in screen saver turning off the monitor during video playback. A workaround is to add {{ic|gnome-session-inhibit}} to the beginning of the {{ic|1=Exec=}} line in {{ic|mpv.desktop}}.


=== Use mpv with a compositor ===
=== Use mpv with a compositor ===


If you are using a compositor (e.g. in KDE Plasma 5) and find that composition is disabled (e.g. in Plasma this would make you unable to present windows or see window thumbnails in the default app switcher) when ''mpv'' is playing a video, try {{ic|1=x11-bypass-compositor=no}}
If you are using a compositor (e.g. in KDE Plasma 5) and find that composition is disabled (e.g. in Plasma this would make you unable to present windows or see window thumbnails in the default app switcher) when mpv is playing a video, try {{ic|1=x11-bypass-compositor=no}}

Revision as of 04:01, 14 October 2018

mpv is a media player based on MPlayer and the now unmaintained mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. A comprehensive (although admittedly incomplete) list of differences between mpv and the aforementioned players can be found here.

Installation

Install the mpv package or mpv-gitAUR for the development version.

Front ends

See List of applications/Multimedia#mpv-based.

Configuration

mpv comes with good all-around defaults that should work well on computers with weaker/older video cards. However, if you have a computer with a more modern video card then mpv allows you to do a great deal of configuration to achieve better video quality (limited only by the power of your video card). To do this one only needs to create a few configuration files (they do not exist by default).

Note: Configuration files are read system-wide from /etc/mpv and per-user from ~/.config/mpv (unless the environment variable XDG_CONFIG_HOME is set), where per-user settings override system-wide settings, all of which are overridden by the command line. User specific configuration is suggested since it may require some trial and error.

To help you get started mpv provides sample configuration files with default settings. Copy them to use as a starting point:

$ cp -r /usr/share/doc/mpv/ ~/.config/

mpv.conf contains the majority of mpv's settings, input.conf contains key bindings. Read through both of them to get an idea of how they work and what options are available.

General settings

Add the following settings to ~/.config/mpv/mpv.conf.

High quality configurations

This loads high quality OpenGL options. Most users can run these without any problems, but they are not enabled by default to avoid causing problems for the few users who cannot run them.

profile=gpu-hq

The gpu-hq profile defaults to the spline36 scaling filter for mid quality and speed. For the best quality video output, the manual states that if your hardware can run it, ewa_lanczossharp is probably what you should use.

profile=gpu-hq
scale=ewa_lanczossharp
cscale=ewa_lanczossharp

These last three options are a little more complicated. The first option makes it so that if audio and video go out of sync then instead of dropping video frames it will resample the audio (a slight change in audio pitch is often less noticeable than dropped frames). The mpv wiki has an in depth article on it titled Display Synchronization. The remaining two essentially make motion appear smoother on your display by changing the way that frames are shown so that the source framerate jives better with your display's refresh rate (not to be confused with SVP's technique which actually converts video to 60fps). The mpv wiki has an in depth article on it titled Interpolation though it is also commonly known as smoothmotion.

profile=gpu-hq
scale=ewa_lanczossharp
cscale=ewa_lanczossharp
video-sync=display-resample
interpolation
tscale=oversample

Beyond this there is still a lot you can do but things become more complicated, require more powerful video cards, and are in constant development. As a brief overview, it is possible to load special shaders that perform exotic scaling and sharpening techniques including some that actually use deep neural networks trained on images (for both real world and animated content). To learn more about this take a look around the mpv wiki, particularly the user shader's section.

There are also plenty of other options you may find desirable as well. It is worthwhile taking a look at mpv(1). It's also helpful to run mpv from the command line to check for error messages about the config.

Profiles

In mpv.conf it is possible to create profiles which are essentially just "groups of options" with which you can:

  • Quickly switch between different configurations without having to rewrite the file.
  • Create special profiles for special content.
  • nest profiles so that you can make more complicated profiles out of simpler ones.

Creating a profile is easy. The area at the top of mpv.conf is called the top level, any options you write there will kick into effect once mpv is started. However, once you define a profile by writing its name in brackets then every option you write below it (until you define a new profile) is considered part of that profile. Here is an example mpv.conf:

profile=myprofile2        #Top level area, load myprofile2
ontop=yes                 #Always on top
[myprofile1]              #A simple profile, top level area ends here
profile-desc="a profile"  #Optional description for profile
fs=yes                    #Start in full screen
[myprofile2]              #Another simple profile
profile=gpu-hq            #A built in profile that comes with mpv
log-file=~~/log           #Sets a location for writing a log file, ~~/ translates to ~/.config/mpv

There are only two lines within the top level area and there are two separate profiles defined below it. When mpv starts it sees the first line, loads the options in myprofile2 (which means it loads the options in gpu-hq and log-file=~~/log) finally it loads ontop=yes and finishes starting up. Note, myprofile1 is never loaded because it's never called in the top level area.

Alternatively one could call mpv from the command line with:

$ mpv --profile=myprofile1 video.mkv

and it would ignore all options except the ones for myprofile1.

Key bindings

Key bindings are fairly straightforward given the examples in /usr/share/doc/mpv/input.conf and the relevant section in the manual.

Add the following examples to ~/.config/mpv/input.conf:

shift+s         screenshot each-frame
Shift+UP        seek  600
Shift+DOWN      seek -600
=               cycle video-unscaled
-               cycle-values window-scale 2 3 1 .5
WHEEL_UP        add volume 5
WHEEL_DOWN      add volume -5
WHEEL_LEFT      ignore
WHEEL_RIGHT     ignore
Alt+RIGHT       add video-rotate 90
Alt+LEFT        add video-rotate -90
Alt+-           add video-zoom -0.25
Alt+=           add video-zoom 0.25
Alt+j           add video-pan-x -0.05
Alt+l           add video-pan-x 0.05
Alt+i           add video-pan-y 0.05
Alt+k           add video-pan-y -0.05
Alt+BS          set video-zoom 0; set video-pan-x 0; set video-pan-y 0

For an attempt to reproduce MPC-HC key bindings in mpv, see [1].

Additional configuration files

In addition there are a few more configuration files and directories that can be created, among which:

  • ~/.config/mpv/script-opts/osc.conf manages the On Screen Controller.
  • ~/.config/mpv/scripts/script-name.lua for Lua scripts. See [2] for an example.

See https://mpv.io/manual/master/#files for more.

Scripts

mpv has a large variety of scripts that extend the functionality of the player. To this end, it has internal bindings for both Lua and JavaScript (added recently).

Scripts are typically installed by putting them in the ~/.config/mpv/scripts/ directory (you may have to create it first). After that they will be automatically loaded when mpv starts (this behavior can be altered with other mpv options). Some scripts come with their own installation and configuration instructions, so make sure to have a look. In addition some scripts are old, broken, and unmaintained.

JavaScript

Since JavaScript support is still fairly new, there is currently very little in the way of scripts, but documentation exists for anyone interested in making their own.

JavaScript support is not available in the mpv build, but it's supported by some AUR packages e.g. mpv-fullAUR and mpv-full-gitAUR.

Lua

There are a lot of interesting Lua scripts for mpv. If you would like to make your own, the relevant documentation may be found here.

mpv-stats

mpv-stats (or simply stats) is a Lua script that outputs a lot of live statistics showing how well mpv is currently doing. It is very useful for making sure that your hardware can keep up with your configuration and for comparing different configurations. Since version v0.28.0, the script is built into mpv and can be toggled on or off with the i or I keys (by default).

mpv-webm

mpv-webm (or simply webm) is a very easy to use Lua script that allows one to create WebM files while watching videos. It includes several features and does not have any extra dependencies (relies entirely on mpv).

C

mpv-mpris

The C plugin mpv-mpris allows other applications to integrate with mpv via the MPRIS protocol. For example, with mpv-mpris installed, kdeconnect can automatically pause video playback in mpv when a phone call arrives.

Install mpv-mprisAUR and follow the post-installation instructions displayed by Pacman.

Vapoursynth

Vapoursynth is an alternative to AviSynth that can be used on Linux and allows for Video manipulation via python scripts. Vapoursynths python scripts can be used as video filters for mpv.

To use vapoursynth filters you have to install the vapoursynth package (or vapoursynth-gitAUR) and compile mpv with the --enable-vapoursynth build flag.

This is easier to do by first installing Vapoursynth and then installing (or re-installing if it's already installed) mpv-gitAUR. The configure script for mpv-gitAUR will auto-detect Vapoursynth (as long as it has already been installed) and it will automatically compile mpv with support for Vapoursynth without having to manually change any configure options or anything (this makes it very easy to update mpv as well).

SVP 4 Linux (SmoothVideoProject)

SmoothVideoProject SVP is a program that's primarily known for converting video to 60fps. It's free [as in beer] and full featured for 64bit Linux (costs money for Windows and OS X and is incompatible with 32bit Linux).

It has three main features and each one can be disabled/enabled as one chooses (you are not forced to use motion interpolation).

  1. Motion interpolation (youtube video) - An algorithm that converts video to 60fps. This creates the somewhat controversial "soap opera effect" that some people love and others hate. Unfortunately the algorithm is not perfect and it also introduces more than its share of weird artifacts. The algorithm can be tuned (via a slider) for either performance or quality. It also has some artifact reduction settings that interpolate actual frames with the generated frames reducing the noticeability of the artifacts. The framerate detection can be set to automatic or manual (manual seems to resolve performance issues for some users).
  2. Black bar lighting (youtube video) - If the image has an aspect ratio that produces black bars on your display then SVP will illuminate the black bars with "lights" generated by the content on the screen. It has some amount of customization but the defaults are pretty close to optimal.
  3. LED ambient lighting control (youtube video) - Has the ability to control LED ambient lighting attached to your television.

Once you have mpv compiled with Vapoursynth support it's fairly easy to get SVP working with mpv. Simply install svpAUR, open the SVP program to let it assess your system performance (you may want to close other programs first so that it gets an accurate reading), and finally add the following mpv profile to your mpv.conf (taken from here):

mpv.conf
[svp]
input-ipc-server=/tmp/mpvsocket     # Receives input from SVP
hr-seek-framedrop=no                # Fixes audio desync
resume-playback=no                  # Not compatible with SVP

# Can fix stuttering in some cases, in other cases probably causes it. Try it if you experience stuttering.
#opengl-early-flush=yes

Then, in order to use SVP you must have the SVP program running in the background before opening the file using mpv with that profile. Either do:

$ mpv --profile=svp video.mkv

or set profile=svp in the top-level portion of the mpv config.

If you want to use hardware decoding then you must use a copy-back decoder since normal decoders are not compatible with Vapoursynth (choose a hwdec option that ends in -copy). For instance:

hwdec=auto-copy
hwdec-codecs=all

Either way, hardware decoding is discouraged by mpv devs and is not likely to make a significant difference in performance.

Tips and Tricks

Hardware decoding

See Hardware video acceleration.

Warning: Hardware decoding is known to sometimes cause problems and as such it is considered "usually a bad idea unless absolutely needed" by the developers. For that reason and because it typically offers very similar performance to software decoding it is disabled by default. Moreover, depending on the video card, drivers installed, and file being decoded hardware decoding may perform differently or may not even be used at all leading to inconsistent behavior that can be difficult to debug.
Note: The main difference between hardware decoding and software decoding is that in software decoding the file will be decompressed and then moved onto the video card whereas with hardware decoding it will be moved to the video card first and then decompressed. In either case, video playback will still be hardware accelerated via the video card.

Unlike mplayer and mplayer2, mpv has both VA-API and VDPAU support built-in. To enable it, run mpv with the --hwdec='method' option. You can find list of all available methods looking in the mpv(1) manual. To make this persistent, add the line hwdec=method to your configuration file. If hardware decoding cannot be used, mpv will automatically fall back to software decoding.

The default video output driver, gpu, is the preferred video output driver and all others are offered only for compatibility purposes. If one encounters problems they may choose to use either vo=vdpau (if using hwdec=vdpau) or vo=vaapi (if using hwdec=vaapi) instead. This can affect the framedrop code used and cause other small differences.

For VA-API hardware decoding with vo=gpu enable EGL with the gpu-context=x11egl option or use vaapi video output driver vo=vaapi instead.

Even with hardware decoding enabled, it will only be used for some codecs by default. In order to use hardware decoding with all codecs set hwdec-codecs=all. It is also possible to specify an exact list of codecs for which you want hardware decoding to be used (provided it has been enabled) by setting --hwdec-codecs=h264,mpeg2video.

In GNOME Wayland

Because GNOME in Wayland mode also runs an Xorg server, video acceleration will fail with [vaapi] libva: va_getDriverName() failed with unknown libva error,driver_name=(null).

To make mpv use the Wayland compositor, add the --opengl-backend=wayland option. However this will prevent the display of window decorations, see [3].

Save position on quit

By default you can save the position and quit by pressing Shift+q. The shortcut can be changed by setting quit_watch_later in the key bindings configuration file.

To automatically save the current playback position on quit, start mpv with --save-position-on-quit, or add save-position-on-quit to the configuration file.

Volume is too low

Set volume-max=value in your configuration file to a reasonable amount, such as volume-max=150, which then allows you to increase your volume up to 150%, which is more than twice as loud. Increasing your volume too high will result in clipping artefacts. Additionally (or alternatively), you can utilize dynamic range compression with af=acompressor.

Play a DVD

To start the main stream of a video DVD, use the command:

$ mpv dvd://

Install libdvdcss, to fix the error:

[dvdnav] Error getting next block from DVD 1 (Error reading from DVD.)

Quickly cycle between aspect ratios

You can cycle between aspect ratios using Shift+a.

Ignoring aspect ratio

You can ignore aspect ratio using --keepaspect=no. To make option permanent, add line keepaspect=no to configuration file.

Draw to the root window

Run mpv with --wid=0. mpv will draw to the window with a window ID of 0.

Always show GUI

It may be useful to always show the GUI window, even for audio files, especially when mpv is not started from terminal. This can be done by using --force-window option.

Hide GUI for video files

It may be useful to hide the GUI window for video files. This can be done by using --no-video option.

Restoring old OSC

Since version 0.21.0, mpv has replaced the on-screen controls by a bottombar. In case you want on-screen controls back, you can edit the mpv configuration as described here.

Use as a browser plugin

With the help of mozpluggerAUR, mpv can be used in a supported browser to play video. See Browser plugins#MozPlugger for configuration details. This coupled with a user script such as ViewTube, allows you to use mpv in place of a site's integrated video player.

It may be needed to specify a valid user agent for HTTP streaming, e.g. user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0".

Browser plugins#Multimedia playback page shows other easy ways to watch videos.

Improving mpv as a music player with Lua scripts

The development of mpv's Lua scripts are documented in DOCS/man/lua.rst and examples are shown in TOOLS/lua of the mpv repository. This blog post introduces the music.lua script, which shows how Lua scripts can be used to improve mpv as a music player.

Twitch.tv streaming over mpv

If youtube-dl is installed, mpv can directly open a Twitch livestream.

Alternatively, see Streamlink#Twitch.

Another alternative based on Livestreamer is this Lua script: https://gist.github.com/ChrisK2/8701184fe3ea7701c9cc

youtube-dl and choosing formats

The default --ytdl-format is bestvideo+bestaudio/best. For youtube videos that have 4K resolutions available, this may mean that your device will struggle to decode 4K VP9 encoded video in software even if the attached monitor is much lower resolution.

Setting the right youtube-dl format selectors can fix this easily though. In the following configuration example, only videos with a vertical resolution of 1080 pixels or less will be considered.

ytdl-format=bestvideo[height<=?1080]+bestaudio/best

If you wish to avoid a certain codec altogether because you cannot hardware-decode it, you can add this to the format selector. For example, we can additionally choose to ignore VP9 as follows:

ytdl-format=bestvideo[height<=?1080][vcodec!=vp9]+bestaudio/best

If you prefer best quality open codecs (VP9 and Opus), use:

ytdl-format="((bestvideo[vcodec^=vp9]/bestvideo)+(bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio[acodec=aac]/bestaudio))/best"

youtube-dl audio with search

To find and stream audio from your terminal emulator with yta "search terms" put the following function in your .bashrc:

function yta() {
    mpv --ytdl-format=bestaudio ytdl://ytsearch:"$@"
}

Creating a single screenshot

An example of creating a single screenshot, by using a start time (HH:MM:SS):

$ mpv --no-audio --start=00:01:30 --frames=1 /path/to/video/file --o=/path/to/screenshot.png

Screenshots will be saved in /path/to/screenshot.png.

Troubleshooting

General debugging

If you are having trouble with mpv's playback (or if it's flat out failing to run) then the first three things you should do are:

  1. Run mpv from the command line (the -v flag increases verbosity). If you are lucky there will be an error message there telling you what is wrong.
    $ mpv -v video.mkv
  2. Have mpv output a log file. The log file might be difficult to sift through but if something is broken you might see it there.
    $ mpv -v --log-file=./log video.mkv
  3. Run mpv without a configuration. If this runs well then the problem is somewhere in your configuration (perhaps your hardware cannot keep up with your settings).
    $ mpv --no-config video.mkv

If mpv runs but it just does not run well then a fourth thing that might be worth taking a look at is installing the mpv-stats script and using it to see exactly how it's performing.

Fix jerky playback and tearing

mpv defaults to using the OpenGL video output device setting on hardware that supports it. In cases such as trying to play video back on a 4K display using a Intel HD4XXX series card or similar, you will find video playback unreliable, jerky to the point of stopping entirely at times and with major tearing when using any opengl output setting. If you experience any of these issues, using the XV (XVideo) video output device may help:

~/.config/mpv/mpv.conf
vo=xv

This VO is deprecated and will cause issues in recent versions of mpv, most noticeably is the osd looking very blurry.

It is possible to increase playback performance even more (especially on lower hardware), but this decreases the video quality dramatically in most cases.

The following options may be considered to increase the video playback performance:

~/.config/mpv/mpv.conf
vd-lavc-fast
vd-lavc-skiploopfilter=<skipvalue>
vd-lavc-skipframe=<skipvalue>
vd-lavc-framedrop=<skipvalue>
vd-lavc-threads=<threads>

Problems with window compositors

Window compositors such as KWin or Mutter can cause trouble for playback smoothness. In such cases, it may help to set x11-bypass-compositor=yes to make mpv also disable window compositing when playing in windowed mode (if supported by the compositor).

With KWin compositing and hardware decoding, you may also want to set x11-bypass-compositor=no to keep compositing enabled in fullscreen, since reanabling compositing after leaving fullscreen may introduce stutter for a period of time.

No volume bar, cannot change volume

Spin the mouse wheel over the volume icon.

GNOME Blank screen (Wayland)

mpv may not suspend GNOME's Power Saving Settings if using Wayland resulting in screen saver turning off the monitor during video playback. A workaround is to add gnome-session-inhibit to the beginning of the Exec= line in mpv.desktop.

Use mpv with a compositor

If you are using a compositor (e.g. in KDE Plasma 5) and find that composition is disabled (e.g. in Plasma this would make you unable to present windows or see window thumbnails in the default app switcher) when mpv is playing a video, try x11-bypass-compositor=no