Skip to content

Instantly share code, notes, and snippets.

@mcp73
Forked from dbrookman/build-mpv_silicon.sh
Created August 8, 2022 15:37
Show Gist options
  • Save mcp73/64d27fb63a2e262c900250cf9569f5f1 to your computer and use it in GitHub Desktop.
Save mcp73/64d27fb63a2e262c900250cf9569f5f1 to your computer and use it in GitHub Desktop.
How to build mpv & mpv.app on an Apple silicon (M1 / M2) Mac

Preparations

Before you can build mpv & mpv.app on an Apple silicon (M1 / M2) 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've never run brew install --only-dependencies mpv, do so now.

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 you're in the root directory of the cloned repo beforehand.


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 (M1 / M2) Macs
# run this script from the root directory of the mpv repo
set -x
# use standalone tools, not Xcode's (avoids xcrun errors)
export DEVELOPER_DIR="/Library/Developer/CommandLineTools/"
LUAJIT_PATH="$(brew --prefix --installed luajit-openresty)" || exit 1
LUAJIT_PKG_CONFIG_PATH="$LUAJIT_PATH/lib/pkgconfig"
export PKG_CONFIG_PATH="$LUAJIT_PKG_CONFIG_PATH"
# if we don't have the latest ffmpeg...
if ! brew --prefix --installed ffmpeg; then
# ...but we do have ffmpeg@4, use it instead
if FFMPEG4_PATH="$(brew --prefix --installed ffmpeg@4)"; then
FFMPEG4_PKG_CONFIG_PATH="$FFMPEG4_PATH/lib/pkgconfig"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$FFMPEG4_PKG_CONFIG_PATH"
# if we have neither version, gtfo
else
exit 1
fi
fi
set -e # if any of the following fail, immediately gtfo
./bootstrap.py
./waf configure --lua=luajit
./waf build
# test the binary we just built
./build/mpv --version
./TOOLS/osxbundle.py --skip-deps build/mpv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment