keepcalculator

06 Numbers and Powers

MPV CLI Media Player: What It Is & How to Use It

Card No. 06·79906 · Updated · Standard formula, shown below

MPV is a free, open-source command-line media player that plays video and audio files with high quality and minimal interface. You control it by typing commands and using keyboard shortcuts, not by clicking buttons, making it a favorite among power users and scripters. This article explains what makes MPV different, how to install and use it, and how to solve common problems.

What Is MPV?

MPV is a media player based on the older MPlayer and mplayer2 projects. It is a command-line program, meaning you launch it from a terminal or by typing a command, and it opens a video window. Unlike VLC or Windows Media Player, MPV has no built-in graphical interface for menus or settings. Instead, you control playback through keyboard shortcuts, configuration files, and command-line options. This design makes it extremely fast, lightweight, and scriptable, which is why it is often embedded in other software or used on servers.

Key Features and Why People Choose It

MPV is known for its excellent video quality and broad format support. It uses the FFmpeg libraries to decode almost any media file, including MKV, MP4, AVI, FLAC, and even streaming protocols like HLS and DASH. It also has a built-in high-quality video scaler and supports color management, making it a popular choice for watching high-resolution content. Another major advantage is its scriptability: you can write Lua scripts to add custom keybindings, automate tasks, or integrate MPV with other tools. For example, you can create a script that automatically skips intro sequences or downloads subtitles.

How to Install MPV

Installation is straightforward on most operating systems:

  • Windows: Download the installer from the official MPV website or use a package manager like Chocolatey or winget.
  • macOS: Install via Homebrew with the command brew install mpv, or download a pre-built binary.
  • Linux: Use your distribution’s package manager, e.g., sudo apt install mpv on Debian/Ubuntu, or sudo dnf install mpv on Fedora.

After installation, you can start MPV by typing mpv followed by a file path or URL in the terminal.

Basic Usage and Common Commands

To play a file, simply run:

mpv /path/to/video.mp4

You can also play multiple files or a playlist:

mpv file1.mp4 file2.mp4

For streaming, just pass the URL:

mpv https://example.com/stream.m3u8

Once playing, use keyboard shortcuts to control playback. The most common ones are:

  • Space – Play/Pause
  • Left/Right arrows – Seek backward/forward by 5 seconds
  • Up/Down arrows – Seek by 60 seconds
  • f – Toggle fullscreen
  • m – Mute
  • q – Quit

You can see all keybindings by pressing ? while MPV is running.

Configuration and Customization

MPV uses a configuration file to set default options. On Linux and macOS, the file is located at ~/.config/mpv/mpv.conf; on Windows, it is %APPDATA%\mpv\mpv.conf. You can put any command-line option in this file, one per line, to make it the default. For example, to always start in fullscreen and use the hardware video decoder, you could write:

fullscreen=yes
hwdec=auto

You can also create a input.conf file to remap keys. For instance, to make the n key skip to the next file, add:

n playlist_next

This flexibility is what attracts many users to MPV.

Common Problems and How to Fix Them

New users often run into a few issues:

  • No video window opens: This usually means the file is not found or the path is wrong. Check the path and ensure the file exists.
  • No audio: Try setting --ao=alsa on Linux or --ao=wasapi on Windows to force a specific audio output driver.
  • Hardware acceleration not working: Use --hwdec=auto to let MPV pick the best decoder, or specify your GPU type, e.g., --hwdec=cuda for NVIDIA.
  • Subtitles not showing: Ensure the subtitle file has the same name as the video and is in the same folder, or load it manually with --sub-file=subs.srt.

If you encounter a specific error, running mpv --verbose will print detailed logs that can help diagnose the issue.

MPV vs. VLC: Which Should You Use?

VLC is the go-to for most users because it has a full graphical interface and plays everything out of the box. MPV is lighter, faster, and more scriptable, but requires learning command-line usage. If you want a simple, click-and-play experience, VLC is better. If you are comfortable with the terminal and want a player that fits into your workflow, MPV is worth the learning curve. Many users keep both installed.

Is MPV Safe?

Yes, MPV is safe. It is open-source, widely audited, and has no ads or bundled software. However, like any media player, it can process malicious files, so always download media from trusted sources. Also, be cautious when using scripts from the internet; only use scripts from reputable sources.

Frequently Asked Questions

How do I play a video in a loop?

Use the --loop-file=inf option, or simply press Shift+L during playback to toggle looping.

Can I use MPV to stream YouTube videos?

Yes, MPV can play YouTube URLs directly if you have youtube-dl or yt-dlp installed. MPV will automatically use them to extract the stream URL.

How do I take a screenshot with MPV?

Press s to take a screenshot of the current frame. The image is saved in the current directory (or the folder specified by --screenshot-directory).

Why does MPV not show album art for audio files?

MPV is a video player first; it does not display embedded album art by default. You can enable it with the --audio-display=attachment option.

How do I make MPV remember playback position?

Add save-position-on-quit to your mpv.conf file. MPV will then resume from where you stopped when you open the same file again.

Can I control MPV with a game controller?

Yes, MPV supports input from gamepads via the --input-gamepad option, but it requires the cplayer Lua script to be enabled.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →