Last active
November 16, 2017 01:25
-
-
Save dral3x/5495295 to your computer and use it in GitHub Desktop.
Script for compiling FFMpeg for Android projects on Mac OS.
Please adjust NDK, PLATFORM and PREBUILD variable before run it
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 | |
###################################################### | |
# Usage: | |
# put this script in top of FFmpeg source tree | |
# ./build_android | |
# | |
# It generates binary for following architectures: | |
# ARMv6 | |
# ARMv6+VFP | |
# ARMv7+VFPv3-d16 (Tegra2) | |
# ARMv7+Neon (Cortex-A8) | |
# | |
# Customizing: | |
# 1. Feel free to change ./configure parameters for more features | |
# 2. To adapt other ARM variants | |
# set $CPU and $OPTIMIZE_CFLAGS | |
# call build_now | |
###################################################### | |
# change these three lines to adjust those to your local folders configuration | |
NDK=/Applications/adt-bundle-mac/ndk | |
PLATFORM=$NDK/platforms/android-9/arch-arm | |
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86_64 | |
function build_now | |
{ | |
./configure \ | |
--disable-shared \ | |
--enable-static \ | |
--enable-gpl \ | |
--enable-version3 \ | |
--enable-nonfree \ | |
--disable-doc \ | |
--disable-ffmpeg \ | |
--disable-ffplay \ | |
--disable-ffprobe \ | |
--disable-ffserver \ | |
--disable-avdevice \ | |
--disable-avfilter \ | |
--disable-postproc \ | |
--enable-small \ | |
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \ | |
--enable-cross-compile \ | |
--target-os=linux \ | |
--extra-cflags="-I$PLATFORM/usr/include -Wno-traditional" \ | |
--extra-ldflags="-L$PLATFORM/usr/lib -nostdlib" \ | |
--prefix="$PREFIX" \ | |
--arch=arm \ | |
--disable-symver \ | |
--disable-debug \ | |
--disable-stripping \ | |
$ADDITIONAL_CONFIGURE_FLAG | |
sed -i '.bak' 's/HAVE_CBRT 0/HAVE_CBRT 1/g' config.h | |
sed -i '.bak' 's/HAVE_ISINF 0/HAVE_ISINF 1/g' config.h | |
sed -i '.bak' 's/HAVE_ISNAN 0/HAVE_ISNAN 1/g' config.h | |
sed -i '.bak' 's/HAVE_RINT 0/HAVE_RINT 1/g' config.h | |
sed -i '.bak' 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h | |
sed -i '.bak' 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h | |
sed -i '.bak' 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h | |
sed -i '.bak' 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h | |
sed -i '.bak' 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h | |
sed -i '.bak' 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h | |
make clean | |
make -j4 install | |
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o | |
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a | |
} | |
#arm v6 | |
#CPU=armv6 | |
#OPTIMIZE_CFLAGS="-marm -march=$CPU" | |
#PREFIX=./android/$CPU | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_now | |
################################### | |
#arm v7vfpv3 | |
CPU=armv7-a | |
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU " | |
PREFIX=./android/$CPU | |
ADDITIONAL_CONFIGURE_FLAG= | |
build_now | |
################################### | |
#arm v7vfp | |
#CPU=armv7-a | |
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU " | |
#PREFIX=./android/$CPU-vfp | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_now | |
################################### | |
#arm v7n | |
#CPU=armv7-a | |
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8" | |
#PREFIX=./android/$CPU | |
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon | |
#build_now | |
################################### | |
#arm v6+vfp | |
#CPU=armv6 | |
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU" | |
#PREFIX=./android/${CPU}_vfp | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment