Skip to content

Building FFmpegKit with Custom Libraries

Taner Sener edited this page Oct 3, 2022 · 5 revisions

ffmpeg-kit build scripts come with a list of external libraries that can be enabled out of the box.

However, ffmpeg-kit is not limited to those built-in libraries only. You can build ffmpeg with other libraries as well. You just to tell build scripts how they can be compiled. And they will do that for you.

Top level build scripts (android.sh, ios.sh, linux.sh, macos.sh and tvos.sh) support optional flags to pass that information.

  1. First, the following flags must be provided to build a custom library. All of them are mandatory except repo-commit and repo-tag. Those two are interchangeable. Providing only one of them is sufficient. You can build more than one custom library as well.
--enable-custom-library-[n]-name=value				name of the custom library []
--enable-custom-library-[n]-repo=value				git repository of the source code []
--enable-custom-library-[n]-repo-commit=value			git commit to download the source code from []
--enable-custom-library-[n]-repo-tag=value			git tag to download the source code from []
--enable-custom-library-[n]-package-config-file-name=value	package config file installed by the build script []
--enable-custom-library-[n]-ffmpeg-enable-flag=value	        library name used in ffmpeg configure script to enable the library []
--enable-custom-library-[n]-license-file=value			licence file path relative to the library source folder []

The following Android only flag is also optional. It must be provided if the custom library uses libc++. Loading ffmpeg will fail with linking errors if the custom library uses it but the flag is not specified.

--enable-custom-library-[n]-uses-cpp				flag to specify that the library uses libc++ []

Examples:

./macos.sh \
 --enable-custom-library-1-name=chromaprint \
 --enable-custom-library-1-repo=https://github.com/arthenica/chromaprint \
 --enable-custom-library-1-repo-tag=v1.5.0 \
 --enable-custom-library-1-package-config-file-name=libchromaprint \
 --enable-custom-library-1-ffmpeg-enable-flag=chromaprint \
 --enable-custom-library-1-license-file=LICENSE.md

./android.sh \     
 --enable-custom-library-1-name=x265 \
 --enable-custom-library-1-repo=https://github.com/arthenica/x265 \
 --enable-custom-library-1-repo-tag=3.4 \
 --enable-custom-library-1-package-config-file-name=x265 \
 --enable-custom-library-1-ffmpeg-enable-flag=libx265 \
 --enable-custom-library-1-license-file=COPYING \
 --enable-custom-library-1-uses-cpp \
 --enable-gpl
  1. The second step is to provide the compile script. It must be created under the scripts/android folder for Android, under the scripts/linux folder for Linux and under the scripts/apple folder for the Apple platforms. It's name must be in the form of name.sh. Where the name is the same name given in the --enable-custom-library-[n]-name option passed. That's it.

You can look and copy the compile scripts we have for the built-in libraries under the scripts/android, scripts/linux and scripts/apple folders. They will show you the general syntax and environment variables we're using in each platform.

Clone this wiki locally