Macast
Macast copied to clipboard
希望能原生支持M1芯片的mac (native support for m1)
现在看macast还是intel架构在跑的,希望能出原生支持m1芯片版本的
下面的内容已经无效了,arm构建可以到本项目的github actions下载
Macast目前使用 github-actions 自动构建,而 github-actions 对普通用户只开放 MacOS 10.15,要支持universal2 至少需要MacOS 11,而且我不太确定在intel cpu 上能否可以编译出支持arm架构的mpv,mpv官方提供的应用版本是intel架构的,arm原生支持需要在m1上手动编译,而我又没有m1 mac。
所以目前来说,如果想要原生支持,需要自己手动编译才行:
- 1 Homebrew 安装mpv,使用Homebrew 安装mpv 会自动从mpv源码进行编译
- 2 clone 本项目,修改项目使用mpv的路径为系统默认mpv的路径 在根目录 Macast.py 文件中找到并删除下面的方法,这会让Macast使用系统路径中的mpv
def initPlatformDarwin(self):
Setting.setMpvPath(os.path.abspath('bin/MacOS/mpv'))
- 3 编译Macast
cd Macast
pip3 install -r requirements/darwin.txt
pip3 install py2app
python3 setup_py2app.py py2app
open dist
如果在编译过程中遇到了什么问题,欢迎继续讨论
outdated, see below for more information
At present, Macast uses GitHub-Actions to build automatically, while GitHub-Actions only supports MacOS 10.15 to ordinary users. To support universal2, MacOS 11 is required at least. Moreover, arm native support for MPV needs to be manually compiled on M1, And I don't have a M1 Mac.
So, if you want native support, you need to compile it manually:
- 1 install mpv via Homebrew
- 2 clone this project,Modify the MPV path used by the project to the system default MPV path Find and delete the following method in the Macast.py, which will make Macast use MPV in the system path
def initPlatformDarwin(self):
Setting.setMpvPath(os.path.abspath('bin/MacOS/mpv'))
- 3 compile Macast
cd Macast
pip3 install -r requirements/darwin.txt
pip3 install py2app
python3 setup_py2app.py py2app
open dist
Please refer to: development-upder-macos
The setup of python3 setup.py py2app
doesn't work for me now, and I found out that python3 setup_py2app.py py2app
does the trick.
Maybe this part is changed.
@zhangcheng Thanks for the tips.
If there are other questions, you can refer to this build script: https://github.com/xfangfang/Macast/blob/121add3a8a70edb77e33aeab1ec88aeff27f49fc/.github/workflows/build-macast.yaml#L201-L207
My result shown as above. 😄 Basically follow the above steps, except:
- Didn't bother to modify
Macast.py
, instead just copy the single binary of homebrew installed mpv ascp /opt/homebrew/Cellar/mpv/0.34.1_1/bin/mpv bin/MacOS/
- After
py2app
step, docp -R bin dist/Macast.app/Contents/Resources/
FYI. According to a recent comment (almost 1 month old already), official Github actions for M1 will become available soon.
My custom build DMG is on my fork, just in case it's also useful at the moment for others.
@zhangcheng Thanks for reminding. Actually, it can also be compiled by x86 macOS. I just lack a mpv.app(arm or universal2) to Copy into Macast.
@zhangcheng I can't run the mpv on my M1 mac..Looks like it's a matter of some libs.
Or, it's only my problem..I don't know.
I am a bit naive here. 😓
No wonder why brew install mpv
installs a ton of dependency packages.
Only copy the single mpv
binary into Macast.app
won't work.
You will have to do brew install mpv
as a short term solution. @Haifeng97
Haha, found a nice tool (mac dylib bundler) to solve this problem.
dylibbundler -od -b \
-x dist/Macast.app/Contents/Resources/bin/MacOS/mpv \
-d dist/Macast.app/Contents/Resources/bin/libs/
Uninstall ffmpeg@4
and test with
% /Volumes/Macast-v0.7\ Installer/Macast.app/Contents/Resources/bin/MacOS/mpv
mpv 0.34.1 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
built on Wed Feb 2 21:06:32 UTC 2022
FFmpeg library versions:
libavutil 56.70.100
libavcodec 58.134.100
libavformat 58.76.100
libswscale 5.9.100
libavfilter 7.110.100
libswresample 3.9.100
FFmpeg version: 4.4.1
Usage: mpv [options] [url|path/]filename
DMG is updated on my fork.
cc @Haifeng97
@zhangcheng Nice!
Could you please compile with the following command so that I can try to build Macast automatically using GitHub-Actions based on your compiled MPV.
dylibbundler -od -b \
-x dist/Macast.app/Contents/Resources/bin/MacOS/mpv \
-d dist/Macast.app/Contents/Resources/bin/MacOS/lib/
update:
dylibbundler -od -b \
-x dist/Macast.app/Contents/Resources/bin/MacOS/mpv \
-d dist/Macast.app/Contents/Resources/bin/MacOS/lib/ \
-p @executable_path/lib/
Sorry to bother you @zhangcheng
I've tried but it seems still doesn't work.
No bother at all, instead, thank you for helping out the test. @Haifeng97
Looks like we are dealing with nested dependency here, some of dylib depended by mpv binary, which in turn depends on some other dylib installed by homebrew (outside our little wall garden).
Seems to me that mac dylib bundler
probably only deals with one level of dylib.
My knowledge on mac dylib is very limited, any idea from master @xfangfang ? 😄
What I can think of now, is to do this process to all dylib copied over, repeat if there are new dylib added.
Update: this idea doesn't fly.
% dylibbundler -b \
-x bin/MacOS/lib/libvapoursynth-script.0.dylib \
-d bin/MacOS/lib/ \
-p @executable_path/lib/
* Collecting dependencies....
* Checking output directory bin/MacOS/lib/
* Processing bin/MacOS/lib/libvapoursynth-script.0.dylib
chmod +w "bin/MacOS/lib/libvapoursynth-script.0.dylib"
* Fixing dependencies on bin/MacOS/lib/libvapoursynth-script.0.dylib
codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - "bin/MacOS/lib/libvapoursynth-script.0.dylib"
bin/MacOS/lib/libvapoursynth-script.0.dylib: replacing existing signature
% otool -L bin/MacOS/lib/libvapoursynth-script.0.dylib
bin/MacOS/lib/libvapoursynth-script.0.dylib:
@executable_path/lib/libvapoursynth-script.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/Python (compatibility version 3.9.0, current version 3.9.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
It still depends on homebrew installed Python 3.9. 😓
I feel you can try to compile MPV manually. When compiling MPV, some optional configurations can be cancelled, so that there may not be too many dependencies packaged. I noticed that the number of dependencies compiled by stolendata is less than your compilation results, indicating that some dependencies can be ignored.
But I don't know much about how to compile MPV.
I feel you can try to compile MPV manually. When compiling MPV, some optional configurations can be cancelled, so that there may not be too many dependencies packaged. I noticed that the number of dependencies compiled by stolendata is less than your compilation results, indicating that some dependencies can be ignored.
But I don't know much about how to compile MPV.
Nice idea, no need to keep banging my head against homebrew bottled mpv, since it bundles in more bells and whistles than we need for our purpose.
I found this mpv homebrew tap for IINA, and also this:
Now IINA is shipped with a universal binary that run natively on both Intel and M1-based Macs.
IINA repo has a other/download_libs.sh script to download its pre-compiled libraries. Anything we could borrow from them? @xfangfang
BTW. I couldn't find mpv
binary under IINA.app contents. Is it because IINA uses libmpv
instead?
@zhangcheng I think so too, iina used libmpv to render video. Macast takes a more easy way to work with mpv by directly copying a compiled mpv.
I'm not sure if we can use these libraries provided by iina. Maybe we can directly modify the dependence of MPV to these libraries through some tools on the macOS.(install_name_tool?)
I still feel like compiling mpv.app manually is a good idea, although it seems that compiling MPV is not easy.
I hope this time it finally works, by utilizing iina/homebrew-mpv-iina.
My steps:
% brew tap iina/homebrew-mpv-iina
% brew install mpv-iina
% cp /opt/homebrew/Cellar/mpv-iina/0.34.0/bin/mpv bin/MacOS
% dylibbundler -cd -b \
-x bin/MacOS/mpv \
-d bin/MacOS/lib/ \
-p @executable_path/lib/
Use
% otool -L bin/MacOS/lib/* |grep homebrew
to verify that no more dependency with anything under /opt/homebrew
.
Also temporarily rename /opt/homebrew/opt/[email protected]
to something else on my box to make sure newly built Macast.app still playing things just fine.
@Haifeng97 pls take a look when you have time, DMG updated one more time.
Sorry for the delay, and it works well on my mac now. Nice job!
@zhangcheng
Thanks a lot for your detailed steps. I just built Macast.app through Github-Actions(with help from @xfangfang). Hope this will work normally on your Mac too. I will open a PR if everything works fine.
https://github.com/Haifeng97/Macast/actions/runs/2024907084
tips:
- update mpv.app to 0.34.1
- It seems there need more steps on macOS 12.1 or higher after dylibbundler step, run:
codesign --sign - --force dist/Macast.app/Contents/Resources/bin/MacOS/lib/*