FFmpeg (and how to build it)
Home > Developer reference > FFmpeg (and how to build it)
Aural Player makes use of the popular FFmpeg project's libraries to decode audio formats that macOS' CoreAudio is not able to natively decode, eg - FLAC, Vorbis, True Audio, Monkey's Audio.
Specifically, the following 4 libraries are used:
- libavformat - To "demux" audio files / containers and read stream information.
- libavcodec - To decode audio packets into PCM samples.
- libavutil - A support library with utilities.
- libswresample - To convert PCM samples, if necessary, into the canonical sample format required by CoreAudio for playback.
Note that, since Aural Player does not deal with video, no video codecs are required. Also, since it does not perform any encoding or transcoding, no encoders are required. So, the FFmpeg build required for Aural Player consists of a small subset of specific FFmpeg components:
- Demuxers for supported non-native audio file formats
- Decoders for the supported non-native audio formats
- Parsers for supported non-native audio formats or image formats (to be able to parse cover art)
The build script, source code, and detailed instructions are available in /Resources/ffmpeg. Please read the instructions in README.txt to learn about the required pre-requisites for a successful FFmpeg build.
The script (named "build-ffmpeg.sh") will build one set of the 4 libraries for the x86_64 (Intel) architecture, then build another set of libraries for the arm64 (Apple Silicon) architecture, and then combine the two sets of libraries into "fat" or universal binaries that are executable on both architectures.
Finally, the libraries (.dylib), along with the corresponding public header files (.h), will be wrapped into XCFrameworks (.xcframework) that are ready to drop into the Aural Player project and use for development.
If you'd like to modify the build, please modify the arguments passed to FFmpeg's configure tool in the script. You may modify which components are built: which demuxers, decoders, parsers, etc.
# Configure FFmpeg
./configure \
--cc=/usr/bin/clang \
...
--enable-demuxer=ape,asf,asf_o,dsf,flac,iff,matroska,mpc,mpc8,ogg,rm,tak,tta,wv \
--enable-decoder=ape,cook,dsd_lsbf,dsd_lsbf_planar,dsd_msbf,dsd_msbf_planar ...
...
The FFmpeg libraries are built as dynamic (shared) libraries having the extension .dylib and then wrapped into XCFrameworks (.xcframework) that also include the corresponding public headers. The Aural Player project refers to them under the Frameworks source group and embeds them in the Frameworks sub-directory when it builds an app bundle.
So, once you have built the XCFrameworks, copy them into the Frameworks source group of the Xcode project to build Aural Player with the newly built libraries.