Skip to main content
Version: v5.9.0

Build ffmpeg based on NDK

To Support NETINT’s decoder, encoder and filter modules build FFmpeg based on the Android NDK.

  1. Create a pkg-config file for libxcoder

libxcoder is referenced by FFmpeg which is based on the pkg-config mechanism. Generate the pkg-config file for libxcoder first.

cd ~/FFmpegXcoder/libxcoder/ &&  sh build.sh -a

The above step is for Quadra only. For Logan (including for when Quadra and Logan co-existence is required) also create the pkg-config file for libxcoder_logan

cd ~/FFmpegXcoder/libxcoder_logan/ &&  sh build.sh -a

Generate the pkg-config file for libxcoder. Now copy the AOSP generated libxcoder dynamic library to the specified directory in the libxcoder pkg-config file.

cp ~/android_work/out/target/product/generic_x86_64/system/lib64/libxcoder.so /usr/local/lib/

For Logan we should copy libxcoder_logan:

cp ~/android_work/out/target/product/generic_x86_64/system/lib64/libxcoder_logan.so /usr/local/lib/
  1. Build FFmpeg
cd ~/FFmpegXcoder/FFmpeg-n4.3.1 && make clean
sh build_ffmpeg.sh -a –shared --android_arch=x86_64
make install
sudo ldconfig 

For Quadra and Logan co-existence build FFmpeg with the following command:

sh build_ffmpeg.sh --quadra --logan -a –shared --android_arch=x86_64
note

This uses FFmpeg-n4.3.1 as an example but other FFmpeg versions can be used depending on the system requirements.

There are a range of valid android_arch parameters [arm,arm64,x86,x86_64(default)], in this example we are using x86_64.

If the build is successful a folder named android is created under the path

~/FFmpegXcoder/FFmpeg-n4.3.1

There will also be some FFmpeg libraries and bin files generated under the same folder.

Push the generated files to the Android run environment. Please refer to section 11.7 for details.