- 利用ffmpeg-android-maker编译,地址Javernaut/ffmpeg-android-maker: Contains a script that assembles FFmpeg library for Android (github.com)
- libfdk-aac编译脚本
bash
#!/bin/bash
NDK=$ANDROID_NDK_HOME # 这里需要替换成你本地的 NDK 路径
HOST_TAG=linux-x86_64
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
ANDROID_LIB_PATH="$(pwd)/android"
API=34
function build_android
{
echo "Build fdk-aac for android $CPU"
./configure \
--host=$HOST \
--enable-shared \
--enable-static \
--prefix="$ANDROID_LIB_PATH/$CPU" \
CPPFLAGS="-fPIC"
make clean
make -j8
make install
echo "Build fdk-aac for android $CPU completed"
}
# armeabi-v7a
CPU=armv7-a
HOST=arm-linux-android
export AR=$TOOLCHAIN/bin/llvm-ar
export AS=$TOOLCHAIN/bin/llvm-as
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export CC=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang
export CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang++
#export LD=${CC}
build_android
# arm64-v8a
CPU=armv8-a
HOST=aarch64-linux-android
export AR=$TOOLCHAIN/bin/llvm-ar
export AS=$TOOLCHAIN/bin/llvm-as
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
#export LD=${CC}
build_android
- 修改ffmpeg-android-maker/scripts/ffmpeg/build.sh 中 configure部分内容,这里添加了disable-doc,否则会报cc1错误
bash
./configure \
--prefix=${BUILD_DIR_FFMPEG}/${ANDROID_ABI} \
--enable-cross-compile \
--target-os=android \
--arch=${TARGET_TRIPLE_MACHINE_ARCH} \
--sysroot=${SYSROOT_PATH} \
--cc=${FAM_CC} \
--cxx=${FAM_CXX} \
--ld=${FAM_LD} \
--ar=${FAM_AR} \
--as=${FAM_CC} \
--nm=${FAM_NM} \
--ranlib=${FAM_RANLIB} \
--strip=${FAM_STRIP} \
--extra-cflags="-O3 -fPIC $DEP_CFLAGS" \
--extra-ldflags="$DEP_LD_FLAGS" \
--enable-shared \
--disable-static \
--disable-vulkan \
--enable-nonfree \
--enable-libfdk-aac \
--disable-doc \
--pkg-config=${PKG_CONFIG_EXECUTABLE} \
${EXTRA_BUILD_CONFIGURATION_FLAGS} \
$ADDITIONAL_COMPONENTS || exit 1
- export PKG_CONFIG_PATH={FDK_PKG_CONFIG_PATH}:{PKG_CONFIG_PATH},即fdk-aac生成的pkgconfig路径
bash
./ffmpeg-android-maker.sh -abis=arm64 -android=34