208.1. mpv-0.41.0
Command-line media player for Wayland, with no toolkit
| Version | 0.41.0, release 2 |
| Shelf | video-players — Video players and media centres, and their front-end add-ons |
| Phase | 42_graphics (Graphics Stack), 171 of 189 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://mpv.io/ |
| Build time | 0.9 SBU |
| Installed size | 7.0 MiB in 31 files |
| Recipe | ports/core/video-players/mpv/kpkgbuild |
About
mpv is a media player with no toolkit: it draws video with its own GPU renderer straight onto a Wayland surface, and its controls, statistics overlay and console are Lua scripts built into the binary. The port also builds libmpv, the playback engine that front ends such as haruna draw their windows around (smplayer runs the mpv program itself inside its window instead), and loads C plugins such as mpv-mpris, which puts mpv on the session bus for the media keys and the panel.
Nearly every optional part is named on or off. A meson feature left at auto is built when its library happens to be in the build root, so naming each one keeps the player the same on every build and turns a missing library into a failed configure.
Why it is in KDOS
The comment above it in script/phases/42_graphics/packages.d/video-players.txt:
A media player that needs NO toolkit — it draws with its own renderer straight onto a Wayland surface, so it plays on the lightest machine, and libmpv is the engine toolkit front ends draw over.
Sources
mpv-0.41.0.tar.gz(6.9 MiB)
sha256ee21092a5ee427353392360929dc64645c54479aefdb5babc5cfbb5fad626209
upstream: https://github.com/mpv-player/mpv/archive/refs/tags/v0.41.0.tar.gz
archive copy: sources-4/video-players--mpv-0.41.0.tar.gz
Dependencies
Depends on: meson, ninja, pkgconf, python3, ffmpeg, wayland, wayland-protocols, libxkbcommon, mesa, alsa-lib, pipewire, libass, lcms2, libdrm, libplacebo, libdisplay-info, libsixel, libarchive, python3-docutils, libva, vulkan-loader, vulkan-headers, luajit, rubberband, zimg, libjpeg-turbo, zlib, uchardet, libbluray, libdvdnav, libcdio, libcdio-paranoia, libX11, libXext, libXfixes, libXpresent, libXrandr, libXScrnSaver, yt-dlp.
Required by (8): celluloid, haruna, kalarm, mpv-mpris, mpvqt, plasmatube, smplayer, uosc.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
-Dxv=disabled, line 26: libXv-Dshaderc=disabled, line 37: shaderc (explained with the switches below)-Dopenal=disabled, line 50: openal-soft
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install mpv'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/video-players/mpv.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/video-players/mpv
echo 'ee21092a5ee427353392360929dc64645c54479aefdb5babc5cfbb5fad626209 mpv-0.41.0.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/mpv
SRC=$SRC_ROOT/mpv-0.41.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mpv-0.41.0.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
meson setup build \
--prefix=/usr \
--libdir=lib \
--buildtype=release \
-Dlibmpv=true \
-Dcplayer=true \
-Dbuild-date=false \
-Dcplugins=enabled \
-Dx11=enabled \
-Degl-x11=enabled \
-Dgl-x11=disabled \
-Dvaapi-x11=disabled \
-Dvdpau=disabled \
-Dvdpau-gl-x11=disabled \
-Dxv=disabled \
-Dx11-clipboard=enabled \
-Dwayland=enabled \
-Dgl=enabled \
-Degl=enabled \
-Degl-wayland=enabled \
-Degl-drm=enabled \
-Dgbm=enabled \
-Ddmabuf-wayland=enabled \
-Ddrm=enabled \
-Dvulkan=enabled \
-Dshaderc=disabled \
-Dspirv-cross=disabled \
-Dvaapi=enabled \
-Dvaapi-drm=enabled \
-Dvaapi-wayland=enabled \
-Dcuda-hwaccel=disabled \
-Dcuda-interop=disabled \
-Dcaca=disabled \
-Dsixel=enabled \
-Dalsa=enabled \
-Dpipewire=enabled \
-Dpulse=disabled \
-Djack=enabled \
-Dopenal=disabled \
-Dsndio=disabled \
-Doss-audio=disabled \
-Dsdl2-audio=disabled \
-Dsdl2-video=disabled \
-Dsdl2-gamepad=disabled \
-Dlua=luajit \
-Djavascript=disabled \
-Drubberband=enabled \
-Dzimg=enabled \
-Djpeg=enabled \
-Dzlib=enabled \
-Diconv=enabled \
-Duchardet=enabled \
-Dlibavdevice=enabled \
-Dlibarchive=enabled \
-Dlcms2=enabled \
-Dlibbluray=enabled \
-Ddvdnav=enabled \
-Dcdda=enabled \
-Ddvbin=enabled \
-Dvapoursynth=disabled \
-Dmanpage-build=enabled
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
install -d "$PKG/etc/mpv"
cat > "$PKG/etc/mpv/mpv.conf" <<'CONF'
gpu-sw=yes
CONF
chmod 644 "$PKG/etc/mpv/mpv.conf"
The switches, and why each is set:
-Dlibmpv=true,-Dcplayer=true— Build both the shared library and thempvprogram.-Dbuild-date=false— Leave the compile time out of the binary, which otherwise makes two builds of the same source differ (Reproducible packages).-Dcplugins=enabled— Load C plugins from~/.config/mpv/scriptsand the system script directory; mpv-mpris is one.-Dwayland=enabled,-Dgl=enabled,-Degl=enabled,-Degl-wayland=enabled— The Wayland output and OpenGL through Mesa’s EGL on it, the default path on the desktop.-Degl-drm=enabled,-Dgbm=enabled,-Ddrm=enabled— Video straight to the display through KMS, with no compositor running (--vo=gpu --gpu-context=drm, or--vo=drm).-Ddmabuf-wayland=enabled—--vo=dmabuf-wayland, which hands decoded frames to the compositor as DMA-BUFs instead of drawing them.-Dvulkan=enabled— The Vulkan rendering context. The renderer itself is libplacebo, a required dependency built with its Vulkan and OpenGL backends, so--vo=gpu-nextruns on Vulkan where a device answers and on OpenGL through EGL where none does.-Dshaderc=disabled,-Dspirv-cross=disabled— A second GLSL compiler beside the glslang libplacebo uses, and SPIRV-Cross, which is not a port.-Dx11=enabled,-Degl-x11=enabled,-Dx11-clipboard=enabled— A second output for a front end that embeds mpv by X11 window id, as SMPlayer does with--wid; without an X11 output such a front end plays the sound with no picture. The window is drawn with OpenGL through EGL, and the clipboard is the X11 one. The libraries are the X client libraries, served by Xwayland; no X server is involved on the login path (principles).-Dgl-x11=disabled,-Dxv=disabled,-Dvdpau=disabled,-Dvdpau-gl-x11=disabled— GLX, the XVideo output and VDPAU decode, leaving EGL as the only OpenGL route on X11 and VA-API as the only hardware decoder.-Dvaapi-x11=disabled— VA-API on an X11 window, which needs a libva built with its X11 backend; libva is built with-Dwith_x11=no.-Dvaapi=enabled,-Dvaapi-drm=enabled,-Dvaapi-wayland=enabled— Hardware decoding through libva, presented on DRM and on Wayland.-Dcuda-hwaccel=disabled,-Dcuda-interop=disabled— NVIDIA CUDA decoding, whose toolkit is not a port.-Dsixel=enabled—--vo=sixel, video drawn as sixel pictures in a terminal that supports them, Konsole among them. It reaches a terminal where no compositor runs: a serial line, an ssh login or a console terminal. mpv builds its other terminal outputs,--vo=tctand--vo=kitty, with no switch.-Dcaca=disabled— The libcaca text-art output, which is not a port.-Dpipewire=enabled,-Dalsa=enabled,-Djack=enabled— The PipeWire and ALSA outputs, and JACK, which builds against thelibjackthat pipewire provides.-Dpulse=disabled,-Dopenal=disabled,-Dsdl2-audio=disabled— Further routes to the sound server the PipeWire output already reaches; the PulseAudio protocol is served by PipeWire itself.-Dsndio=disabled,-Doss-audio=disabled— The sndio and OSS outputs. sndio is not a port.-Dsdl2-video=disabled,-Dsdl2-gamepad=disabled— SDL’s video output and gamepad input.-Dlua=luajit— The scripting layer, and with it the on-screen controller, the stats overlay and the console. mpv accepts Lua 5.1 or 5.2; luajit is 5.1 with 5.2 extensions.-Djavascript=disabled— JavaScript scripting, which needs MuJS, not a port.-Drubberband=enabled— Therubberbandpitch- and tempo-shifting audio filter.-Dzimg=enabled— The zimg scaler, used for software conversions and screenshots in preference to libswscale.-Djpeg=enabled— JPEG screenshots.-Duchardet=enabled— Detect the character set of an external subtitle file, so--sub-codepage=auto, the default, converts a CP1251, GBK or Shift-JIS subtitle instead of showing it garbled.-Diconv=enabled,-Dzlib=enabled,-Dlcms2=enabled,-Dlibarchive=enabled,-Dlibavdevice=enabled— Character-set conversion, zlib-compressed Matroska tracks, ICC colour management, playing files from inside archives (archive://), and FFmpeg’s capture devices as inputs.-Dlibbluray=enabled,-Ddvdnav=enabled,-Dcdda=enabled—bd://,dvd://andcdda://input, through libbluray, libdvdnav and libcdio-paranoia. mpv buildsdvdnav,cddaanddvbin, likejackandx11, only as a GPL build, which this is:-Dgplkeeps its default oftrue.-Ddvbin=enabled—dvb://television input, which needs only the kernel’s DVB headers.-Dvapoursynth=disabled— The VapourSynth filter, which is not a port.-Dmanpage-build=enabled— Buildmpv.1with rst2man from python3-docutils.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mpv, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf mpv-0.41.0-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mpv, and runs the triggers its paths call for.
Contents
Installed programs: mpv.
Installed libraries: libmpv.so.
Installed directories: /usr/include/mpv, /usr/share/doc/mpv, /usr/share/licenses/mpv.
Short descriptions
mpv |
a media player |
mpv.pc |
mpv media player client library |
Notes
yt-dlp is in depends but not used by the build: mpv’s built-in ytdl_hook script runs it at play time when given a web address.
build.sh installs /etc/mpv/mpv.conf, the system configuration that the program reads before ~/.config/mpv/mpv.conf, with one line, gpu-sw=yes. Without it mpv refuses every rendering context it suspects is software, the Wayland one on llvmpipe among them, and falls through to its X11 EGL context, which on a session with no X display stops on the assertion !vo->x11; in a virtual machine or on a machine with no GPU driver the player never opens. The option does nothing on a hardware context, and libmpv front ends read no configuration file unless they ask.