一. 搭建编译环境
- 安装Ubuntu-18.04.4-desktop-amd64
Ubuntu环境下命令安装:
apt-get install -y make
apt-get install -y unzip
- 下载NDK,这里选用的是ndk-r21d
- 下载FFmpeg
二. 构建编译脚本
#!/bin/sh
echo Start building ff.
NDK=/home/hhu/share/transfer/android-ndk-r21b
ANDROID_VERSION=21
TOOLCHAIN_VERSION=4.9
BUILD_PLATFORM=linux-x86_64
ARCH=arm
HOST=arm-linux
ANDROID_ARCH_ABI=armeabi
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin
PREFIX=$(pwd)/android/${ANDROID_VERSION}/$ANDROID_ARCH_ABI
ADDI_LDFLAGS="-fPIE -pie"
ADDI_CFLAGS="-fPIE -pie -march=armv7-a -mfloat-abi=softfp -mfpu=neon"
build() {
./configure \
--prefix=$PREFIX \
--toolchain=clang-usan \
--target-os=android \
--arch=$ARCH \
--cpu=armv7-a \
--sysroot=$SYSROOT \
--cc=$TOOLCHAIN/armv7a-linux-androideabi21-clang \
--cxx=$TOOLCHAIN/armv7a-linux-androideabi21-clang++ \
--strip=$TOOLCHAIN/arm-linux-androideabi-strip \
--extra-cflags="$ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
--enable-neon \
--enable-hwaccels \
--enable-gpl \
--enable-jni \
--enable-mediacodec \
--enable-decoder=h264_mediacodec \
--enable-hwaccel=h264_mediacodec \
--enable-decoder=hevc_mediacodec \
--enable-decoder=mpeg4_mediacodec \
--enable-decoder=vp8_mediacodec \
--enable-decoder=vp9_mediacodec \
--enable-cross-compile \
--enable-ffmpeg \
--enable-shared \
--disable-static \
--disable-debug \
--disable-static \
--disable-doc \
--disable-ffplay \
--disable-ffprobe \
--disable-postproc \
--disable-avdevice \
--disable-symver \
--disable-stripping
make clean
make -j4
make install
echo "$ANDROID_ARCH_ABI installed"
}
build
网友评论