Add experimental MPV player backend (#161)

Experimental MPV player backend

Related to #14, #22, & #85

You can switch to MPV in advanced settings and toggle using hardware
decoding or not.

This uses code and buildscripts from
https://github.com/mpv-android/mpv-android, plus other third party
libraries to build MPV
This commit is contained in:
damontecres 2025-11-16 18:46:25 -05:00 committed by GitHub
parent d7b333e519
commit 6be2662d4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 3987 additions and 289 deletions

91
scripts/mpv/include/ci.sh Executable file
View file

@ -0,0 +1,91 @@
#!/bin/bash -e
# go to buildscripts root folder
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
. ./include/depinfo.sh
msg() {
printf '==> %s\n' "$1"
}
fetch_prefix() {
if [[ "$CACHE_MODE" == folder ]]; then
local text=
if [ -f "$CACHE_FOLDER/id.txt" ]; then
text=$(cat "$CACHE_FOLDER/id.txt")
else
echo "Cache seems to be empty"
fi
printf 'Expecting "%s",\nfound "%s".\n' "$ci_tarball" "$text"
if [[ "$text" == "$ci_tarball" ]]; then
tar -xzf "$CACHE_FOLDER/data.tgz" -C prefix && return 0
fi
fi
return 1
}
build_prefix() {
msg "Building the prefix ($ci_tarball)..."
msg "Fetching deps"
IN_CI=1 ./include/download-deps.sh
# build everything mpv depends on (but not mpv itself)
for x in ${dep_mpv[@]}; do
msg "Building $x"
./buildall.sh $x
done
if [[ "$CACHE_MODE" == folder && -w "$CACHE_FOLDER" ]]; then
msg "Compressing the prefix"
tar -cvzf "$CACHE_FOLDER/data.tgz" -C prefix .
echo "$ci_tarball" >"$CACHE_FOLDER/id.txt"
fi
}
export WGET="wget --progress=bar:force"
if [ "$1" = "export" ]; then
# export variable with unique cache identifier
echo "CACHE_IDENTIFIER=$ci_tarball"
exit 0
elif [ "$1" = "install" ]; then
# install deps
if [[ -n "$ANDROID_HOME" && -d "$ANDROID_HOME" ]]; then
msg "Linking existing SDK"
mkdir -p sdk
ln -sv "$ANDROID_HOME" sdk/android-sdk-linux
fi
msg "Fetching SDK + NDK"
IN_CI=1 ./include/download-sdk.sh
msg "Fetching mpv"
mkdir -p deps/mpv
$WGET https://github.com/mpv-player/mpv/archive/master.tar.gz -O master.tgz
tar -xzf master.tgz -C deps/mpv --strip-components=1
rm master.tgz
msg "Trying to fetch existing prefix"
mkdir -p prefix
fetch_prefix || build_prefix
exit 0
elif [ "$1" = "build" ]; then
# run build
:
else
exit 1
fi
msg "Building mpv"
./buildall.sh -n mpv || {
# show logfile if configure failed
[ ! -f deps/mpv/_build/config.h ] && cat deps/mpv/_build/meson-logs/meson-log.txt
exit 1
}
msg "Building mpv-android"
./buildall.sh -n
exit 0

43
scripts/mpv/include/depinfo.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash -e
## Dependency versions
# Make sure to keep v_ndk and v_ndk_n in sync, both are listed on the NDK download page
v_sdk=11076708_latest
v_ndk=r29
v_ndk_n=29.0.14206865
v_sdk_platform=35
v_sdk_build_tools=35.0.0
v_lua=5.2.4
v_unibreak=6.1
v_harfbuzz=12.1.0
v_fribidi=1.0.16
v_freetype=2.14.1
v_mbedtls=3.6.4
## Dependency tree
# I would've used a dict but putting arrays in a dict is not a thing
dep_mbedtls=()
dep_dav1d=()
dep_ffmpeg=(mbedtls dav1d)
dep_freetype2=()
dep_fribidi=()
dep_harfbuzz=()
dep_unibreak=()
dep_libass=(freetype2 fribidi harfbuzz unibreak)
dep_lua=()
dep_libplacebo=()
dep_mpv=(ffmpeg libass lua libplacebo)
dep_mpv_android=(mpv)
## for CI workflow
# pinned ffmpeg revision
v_ci_ffmpeg=n8.0
# filename used to uniquely identify a build prefix
ci_tarball="prefix-ndk-${v_ndk}-lua-${v_lua}-unibreak-${v_unibreak}-harfbuzz-${v_harfbuzz}-fribidi-${v_fribidi}-freetype-${v_freetype}-mbedtls-${v_mbedtls}-ffmpeg-${v_ci_ffmpeg}.tgz"

32
scripts/mpv/include/path.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
. "$DIR/include/depinfo.sh"
os=linux
[[ "$OSTYPE" == "darwin"* ]] && os=mac
export os
if [ "$os" == "mac" ]; then
[ -z "$cores" ] && cores=$(sysctl -n hw.ncpu)
# various things rely on GNU behaviour
export INSTALL=`which ginstall`
export SED=gsed
else
[ -z "$cores" ] && cores=$(grep -c ^processor /proc/cpuinfo)
fi
cores=${cores:-4}
# configure pkg-config paths if inside buildscripts
if [ -n "$ndk_triple" ]; then
export PKG_CONFIG_SYSROOT_DIR="$prefix_dir"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/lib/pkgconfig"
unset PKG_CONFIG_PATH
fi
toolchain=$(echo "$DIR/sdk/android-ndk-${v_ndk}/toolchains/llvm/prebuilt/"*)
[ -d "$toolchain" ] && \
export PATH="$toolchain/bin:$DIR/sdk/android-ndk-${v_ndk}:$DIR/sdk/bin:$PATH"
export ANDROID_HOME="$DIR/sdk/android-sdk-$os"
unset ANDROID_SDK_ROOT ANDROID_NDK_ROOT