Skip to content

sunweifeng/libmpv-darwin-build

 
 

Repository files navigation

libmpv Build

Provides builds of libmpv for macOS & iOS, usable by media_kit, compatible with commercial use.

Heavily inspired by Homebrew and IINA.

Usage

$ brew install cmake golang go-task meson ninja
$ VERSION=v0.0.1 task
$ ls build/video/macos/universal/libs
libass.9.dylib
libavcodec.59.dylib
libavfilter.8.dylib
...
$ ls build/video/macos/universal/archives/libs
libmpv-libs-video-v0.0.1-macos-universal.tar.gz

Dependencies

flowchart LR

A(mpv) --> B(ffmpeg)
A(mpv) -.-> C(libass)
A(mpv) -.-> D(uchardet)

B -.-> H(libressl)

C --> E(freetype)
C --> F(harfbuzz)
C --> G(fribidi)

E -.-> F
Loading
  • ffmpeg: A cross-platform solution for converting, streaming, and recording audio and video, with support for a wide range of codecs and formats

  • libass(optional): A library for rendering subtitles in videos, with support for advanced text formatting and positioning features (made optional with a patch)

  • fribidi: A library for handling bidirectional text (such as Arabic or Hebrew) in Unicode strings, with support for complex shaping and layout

  • freetype: A library for rendering high-quality text in graphics applications, with support for a wide range of font formats and glyph rendering techniques

  • harfbuzz: A library for shaping and laying out text in multiple languages and scripts, with support for advanced typography features such as ligatures and kerning

  • libressl (optional): A fork of OpenSSL that aims to provide a more secure and auditable implementation of the SSL/TLS protocols

  • uchardet (optional): A C++ port of the Universal Character Encoding Detector (used by Mozilla Firefox and Thunderbird) for detecting the encoding of input text

Commercial Use

Dependency Licence Commercial use
mpv LGPL-2.1 (-Dgpl=false)
ffmpeg LGPL-2.1 (--enable-gpl & --enable-nonfree omitted)
libass ISC
freetype FreeType
harfbuzz MIT
fribidi LGPL-2.1
libressl Apache-1.0, BSD-4-Clause, ISC, public domain
uchardet MPL-1.1, GPL-2, LGPL-2.1

Notes

The minimum versions of macOS and iOS have been chosen for these reasons:

  • macOS: the arm64 sdk force a minimum version of 11.0
  • iOS: ffmpeg requires a minimum version of 13.0

Some dependencies, which are not needed at the moment, may be added in the future:

  • libbluray: A library for reading and parsing Blu-ray discs, with support for advanced features such as BD-J menus and seamless branching

  • libarchive: A library for reading various archive formats, including tar and zip, with support for compression and metadata, and a flexible API for reading and extracting archive contents

We use meson as much as possible in order to simplify cross-compilation, at the cost of some heaviness regarding legacy packages.

Project Layout

.
├── ...
├── cmd                              # golang scripts
├── pkg                              # golang packages
├── downloads                        # dependencies archives files
├── downloads.lock                   # lock file of dependencies archives
├── Taskfile.yaml                    # main build script
├── scripts                          # build scripts
├── cross-files                      # cross build files used by meson
├── build
│   ├── tool-versions.lock           # versions of tools used during build
│   ├── tools                        # "sanboxed" tools & pkg-config
│   ├── audio
│   └── video
│       ├── macos
│       └── ios
│           ├── universal            # amd64 & arm64 libs merged with lipo
│           ├── amd64
│           └── arm64
│               ├── sources          # archives are extracted here
│               ├── chroot           # cross built files
│               │   ├── include
│               │   └── lib
│               ├── libs             # cleaned libs from `chroot/lib`
│               ├── frameworks       # `.framework` built from `libs`
│               ├── xcframeworks     # `.xcframework` built from `frameworks`
│               └── archives
│                   ├──libs          # tar.gz of `libs`
│                   └──xcframeworks  # tar.gz of `xcframeworks`
└── ...

How the libass optional patch was created

As the dependency of mpv on libass is deeply embedded in the code, the simplest solution was to:

  1. Remove the dynamic linking in meson.build.
  2. Include the ass/ass.h and ass/ass_types.h headers directly in the code
  3. Remove the call to ass_library_version in player/command.c
  4. Remove the calls to ass_library_init, called by mp_ass_init, in sub/osd_libass.c and sub/sd_ass.c

TODO

  • libressl: mutualise the build between audio and video variants, currently built twice
  • ffmpeg: improve variant configuration scripts, like what is done for mpv
  • looking for a better build automation tool than Taskfile (if it exists)

Resources

About

libmpv for macOS & iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 51.9%
  • Meson 31.0%
  • Go 17.1%