Created
February 2, 2020 10:58
-
-
Save VincentSit/5408b9446ca84fa73d5d73304e2c06ae to your computer and use it in GitHub Desktop.
Shell script to build FFmpeg for Android.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 当前系统 | |
HOST_TAG=darwin-x86_64 | |
# 支持的 Android 最低系统版本 | |
MIN=21 | |
# NDK 根目录 | |
NDK=$ANDROID_NDK_HOME | |
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG | |
AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar | |
AS=$TOOLCHAIN/bin/arm-linux-androideabi-as | |
NM=$TOOLCHAIN/bin/arm-linux-androideabi-nm | |
RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib | |
STRIP=$TOOLCHAIN/bin/arm-linux-androideabi-strip | |
function build() { | |
ARCH=$1 | |
CPU=$2 | |
# 编译目的目录 | |
PREFIX=$(pwd)/android/$CPU | |
case "$ARCH" in | |
"arm") | |
CC=$TOOLCHAIN/bin/clang | |
CXX=$TOOLCHAIN/bin/clang++ | |
;; | |
*) | |
CC=$TOOLCHAIN/bin/$ARCH-linux-android$MIN-clang | |
CXX=$TOOLCHAIN/bin/$ARCH-linux-android$MIN-clang++ | |
;; | |
esac | |
./configure \ | |
--prefix=$PREFIX \ | |
--pkg-config-flags="--static" \ | |
--ar=$AR \ | |
--as=$AS \ | |
--cc=$CC \ | |
--cxx=$CXX \ | |
--nm=$NM \ | |
--ranlib=$RANLIB \ | |
--strip=$STRIP \ | |
--arch=$ARCH \ | |
--target-os=android \ | |
--disable-shared \ | |
--disable-asm \ | |
--disable-ffprobe \ | |
--disable-ffplay \ | |
--disable-ffmpeg \ | |
--disable-ffserver \ | |
--disable-debug \ | |
--disable-symver \ | |
--disable-doc \ | |
--disable-stripping \ | |
--disable-programs \ | |
--disable-avdevice \ | |
--disable-filters \ | |
--disable-muxers \ | |
--enable-static \ | |
--enable-small \ | |
--enable-neon \ | |
--enable-hwaccels \ | |
--enable-postproc \ | |
--enable-network \ | |
--enable-runtime-cpudetect \ | |
--enable-protocol=udp \ | |
--enable-demuxer=rtsp \ | |
--enable-demuxer=sdp \ | |
--enable-decoder=h264 \ | |
--enable-decoder=hevc \ | |
--enable-decoder=mjpeg \ | |
--enable-bsf=h264_mp4toannexb \ | |
--enable-muxer=mp4 \ | |
--enable-protocol=file \ | |
--enable-cross-compile \ | |
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \ | |
--extra-ldflags="$ADDI_LDFLAGS" | |
make clean | |
make -j6 | |
make install | |
} | |
# 支持的 Android CUP 架构 | |
#ARCH=arm | |
#CPU=arm | |
#ARCH=aarch64 | |
#CPU=armv8-a | |
#ARCH=x86_64 | |
#CPU=x86_64 | |
echo "build armeabi" | |
build arm arm | |
echo "build arm64-v8a" | |
build aarch64 armv8-a | |
echo "build x86_64" | |
build x86_64 x86_64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment