ffmpeg build Anddriod script


build ffmpeg arm

#!/bin/bash

export NDK=/Users/ilong/Documents/android-ndk-r6b
export PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86
export PLATFORM=$NDK/platforms/android-9/arch-arm
export PREFIX=android-ffmpeg/arm
export SOURCE="ffmpeg-4.0.3"
export X264=`pwd`/android-x264

build_one(){
     

  if [ ! -r $SOURCE ]
  then
     echo 'FFmpeg source not found. Trying to download...'
     curl https://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
        || exit 1
  fi

./$SOURCE/configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--disable-everything \
--disable-debug \
--disable-programs \
--disable-network \
--disable-muxers \
--disable-demuxers \
--disable-protocols \
--disable-parsers \
--disable-devices \
--disable-ffprobe \
--disable-avdevice \
--disable-bsfs \
--disable-doc \
--disable-ffplay \
--disable-encoders \
--disable-decoders \
--enable-neon \
--enable-ffmpeg \
--enable-small \
--enable-nonfree \
--enable-version3 \
--enable-gpl \
--enable-asm \
--enable-encoder=aac \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-decoder=aac \
--extra-cflags="-I$X264/arm/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
--extra-ldflags="-L$X264/arm/lib"

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 -L$PREFIX/lib -L$X264/arm/lib -soname libvhffmpeg.so -shared -nostdlib -z noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libvhffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavformat/libavformat.a libavutil/libavutil.a libpostproc/libpostproc.a libswresample/libswresample.a libswscale/libswscale.a  -lc -lm -lz -ldl -llog -lx264 --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}

build_one

echo Android ARM builds finished


build ffmpeg arm64

#!/bin/sh
#Change NDK to your Android NDK location
export NDK=/Users/ilong/Documents/android-ndk-r11c
export PREBUILT=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/*-x86_64
export PLATFORM=$NDK/platforms/android-21/arch-arm64/
export PREFIX=android-ffmpeg/arm64
export SOURCE="ffmpeg-4.0.3"
export X264=`pwd`/android-x264

build_one(){
     

  if [ ! -r $SOURCE ]
  then
     echo 'FFmpeg source not found. Trying to download...'
     curl https://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
        || exit 1
  fi

./$SOURCE/configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--arch=arm64 \
--extra-libs="-lgcc" \
--cc=$PREBUILT/bin/aarch64-linux-android-gcc \
--cross-prefix=$PREBUILT/bin/aarch64-linux-android- \
--nm=$PREBUILT/bin/aarch64-linux-android-nm \
--sysroot=$PLATFORM \
--disable-everything \
--disable-debug \
--disable-programs \
--disable-network \
--disable-muxers \
--disable-demuxers \
--disable-protocols \
--disable-parsers \
--disable-devices \
--disable-ffprobe \
--disable-avdevice \
--disable-bsfs \
--disable-doc \
--disable-ffplay \
--disable-encoders \
--disable-decoders \
--enable-neon \
--enable-ffmpeg \
--enable-small \
--enable-nonfree \
--enable-version3 \
--enable-gpl \
--enable-asm \
--enable-encoder=aac \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-decoder=aac \
--extra-cflags="-I$X264/arm64/include -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums  -fno-strict-aliasing -finline-limit=300" \
--extra-ldflags="-L$X264/arm64/lib"

make clean

make -j8 install

$PREBUILT/bin/aarch64-linux-android-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/aarch64-linux-android-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib -L$X264/arm64/lib -soname libvhffmpeg.so -shared -nostdlib -z noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libvhffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavformat/libavformat.a libavutil/libavutil.a libpostproc/libpostproc.a libswresample/libswresample.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/aarch64-linux-android/4.9/libgcc.a

}

build_one

echo Android ARM64 Combined  finished