mpv

From LinuxReviews
Jump to navigationJump to search

mpv is the best pure no-fuzz video player for Linux. It will play anything video file you throw at it. It is also available for Windows, MacOS and Android. It is just a video player, it does not have menus or toolbars or things of that nature. Basics controls are available in a on-screen overlay display.

What it is and isn't[edit | edit source]

Mpv-0.29.1.jpg

mpv is a video player which will open a video and play it. It does not have additional features. At all. There is no graphical playlist function, there is no button for open files or network URLs or anything like that. You can open a file using your file manager or a terminal and play it with mpv and that is how you use it. You can play network URLs and playlists with it using those things and command-line arguments.

Moving the mouse above a video playing in mpv makes a on-screen navigational interface appear. It is limited to jumping to a specific time on a timeline, play, pause, volume and mute, toggling subtitles on or off and there is also a fullscreen toggle button. Not that you'll need it, pressing f to toggle fullscreen is quicker.

There are more feature-rich programs like SMPlayer which use mpv for the actual video playback while providing a graphical interface with menus and toolbars and icons.

Installing mpv[edit | edit source]

You will probably have to add a third party repository to your distribution to get (a proper) mpv. That would be rpmfusion in the case of Fedora and CentOS.

Some configuration is recommended[edit | edit source]

mpv is highly configurable using the configuration file $HOME/.config/mpv/mpv.conf and there are a lot of examples of mpv configuration files floating around the Internets. While you strictly do not need to have a mpv.conf you may want to consider using the following examples if you do not have one.

All the examples use hwdec=vaapi. vaapi is Intel technology but it is also the best interface for hardware decoding on AMD graphics because vdpau can not do 10-bit HEVC video and vaapi can.

mpv.conf for older and weak Intel iGPU systems and older AMD APUs, specially older laptops[edit | edit source]

We recommend this configuration file for very weak machines and older laptops:

File: $HOME/.config/mpv/mpv.conf
vo=vaapi
hwdec=vaapi
ao=pulse
video-sync=display-resample
# Limit network video playback to 1080p, do not use VP9
ytdl-format=bestvideo[height<=?1080][vcodec!=?vp9]+bestaudio/best
cache=yes
cache-secs=120

This configuration requests that vaapi is used for both hardware video decoding when available and video output. This is the least possible resource-demanding vo= option. It is more battery-friendly than using vo=gpu. Using vo=vaapi is not recommended unless your hardware is weak enough to warrant it.

mpv.conf for typical Intel iGPU systems and AMD APUs[edit | edit source]

File: $HOME/.config/mpv/mpv.conf
vo=gpu
hwdec=vaapi
# Required for hwdec=vaapi to work when using vo=gpu
gpu-context=x11egl
ao=pulse
# Resample audio to catch up if audio/video go out of sync
video-sync=display-resample
#
# bilinear is fastest and also the lowest quality. 
# spline36 for medium quality/speed. 
# ewa_lanczossharp is best but really resource-demanding
scale=bilinear
cscale=bilinear
#
# Limit network video playback to 1080p, do not use VP9
ytdl-format=bestvideo[height<=?1080][vcodec!=?vp9]+bestaudio/best
cache=yes
cache-secs=120

This is fine for newer desktops and laptops with a Intel iGPU as well as AMD APUs.

mpv.conf for dedicated AMD graphics cards[edit | edit source]

File: $HOME/.config/mpv/mpv.conf
vo=gpu
hwdec=vaapi
# Required for hwdec=vaapi to work when using vo=gpu
gpu-context=x11egl
# Enable High Quality GPU profile
# Run mpv --show-profile=gpu-hq to see what settings
# this activates and --profile=help to see available profiles
profile=gpu-hq
video-sync=display-resample
interpolation
tscale=oversample

# https://bugs.freedesktop.org/show_bug.cgi?id=107666
# hwdec=vdpau
ao=pulse
## Network playback configuration
# No limits on quality, 4k 60fps is fine.
#ytdl-format=bestvideo+bestaudio/best
# For 4k video but not 60fps above 1440p
#ytdl-format=bestvideo[height>=1440][fps<=?30]+bestaudio/bestvideo[height<=?1440]+bestaudio/best
# For 1440p max
#ytdl-format=bestvideo[height<=?1440]+bestaudio/best
cache=yes
cache-secs=240
Blond-anime-girl-with-red-questionmark.png What about the more fancy mpv.conf options in other example configuration files like scale=ewa_lanczossharp, should I use those?

While there is a placebo visual benefit there is also a very real cost. profile=gpu-hq will give you scale=spline36 and cscale=spline36 (and dscale=mitchell). spline36 is visually fine while not being too resource-intensive at 4K. Using ewa_lanczossharp will result in stuttering playing 1440p video on a RX560 and put fairly high load on a RX580 too. Even if you have a high-end GPU, do you really need or want your GPU to be working as if it was running a FPS game, making noise from the fans, when you are just using it to watch a video?

mpv.conf files for Windows[edit | edit source]

See the dedicated page Mpv configuration for Windows.

Input configuration[edit | edit source]

mpv has some features which do not have any default key-bindings. It is possible to configure (a lot) more keyboard shortcuts using a configuration file called input.conf in $HOME/.config/mpv.

It could look like this:

File: $HOME/.config/mpv/input.conf
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
n cycle interpolation
ctrl+f vf toggle hflip
alt+f vf toggle vflip
ctrl+r cycle_values video-rotate "90" "180" "270" "0"

Expanding mpv with javascript and/or lua userscripts[edit | edit source]

It is possible to expand mpv's functionality with userscripts. These can add useful features like playlist management, automatic cropping of black bars when detected and much, much more. There are a lot of userscripts available at https://github.com/mpv-player/mpv/wiki/User-Scripts

Links[edit | edit source]

* mpv's homepage is at https://mpv.io/ * There is a mpv keyboard-shortcut cheat-sheet at https://i.imgur.com/LNGJf4u.png * you can read the fine manual at https://man.linuxreviews.org/man1/mpv.1.html

Video players: SMPlayer | mpv | VLC | GNOME Videos :discontinued: Xine | GMPlayer | MPlayer Stand-alone Audio players: :Filesystem-oriented: Audacious :Database-oriented: Elisa | Strawberry | Exaile | GNOME Music
: Bankrupt and finished: Clementine | Amarok Music Player Daemon audio player clients: :GUI: Cantata | GMPC : ncurses: ncmpc - Command-line: mpc : Dead and berried: Sonata | KMP | Glurp