MPV
MPV is an open-source command line media player known for its high performance, versatility, and minimalist design. It has only a very basic GUI. MPV can be used with a GUI front-end like SMPlayer (package: smplayer), to have a comparable user interface like other media players for the desktop environment.
MPV supports a wide range of video and audio formats, ensuring extensive compatibility. It features advanced video rendering capabilities, including high-quality scaling algorithms, color management, and HDR support, which contribute to superior video playback quality. MPV utilizes hardware-accelerated video decoding through APIs such as VA-API, VDPAU, and DXVA2, enhancing performance and reducing CPU usage. The player’s design emphasizes minimalism and efficiency, offering a streamlined user interface with extensive configurability via command-line options and scripting interfaces.
Installation
Using nix-shell
To use MPV in a temporary environment with nix-shell
, run:
nix-shell -p mpv
System-Wide Installation on NixOS
To install MPV system-wide, add it to your system configuration. Edit your /etc/nixos/configuration.nix
and include MPV in the environment.systemPackages
list:
environment.systemPackages = [
pkgs.mpv
];
After modifying your configuration, apply the changes by running:
sudo nixos-rebuild switch
User-Specific Installation with Home Manager
If you use Home Manager, you can add MPV to your home configuration. Edit your Home Manager configuration file (usually ~/.config/nixpkgs/home.nix
) and include MPV in the home.packages
list:
home.packages = [
pkgs.mpv
];
After updating your configuration, apply the changes by running:
home-manager switch
Configuration
The recommended way to enable and configure MPV on NixOS is through the programs
attribute in your NixOS home configuration.
programs.mpv = {
enable = true;
};
A more comprehensive configuration of MPV would look like this.
{ pkgs, ... }:
{
programs.mpv = {
enable = true;
# Custom package configuration for MPV
package = (
pkgs.mpv-unwrapped.wrapper {
# To find more scripts run this in a terminal: nix search nixpkgs mpvScripts
# The scripts are defined in the following Nixpkgs directory: https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/video/mpv/scripts
scripts = with pkgs.mpvScripts; [
uosc
sponsorblock
];
mpv = pkgs.mpv-unwrapped.override {
# Find more override options in the expression:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/video/mpv/default.nix
waylandSupport = true;
};
}
);
# MPV configuration options
config = {
profile = "high-quality";
ytdl-format = "bestvideo+bestaudio";
cache-default = 4000000;
};
};
}
Error, unknown format
If you get the following sort of error, note that mpv currently uses the small ffmpeg version (ffmpeg_5) instead of the full version (ffmpeg_5-full).
$ mpv --log-file=foo.log av://v4l2:/dev/video5
[lavf] Unknown lavf format v4l2
Failed to recognize file format.
Exiting... (Errors when loading file)
To address this problem, you can use the following package configuration for ffmpeg.
programs.mpv = {
enable = true;
package =
(pkgs.mpv-unwrapped.wrapper {
mpv = pkgs.mpv-unwrapped.override {
ffmpeg = pkgs.ffmpeg-full;
};
});
};