Simply build_ffmepg.sh

master
徐灿辉 5 years ago
parent 97c5067331
commit 7aff4e31fb
  1. 73
      build_ffmpeg.sh

@ -19,6 +19,7 @@ FFMPEG_PATH=.
NDK_PATH=/Users/xch/Library/Android/sdk/ndk/21.0.5935234 NDK_PATH=/Users/xch/Library/Android/sdk/ndk/21.0.5935234
HOST_PLATFORM="darwin-x86_64" HOST_PLATFORM="darwin-x86_64"
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin" TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
GCC_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc"
ENABLED_ENCODERS=(h264 png) ENABLED_ENCODERS=(h264 png)
ENABLED_DECODERS=(h264 mpeg4 png) ENABLED_DECODERS=(h264 mpeg4 png)
@ -67,117 +68,95 @@ do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-filter=${filter}" COMMON_OPTIONS="${COMMON_OPTIONS} --enable-filter=${filter}"
done done
COMMON_MERGE_OPTIONS="
libavcodec/libavcodec.a
libavfilter/libavfilter.a
libavformat/libavformat.a
libavutil/libavutil.a
libswresample/libswresample.a
libswscale/libswscale.a
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker
"
cd "${FFMPEG_PATH}" cd "${FFMPEG_PATH}"
# (git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg) # (git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd ffmpeg cd ffmpeg
git checkout release/4.2 git checkout release/4.2
# armeabi-v7a # armeabi-v7a
SYSROOT="${NDK_PATH}/platforms/android-16/arch-arm"
PREFIX="android-libs/armeabi-v7a"
./configure \ ./configure \
--prefix=android-libs/armeabi-v7a \ --prefix=$PREFIX \
--arch=arm \ --arch=arm \
--cpu=armv7-a \ --cpu=armv7-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-" \
--nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \ --nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \
--cc="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-clang" \ --cc="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-clang" \
--ar="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-ar" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp" \ --extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
--extra-ldflags="-Wl,--fix-cortex-a8" \ --extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j4 make -j4
make install make install
SYSROOT="${NDK_PATH}/platforms/android-16/arch-arm"
PREFIX="$(pwd)/android-libs/armeabi-v7a"
# 打包
${TOOLCHAIN_PREFIX}/arm-linux-androideabi-ld \ ${TOOLCHAIN_PREFIX}/arm-linux-androideabi-ld \
-rpath-link=$SYSROOT/usr/lib \ -rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \ -L$SYSROOT/usr/lib \
-L$PREFIX/lib \ -L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \ -soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \ $PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \ ${COMMON_MERGE_OPTIONS} \
libavfilter/libavfilter.a \ ${GCC_PREFIX}/arm-linux-androideabi/4.9.x/libgcc_real.a
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/arm-linux-androideabi/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip $PREFIX/libffmpeg.so ${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip $PREFIX/libffmpeg.so
make clean make clean
# arm64-v8a # arm64-v8a
SYSROOT="${NDK_PATH}/platforms/android-21/arch-arm64"
PREFIX="android-libs/arm64-v8a"
./configure \ ./configure \
--prefix=android-libs/arm64-v8a \ --prefix=$PREFIX \
--arch=aarch64 \ --arch=aarch64 \
--cpu=armv8-a \ --cpu=armv8-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android-" \
--nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \ --nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \
--cc="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-clang" \ --cc="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-clang" \
--ar="${TOOLCHAIN_PREFIX}/aarch64-linux-android-ar" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j8 make -j8
make install make install
SYSROOT="${NDK_PATH}/platforms/android-21/arch-arm64"
PREFIX="$(pwd)/android-libs/arm64-v8a"
# 打包
${TOOLCHAIN_PREFIX}/aarch64-linux-android-ld \ ${TOOLCHAIN_PREFIX}/aarch64-linux-android-ld \
-rpath-link=$SYSROOT/usr/lib \ -rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \ -L$SYSROOT/usr/lib \
-L$PREFIX/lib \ -L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \ -soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \ $PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \ ${COMMON_MERGE_OPTIONS} \
libavfilter/libavfilter.a \ ${GCC_PREFIX}/aarch64-linux-android/4.9.x/libgcc_real.a
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/aarch64-linux-android/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip $PREFIX/libffmpeg.so ${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip $PREFIX/libffmpeg.so
make clean make clean
# x86 # x86
SYSROOT="${NDK_PATH}/platforms/android-16/arch-x86"
PREFIX="android-libs/x86"
./configure \ ./configure \
--prefix=android-libs/x86 \ --prefix=$PREFIX \
--arch=x86 \ --arch=x86 \
--cpu=i686 \ --cpu=i686 \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android-" \
--nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \ --nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \
--cc="${TOOLCHAIN_PREFIX}/i686-linux-android16-clang" \ --cc="${TOOLCHAIN_PREFIX}/i686-linux-android16-clang" \
--ar="${TOOLCHAIN_PREFIX}/i686-linux-android-ar" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
--disable-asm \ --disable-asm \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j4 make -j4
make install make install
SYSROOT="${NDK_PATH}/platforms/android-16/arch-x86"
PREFIX="$(pwd)/android-libs/x86"
${TOOLCHAIN_PREFIX}/i686-linux-android-ld \ ${TOOLCHAIN_PREFIX}/i686-linux-android-ld \
-rpath-link=$SYSROOT/usr/lib \ -rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \ -L$SYSROOT/usr/lib \
-L$PREFIX/lib \ -L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \ -soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \ $PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \ ${COMMON_MERGE_OPTIONS} \
libavfilter/libavfilter.a \ ${GCC_PREFIX}/i686-linux-android/4.9.x/libgcc_real.a
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/i686-linux-android/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/i686-linux-android-strip $PREFIX/libffmpeg.so ${TOOLCHAIN_PREFIX}/i686-linux-android-strip $PREFIX/libffmpeg.so
make clean make clean

Loading…
Cancel
Save