-
Notifications
You must be signed in to change notification settings - Fork 1
Guide to building FFmpeg
- Tested on Mac OS X El Capitan (10.11.6)
- Android NDK R12b
- Android Studio 2.1.2
- Download and extract Android NDK
- Download and extract FFmpeg binaries
We need to add the Android NDK path as an environment variable. Open the Mac Terminal, and:
$ open ~/.bash_profile
In the TextEdit window that opens up:
export ANDROID_NDK=<path-to-your-extracted-ndk>/android-ndk-r12b
- Extract the ffmpeg binaries, rename the extracted folder as
ffmpeg
(if it isn't that already). - Place them inside the
sources
folder insideandroid-ndk-r12b
. - Create a build script and set the configurable options. Here is the script I used.
- Open a Terminal and cd (change directory) to the ffmpeg source directory (easy way) and execute the script (in this case, my script is called
ffmpeg_build.sh
):
./ffmpeg_build.sh
- Open Terminal and cd to the ffmpeg source directory that you extracted earlier.
- Run:
./configure --help
Now that we have built from ffmpeg sources, we need to compile it for Android. Here's how:
- Open Terminal
- cd to the ffmpeg source folder
- Run:
make clean
make -j4
make install
The -j4
command specifies the number of cores that will be utilized. This depends on your system.
CMake is a platform-agnostic tool used for managing the build process. The easiest way to get it on your Mac is by getting Homebrew.
You're done! Depending on how you'd written the build script for ffmpeg, you'll find the compiled ffmpeg binaries in the corresponding location. In my case: <path-to-your-extracted-ndk>/android-ndk-r12b/sources/ffmpeg/android/arm/bin
.
Just copy the compiled binary file and place it in the assets
folder in the ffmpeg Android library (which you either added as a dependency or cloned from this repo).