How To Use mpv – CLI Media Player

There are no shortage of media players for Linux. The majority of Linux distributions come with at least one player pre-installed and offer a few more in the repositories. One of the most popular open source media players is Mplayer, a command-line application with several graphical front-ends (SMPlayer is one of them). It’s a powerful app that supports many audio and video formats, as well as capturing video and audio output, saving streamed content to a file, decoding subtitles, and transcoding (converting) between formats.

Mplayer was previously forked into mplayer2 which brought upgrades and new features, but it’s no longer actively developed. Luckily, a new fork emerged, and it’s called mpv. This media player is free, open source and cross-platform. It brings many configuration options, optimized and cleaned-up code, and the ability to convert multimedia files directly in the player.

Mpv can be installed on Windows, OS X and Linux. The official website offers packages for download, and if your distribution is not supported, you can obtain the source and compile it.

Mpv is a command-line application. To start using it, simply type the following command in the terminal:

mpv (options) filename

To play a single audio file, just navigate to it (or enter the full path) and type its name after mpv to play it. You can control mpv with keyboard shortcuts; for example, pressing Space pauses a song, arrow keys rewind it backward or forward, and / and * keys control the volume. The full list of mpv keyboard shortcuts can be found in the user manual.

To play all media files in a folder, just write the folder name followed by an * sign:

If you want to randomize the order in which they’re played, just add the --shuffle option:

mpv --shuffle/folder-path/*

Mpv also supports different kinds of playlists, and you can load a playlist with the command:

mpv --playlist=filename.pls

To activate the gapless audio option, add the --gapless-audio flag.

mpv --gapless-audio--playlist=filename.pls

When you want to keep mpv opened even after it’s finished playing, use either --idle or --keep-open.

User Settings

Adding all these options every time you use mpv might be impractical. The solution is to edit the configuration file to customize mpv according to your needs. The settings for each user are saved in “/home/$USER/.mpv/config”, while those affecting the whole system go into “/etc/mpv”. User-specific settings have priority over the system-wide ones, so you only have to edit the configuration file for your user.

Lines starting with # are commented, which means that these options are disabled. To enable them, simply remove the # symbol and save changes. To add options which are not listed, write them each in a separate line according to the following scheme:

You can also create separate configuration files for audio and video files. For example, if you have a film (with name “film1.avi”) which you want to play in fullscreen and without sound, you could create a file called “film1.avi.conf” and save it in your “/home/$USER/.mpv” folder with options --no-audio and --fullscreen enabled.

When playing video files, mpv has a small graphical control area called the OSD bar. You can disable it with the --no-osd-bar or --osd-level=0 flag, and customize its font, size, color and position in the mpv configuration file.

It’s possible to make mpv behave like a GUI application by always displaying the video window, even when playing audio-only files. This is done using the --force-window option. To prevent other windows from stealing mpv’s focus, you can use the --ontop option.

Although it looks different from other media players, mpv stacks up to your “regular” player. You can use it to tune into TV and radio channels, stream content directly from the Internet and apply various audio and video filters (for example, remove a TV station logo, rotate or mirror the screen…). The learning curve might be too much for some users, but mpv is worth trying, because it’s quick, lightweight and feature-packed.

Related Ebooks

3 comments

Excellent review of mpv player! So many mplayer(2) forks, so little time …

I have been using mpv player for a quite some time and I love it. On OS X and Linux it is my default player. On Windows I alternate between PotPlayer (Zetro Skin) and mpv.

NOTE: don’t be afraid of the command line options.

Even at default settings mvp is configured to give HQ OpenGL output. Instead of using command line (on all three platforms) just choose media file and select mpv as default player. From then on, just double click media file and play as normal.

mpv is in very active development and given the fact that it is based on ffmpeg, gives you great re-assurance of continuous improvements.

mpv might seem a bit overwhelming at first, especially to those who have no experience with a CLI media player, but it doesn’t take long to get used to it (at least in my opinion), and in the end it’s totally worth the time. A powerful piece of software, really. I’m glad you like it! :)