[Request] How to bump mpv to 0.40.0 and integrate into media-kit?
Hi, thank you for creating media-kit package. I use a lot in my project.
I want to ask some questions about using new version of mpv for macOS. Currently, media-kit is using mpv version 0.36.0, which has some errors when showing duration and cannot load some videos which recorded from iPhone. I have tested using mpv app (version 0.36.0) without media-kit and it still errors, version 0.40.0 works smoothly without errors. For example: in version 0.36.0, mpv shows wrong duration (0:11:00), correct is 0:10:00 (in version 0.40.0)
So how can I build with mpv version 0.40.0 and integrate to media-kit?
Thank you!
I cannot work on this task right now because I have limited time, hardware, and personal availability.
You can still try it yourself. This repository uses Nix as the build system, so it is not easy to start if you are not familiar with Nix.
Please follow the README, read especially the section Build a specific target.
Important points:
- Updating only mpv is probably not enough.
- You will likely need to update or add dependencies.
- You will probably need to create one or more patches to make things work.
- These changes can take a lot of time and patience.
If your time is limited, I do not recommend starting this task now — it can be long and tedious.
This repository is on my long TODO list. I hope to work on it in the coming months.
First of all, thank you for specific answer, I really appreciate it. This issue is on my priority, so I need to do this now and try it myself. I hope you can answer me if I have questions about upgrading.
Thank you!
Hi @birros, today I found someone who is dealing with upgrading like me, so I try to build following him and it builds successfully (with mpv 0.40.0), but when I integrate into media-kit, app crashes right after VideoController initialize.
Below are my details work, can you take a look and give me some directions to debug?
- libmpv-darwin-build for mpv 0.40.0 (with sha256:
sha256:2f6c00db13416425dad61d30f10f4a1943c455e8f5ed725f9100b751aa6cbf23) - changes compare to media-kit libmpv-darwin-build
- media-kit flutter changes
I have run media_kit_test successfully before opening any video! Too close but I don't know how to continue to debug more why failed!
I attached macOS crash log here too.
Thank you!
No idea. As usual with Apple, the crash log is useless. We only know that the crash happens when calling mpv_create.
It looks like a missing symbol called issue. I think libplacebo is misconfigured:
$ otool -L libmpv-xcframeworks_v0.7.1_macos-universal-video-default/Placebo.xcframework/macos-arm64_x86_64/Placebo.framework/Versions/A/Placebo
libmpv-xcframeworks_v0.7.1_macos-universal-video-default/Placebo.xcframework/macos-arm64_x86_64/Placebo.framework/Versions/A/Placebo:
@rpath/Placebo.framework/Versions/A/Placebo (compatibility version 338.0.0, current version 338.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1900.178.0)
When we compare with mpv:
$ otool -L libmpv-xcframeworks_v0.7.1_macos-universal-video-default/Mpv.xcframework/macos-arm64_x86_64/Mpv.framework/Versions/A/Mpv
libmpv-xcframeworks_v0.7.1_macos-universal-video-default/Mpv.xcframework/macos-arm64_x86_64/Mpv.framework/Versions/A/Mpv:
@rpath/Mpv.framework/Versions/A/Mpv (compatibility version 2.0.0, current version 2.0.0)
@rpath/Ass.framework/Versions/A/Ass (compatibility version 12.0.0, current version 12.1.0)
@rpath/Avcodec.framework/Versions/A/Avcodec (compatibility version 60.0.0, current version 60.31.102)
@rpath/Avfilter.framework/Versions/A/Avfilter (compatibility version 9.0.0, current version 9.12.100)
@rpath/Avformat.framework/Versions/A/Avformat (compatibility version 60.0.0, current version 60.16.100)
@rpath/Avutil.framework/Versions/A/Avutil (compatibility version 58.0.0, current version 58.29.100)
@rpath/Placebo.framework/Versions/A/Placebo (compatibility version 338.0.0, current version 338.0.0)
@rpath/Swresample.framework/Versions/A/Swresample (compatibility version 4.0.0, current version 4.12.100)
@rpath/Swscale.framework/Versions/A/Swscale (compatibility version 7.0.0, current version 7.5.100)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
@rpath/Uchardet.framework/Versions/A/Uchardet (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 3423.0.0)
/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3423.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
We can clearly see that /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL is missing from libplacebo. According to the Nix package, OpenGL should be linked to libplacebo.
I think a good approach is to compare the dependencies of this built version of libplacebo with the system version or IINA using otool.
I recommend creating a minimal C program that calls mpv_create and links directly to the dylibs, instead of using the xcframeworks. As long as mpv_create crashes, the media-kit program will crash too.
Thank you, very clean explaination and easy to follow. I will try it!
After few hours to debug, I believe openGL is already in built package because when I run:
$nm -gU libmpv-xcframeworks_v0.7.1_macos-universal-video-default/Placebo.xcframework/macos-arm64_x86_64/Pla
cebo.framework/Versions/A/Placebo | grep pl_opengl
000000000004a388 T _pl_opengl_create
0000000000065abc T _pl_opengl_create_swapchain
00000000000754a8 S _pl_opengl_default_params
000000000004a158 T _pl_opengl_destroy
0000000000060f38 T _pl_opengl_get
0000000000065c54 T _pl_opengl_swapchain_update_fb
0000000000063594 T _pl_opengl_unwrap
0000000000062cc8 T _pl_opengl_wrap
Also, libplacebo loads openGL through glad2 at runtime, so that's why we do not see here, maybe right?
I still compare libplacebo from Nix package:
otool -L libplacebo.351.dylib
libplacebo.351.dylib:
/nix/store/d7ni8nsa07bmylv48npq630ahdd6p0ps-libplacebo-7.351.0/lib/libplacebo.351.dylib (compatibility version 351.0.0, current version 351.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
/nix/store/4r4dfpyz0s7gm0w2ap515lmgnmlhrgm5-shaderc-2025.2-lib/lib/libshaderc_shared.1.dylib (compatibility version 1.0.0, current version 0.0.0)
/nix/store/pzz71xa06z1kvdz5c1757fi4rkdhv5jv-vulkan-loader-1.4.313.0/lib/libvulkan.1.dylib (compatibility version 1.0.0, current version 1.4.0)
/nix/store/sqvb13rj88dcp9sq9qvwqh7p93kj8b4n-lcms2-2.17/lib/liblcms2.2.dylib (compatibility version 3.0.0, current version 3.17.0)
/nix/store/9p88y7c73zacs39rv3wnhrc7p323cpds-libdovi-3.3.1/lib/libdovi.3.dylib (compatibility version 3.0.0, current version 3.3.1)
/nix/store/nzvfa327cd5gan08ijkn465kbanbizpg-libcxx-19.1.7/lib/libc++.1.0.dylib (compatibility version 1.0.0, current version 1.0.0)
no openGL, so maybe I am missing libdovi and liblcms and libshaderc?
Here is my libplacebo package.nix file
maybe I am missing
libdoviandliblcmsandlibshaderc?
No idea. Sorry.
Thank you!