Skip to content

Instantly share code, notes, and snippets.

@dbrookman
Last active May 30, 2025 16:45
Show Gist options
  • Save dbrookman/74b8bcfb37a23452f7137b83bca9580f to your computer and use it in GitHub Desktop.
Save dbrookman/74b8bcfb37a23452f7137b83bca9580f to your computer and use it in GitHub Desktop.
How to build mpv & mpv.app on an Apple silicon Mac

Preparations

Before you can build mpv & mpv.app on an Apple silicon Mac, there's a couple of required dependencies you'll need to install if you haven't already:

  1. Go to System Preferences > Software Update. If there's anything there to update, do it.

  2. If you don't have the Xcode Command Line Tools installed, run xcode-select --install and select Install on the prompt that appears.

  3. If you don't have Homebrew installed, follow the instructions here.

  4. If you don't have all of mpv's dependencies installed, run brew install --build-from-source --only-dependencies mpv && brew install libplacebo.

You'll also need a local copy of the mpv repo, which you can get by running git clone https://github.com/mpv-player/mpv.

You can now run the attached script to build mpv & mpv.app on an Apple silicon Mac yourself. Just make sure to run it from the root directory of the cloned repo.

Static Build

If you want to bundle a static build of mpv.app, perform these steps following the ones above.

  1. Run brew install dylibbundler.

  2. Run the script from the root directory of the cloned repo, but append --static to the command, like ./build-mpv_silicon.sh --static.


Updating

Going forward, you can update your local copy of the repo by running the following commands from its root directory:

git reset --hard
git clean --force -d -x
git pull origin master
#!/usr/bin/env bash
# Builds mpv & mpv.app on Apple silicon Macs.
# Run this script from the root directory of the mpv repo.
# if anything fails, gtfo
set -ex
meson setup build
meson compile -C build
# test the binary we just built
./build/mpv --version
./TOOLS/osxbundle.py --skip-deps build/mpv
if [[ $1 == "--static" ]]; then
dylibbundler --bundle-deps --dest-dir build/mpv.app/Contents/MacOS/lib/ --install-path @executable_path/lib/ --fix-file build/mpv.app/Contents/MacOS/mpv
# test the app binary to make sure all the dylibs made it okay
./build/mpv.app/Contents/MacOS/mpv --version
fi
@joshkerr
Copy link

This worked fine for me on MacOS 15.0.

@ElhemEnohpi
Copy link

@hvirta - thanks, good to know after so many years we can finally download an Apple Silicon binary, including the application bundle, instead of having to go through all this to compile it! It's working well for me, so far. Btw., the direct link to the latest nightly build, as given at https://mpv.io/installation/ is:

https://nightly.link/mpv-player/mpv/workflows/build/master

@alphagumibear - about uninstalling - apart from the mpv folder, the instructions in the main post involve installing Homebrew, and a number of packages within it. If you want to completely remove Homebrew and all the packages, see: Homebrew/install: 📥 Homebrew (un)installer

Otherwise, you'll probably want to remove libplacebo, the mpv formula's dependencies, and possibly dylibbundler and molten-vk, using the brew uninstall [packagename] command. Uninstalling the mpv dependencies is a bit tricky though, because brew uninstall mpv will just tell you that it's not installed. There may be a better way to do it, but I ended up just doing brew install mpv (which downloaded and installed a lot of things) and then brew uninstall mpv. That removed all the unused dependencies.

@alphagumibear
Copy link

@hvirta - thanks, good to know after so many years we can finally download an Apple Silicon binary, including the application bundle, instead of having to go through all this to compile it! It's working well for me, so far. Btw., the direct link to the latest nightly build, as given at https://mpv.io/installation/ is:

https://nightly.link/mpv-player/mpv/workflows/build/master

@alphagumibear - about uninstalling - apart from the mpv folder, the instructions in the main post involve installing Homebrew, and a number of packages within it. If you want to completely remove Homebrew and all the packages, see: Homebrew/install: 📥 Homebrew (un)installer

Otherwise, you'll probably want to remove libplacebo, the mpv formula's dependencies, and possibly dylibbundler and molten-vk, using the brew uninstall [packagename] command. Uninstalling the mpv dependencies is a bit tricky though, because brew uninstall mpv will just tell you that it's not installed. There may be a better way to do it, but I ended up just doing brew install mpv (which downloaded and installed a lot of things) and then brew uninstall mpv. That removed all the unused dependencies.

thank you for your response Elhem!

@giacomorebonato
Copy link

I don't see the OSC anymore and I can't enable it. Do you know what I might miss?

@amnah
Copy link

amnah commented Nov 14, 2024

I don't see the OSC anymore and I can't enable it. Do you know what I might miss?

it looks like they changed the dependencies with the latest v0.39.0 release. you'll need to rerun step 4 of the instructions:

brew install --build-from-source --only-dependencies mpv && brew install libplacebo

(this will install the new mujs and luajit dependencies)

@giacomorebonato
Copy link

I needed to install lua and the osc is now back. Thanks!

@carys-cc
Copy link

With help from AI, enabled libarchive support

#!/usr/bin/env bash

# Builds mpv & mpv.app on Apple silicon Macs with libarchive support.
# Run this script from the root directory of the mpv repo.

# if anything fails, gtfo
set -ex

# Make sure pkg-config is installed
if ! command -v pkg-config &>/dev/null; then
    echo "Installing pkg-config..."
    brew install pkg-config
fi

# Check if libarchive is installed, install if not
if ! brew list libarchive &>/dev/null; then
    echo "Installing libarchive dependency..."
    brew install libarchive
fi

# Get libarchive location from Homebrew
LIBARCHIVE_PREFIX=$(brew --prefix libarchive)
echo "libarchive is installed at: $LIBARCHIVE_PREFIX"

# Setup environment variables so pkg-config can find libarchive
export PKG_CONFIG_PATH="$LIBARCHIVE_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
export LDFLAGS="-L$LIBARCHIVE_PREFIX/lib $LDFLAGS"
export CPPFLAGS="-I$LIBARCHIVE_PREFIX/include $CPPFLAGS"

# Verify pkg-config can find libarchive
if pkg-config --exists libarchive; then
    echo "pkg-config found libarchive:"
    pkg-config --modversion libarchive
    echo "libarchive CFLAGS: $(pkg-config --cflags libarchive)"
    echo "libarchive LIBS: $(pkg-config --libs libarchive)"
else
    echo "ERROR: pkg-config cannot find libarchive"
    echo "Available pkgconfig files in $LIBARCHIVE_PREFIX/lib/pkgconfig:"
    ls -la $LIBARCHIVE_PREFIX/lib/pkgconfig
    exit 1
fi

# Clean previous build if it exists
rm -rf build

# Configure with libarchive support and explicitly specify the path
meson setup build \
    -Dlibarchive=enabled \
    -Dpkg_config_path="$LIBARCHIVE_PREFIX/lib/pkgconfig"

meson compile -C build

# test the binary we just built
./build/mpv --version

./TOOLS/osxbundle.py --skip-deps build/mpv
if [[ $1 == "--static" ]]; then
    dylibbundler --bundle-deps --dest-dir build/mpv.app/Contents/MacOS/lib/ --install-path @executable_path/lib/ --fix-file build/mpv.app/Contents/MacOS/mpv
    # test the app binary to make sure all the dylibs made it okay
    ./build/mpv.app/Contents/MacOS/mpv --version
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment