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-env
To install mpv using nix-env
, execute the following command:
nix-env -iA nixos.mpv
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.
programs.mpv = {
enable = true;
# Custom package configuration for MPV
package =
(pkgs.mpv-unwrapped.wrapper {
mpv = pkgs.mpv-unwrapped.override {
waylandSupport = true;
x11Support = false;
cddaSupport = false;
vulkanSupport = false;
drmSupport = false;
archiveSupport = false;
bluraySupport = true;
bs2bSupport = false;
cacaSupport = false;
cmsSupport = false;
dvdnavSupport = false;
dvbinSupport = false;
jackaudioSupport = false;
javascriptSupport = false;
libpngSupport = false;
openalSupport = false;
pulseSupport = false;
pipewireSupport = true;
rubberbandSupport = false;
screenSaverSupport = false;
sdl2Support = true;
sixelSupport = false;
speexSupport = false;
swiftSupport = false;
theoraSupport = false;
vaapiSupport = true;
vapoursynthSupport = false;
vdpauSupport = true;
xineramaSupport = false;
xvSupport = false;
zimgSupport = false;
};
})
.override {
scripts = with pkgs.mpvScripts; [
uosc
sponsorblock
];
};
# MPV configuration options
config = {
profile = "high-quality";
ytdl-format = "bestvideo+bestaudio";
cache-default = 4000000;
};
};
Finding MPV Scripts
You can find additional scripts for MPV under the mpvScripts
attribute. To search for available scripts, use the following command:
nix search nixpkgs mpvScripts
The scripts are defined in the following Nixpkgs directory:
pkgs/applications/video/mpv/scripts
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;
};
});
};