FFmpeg libraries
Build FFmpeg's LGPL libraries, see where the core loads them from, put them into your app and learn what shipping them owes.
The core reaches FFmpeg through purego, without cgo, and loads its shared libraries at run time. It names the majors of FFmpeg 9 and refuses other versions instead of guessing their layouts.
Building them
Section titled “Building them”tools/ffmpeg builds the libraries for each target at one pinned version, from a checkout of the repository. It runs on macOS with Xcode and Go alone, and every download is pinned with its SHA-256.
go run ./tools/ffmpeg # every target into dist/ffmpeggo run ./tools/ffmpeg -target linux_x64 # one target| Target | Hardware decoding | Run-time needs |
|---|---|---|
macos_arm64, macos_x64 |
VideoToolbox | macOS 11 |
ios, ios_simulator (arm64) |
VideoToolbox | iOS 15 |
windows_x64 |
D3D11VA, DXVA2 | Windows 10 |
linux_x64 |
VAAPI | glibc 2.34, libva.so.2 and libva-drm.so.2 |
Only LGPL 2.1 parts are configured: every demuxer, parser and decoder, the file protocol, the audio filters rate changes use and the spdif muxer for passthrough. There are no encoders, other muxers, devices or network protocols; HTTP(S) is read in Go, so no TLS library is linked. libxml2 (MIT) is linked into libavformat for DASH.
Each archive, ffmpeg-<version>-<target>.zip, holds the six libraries, or six frameworks for iOS, and the notices their licenses ask to ship with them: COPYING.LGPLv2.1, COPYING.libxml2, ffmpeg.patch and BUILD.txt. dist/ffmpeg/source gets FFmpeg’s release tarball and the patch, the libraries’ complete source.
Where they load from
Section titled “Where they load from”The core takes the first it finds:
- The directory the
NSGO_MEDIA_FFMPEGenvironment variable names. - The app bundle’s
Contents/Frameworkson macOS. - The executable’s directory.
- The system’s FFmpeg 9: Homebrew’s prefixes on macOS, the loader’s search elsewhere.
On iOS they load only from frameworks: in NSGO_MEDIA_FFMPEG, which simulator tests use, or in the app’s Frameworks.
Packaging an app
Section titled “Packaging an app”go tool nsgo-media bundle puts the libraries into the packages nsgo build wrote: a macOS app’s Contents/Frameworks, an iOS app’s Frameworks, and the directory of a Windows or Linux executable, with every notice of the archive in FFmpeg/.
go get -tool github.com/oneo-me/nsgo-media/cmd/nsgo-mediago tool nsgo build -installers=falsego tool nsgo-media bundle dist/* # -libs DIR to take the archives from elsewhere- It takes the archives
tools/ffmpegbuilt and downloads nothing. It looks indist/ffmpegof the current directory, then indist/ffmpegof the module’s directory, which for your app is the local checkout itsreplacedirective names. - It takes each package’s target from the end of its name, and joins both architectures’ libraries with
lipoformacos_universal. - A macOS app is signed again with the identity it has (
-signnames another). An appnsgo buildnotarized needs notarizing again. - An iOS app is signed again when it is signed, and the IPA beside it is written again.
nsgo build -runandnsgo devinstall the app beforebundlecan run, so for a device build withsign.profile, bundle, then install it withxcrun devicectl device install app. - The installers
nsgo buildmakes are made beforebundleruns and lack the libraries, so build with-installers=falseand make installers afterwards.
What an app that ships them owes
Section titled “What an app that ships them owes”The libraries are LGPL 2.1, so an app, closed or not, ships them only as replaceable shared libraries, as bundle puts them, and besides:
- Offers their source: the files of
dist/ffmpeg/source, beside the app’s downloads on a server it controls, for as long as it distributes that build, or shipped with the app. - Says in its about box or documentation that it uses libraries of the FFmpeg project under the LGPL 2.1, and where their source is.
- Allows, in any license terms it has, changing the libraries and the reverse engineering needed to debug them, and claims no FFmpeg trademark.
- Settles codec patents itself; the LGPL grants none.
- On iOS, ships them as the separate dynamic frameworks
bundleputs in, never linked into the executable. Whether an App Store app’s signing and terms let users replace them is the app’s own question; the LGPL does not answer it.