【随笔记】NDK 编译开源库 ffmpeg

一、下载源代码

wget http://ffmpeg.org/releases/ffmpeg-4.4.tar.gz
tar -zxvf ffmpeg-4.4.tar.gz

二、编译配置脚本

#! /bin/bash

export PREFIX=`pwd`/build/
export TOOLCHAIN=/opt/ndk/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64
export PATH="$TOOLCHAIN"/bin:"$PATH"
export CC="$TOOLCHAIN"/bin/armv7a-linux-androideabi19-clang 
export CXX="$TOOLCHAIN"/bin/armv7a-linux-androideabi19-clang++ 
export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" 
export LDFLAGS="-fPIE -pie -L$PREFIX/lib"
export TOOL=arm-linux-androideabi
export LD=$TOOLCHAIN/bin/${TOOL}-ld
export AR=$TOOLCHAIN/bin/${TOOL}-ar
export AS=$TOOLCHAIN/bin/${TOOL}-as
export RANLIB=$TOOLCHAIN/bin/${TOOL}-ranlib
export STRIP=$TOOLCHAIN/bin/${TOOL}-strip

./configure \
--prefix=`pwd`/../build/ffmpeg/ \
--enable-shared \
--disable-static \
--disable-doc \
--enable-ffmpeg \
--disable-ffplay \
--enable-ffprobe \
--disable-avdevice \
--disable-doc \
--disable-symver \
--disable-asm \
--target-os=linux \
--arch=armeabi-v7a \
--enable-cross-compile \
--target-os=android \
--sysroot=$TOOLCHAIN/sysroot/ \
--cc=$CC \
--cxx=$CXX \
--strip=$STRIP \
--extra-cflags="-fPIE -pie -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
--extra-ldflags="-fPIE -pie" 

if [ $? -eq 0 ]; then
	make -j16 && make install
fi

三、执行编译

cd ffmpeg-4.4
./android_build_ffmpeg.sh

posted @ 2021-08-03 22:19  Love_梦想  阅读(17)  评论(0编辑  收藏  举报