Skip to content

Instantly share code, notes, and snippets.

@dbrookman
Last active May 1, 2024 17:37
Show Gist options
  • Star 81 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • 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
@spikeh
Copy link

spikeh commented Nov 7, 2023

For Sonoma work solution

rm build/mpv.app/Contents/MacOS/mpv-bundle
mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle
ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv
codesign --force --deep -s - build/mpv.app

Thanks, this worked for me.

@nickeltingupta
Copy link

For Sonoma work solution

rm build/mpv.app/Contents/MacOS/mpv-bundle
mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle
ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv
codesign --force --deep -s - build/mpv.app

This worked for me on Sonoma. I was having "flashing screen" issue and this fixed it, thanks a lot!

@dbrookman
Copy link
Author

This just got merged, so you shouldn't have to fiddle with mpv-bundle or do any code-signing on your own any longer.

Also, if you don't have libplacebo installed, you'll need to run brew install libplacebo. I've updated the instructions accordingly.

@sandlst
Copy link

sandlst commented Nov 18, 2023

building log
I'm successed build on sonoma 14.0 , but failed on sonoma 14.1

I'm having this too; related bug: mpv-player/mpv#12673

This build guide works and uses non-homebrew versions of a lot of deps; it makes me wonder if there is a bug in one of the homebrew Vulkan packages or possibly pkgconf.

In case anyone else is having the same issue:
/opt/homebrew/Cellar/libplacebo/6.338.1_1/include/libplacebo/vulkan.h:21:10: fatal error: 'vulkan/vulkan.h' file not found
when trying to build; I think messing around with the Vulkan-SDK installer and then trying to go back to homebrew's vulkan/libplacebo was the cause of it for me. After completely removing the vulkan-sdk and forcing brew to reinstall libplacebo, vulkan-headers, and vulkan-loader I was able to build mpv again. Even after removing the SDK it was still giving me that error until I force reinstalled those homebrew packages....I reinstalled all of them at once so I'm not sure which one(s) were responsible.

@Akczht
Copy link

Akczht commented Nov 18, 2023

I recently was able to build a standalone mpv app, without any errors after the latest commit bringing support hw decoding of libplacebo with videotoolbox, all I did was install molten-vk and libplacebo I got no errors.

@PsyPryss
Copy link

/!\ WARNING : can't get path for '@rpath/libspirv-cross-c-shared.0.dylib'
What other dependencies am I missing. I'm trying to compile a static build.

@temberature
Copy link

The Absolute Beginner's Guide to Installing and Using Meson
https://mesonbuild.com/SimpleStart.html

@miku1958
Copy link

FYI, If you want to enable gpu-next, you have to install the Vulkan SDK https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg

@ElhemEnohpi
Copy link

ElhemEnohpi commented Mar 20, 2024

@miku1958 Yes, it's nice having gpu-next, now I can watch Dolby Vision videos with mpv!

But you don't have to install the whole Vulkan SDK, which is relatively large. You only need the MoltenVK runtime. As noted in the third comment above yours, it can be installed easily from Homebrew. Just do:

brew install molten-vk

Maybe it can be added to the script...

@miku1958
Copy link

@ElhemEnohpi Got it thanks

@tano70
Copy link

tano70 commented Apr 10, 2024

no work today in my MacbookPro M3 when i ran "brew upgrade" and installed mpv 0.37.0.2 from 0.37.0.1 and ffmpeg 7.0 from 6.1.1.7
any solution?

@ttforsd
Copy link

ttforsd commented Apr 15, 2024

no work today in my MacbookPro M3 when i ran "brew upgrade" and installed mpv 0.37.0.2 from 0.37.0.1 and ffmpeg 7.0 from 6.1.1.7 any solution?

Same issue on m1 air

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