mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Update build_ffmpeg script
This commit is contained in:
parent
ee217d739f
commit
a1817ea7d3
3 changed files with 232 additions and 8 deletions
53
TMessagesProj/jni/ffmpeg/build_ffmpeg_android.sh → TMessagesProj/jni/ffmpeg/build_ffmpeg/build_ffmpeg.sh
Executable file → Normal file
53
TMessagesProj/jni/ffmpeg/build_ffmpeg_android.sh → TMessagesProj/jni/ffmpeg/build_ffmpeg/build_ffmpeg.sh
Executable file → Normal file
|
@ -1,5 +1,32 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# instructions for build
|
||||||
|
# used
|
||||||
|
# ffmpeg 4.3.3
|
||||||
|
# lib vpx 1.10.9
|
||||||
|
# NDK build_ffmpeg for compile libvpx. Last sussecfull build with 21.1.6352462
|
||||||
|
# NDK r10e for compile ffmpeg
|
||||||
|
#
|
||||||
|
# 1) download ffmpeg
|
||||||
|
# 2) set NDK_r10e and NDK variables
|
||||||
|
# 3) download lib vpx
|
||||||
|
# 4) copy libvpx to vpx-android folder and rename as libvpx
|
||||||
|
# 5) copy build_ffmpeg foleder in ffmepg directory
|
||||||
|
# 6) run build_ffmpeg.sh
|
||||||
|
# 7) see compiled library in build_ffmpeg/adnroid folder
|
||||||
|
|
||||||
|
NDK="/opt/android/ndk/android-ndk-r21e"
|
||||||
|
NDK_r10e="/opt/android/ndk/android-ndk-r10e"
|
||||||
|
|
||||||
|
|
||||||
|
cd ./vpx-android
|
||||||
|
export ANDROID_NDK=$NDK
|
||||||
|
sh build-vpx.sh
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
|
||||||
|
NDK=$NDK_r10e
|
||||||
|
|
||||||
function build_one {
|
function build_one {
|
||||||
|
|
||||||
echo "Cleaning..."
|
echo "Cleaning..."
|
||||||
|
@ -8,6 +35,9 @@ make clean
|
||||||
|
|
||||||
echo "Configuring..."
|
echo "Configuring..."
|
||||||
|
|
||||||
|
INCLUDES=" -I${PREFIX}/include"
|
||||||
|
LIBS=" -L${PREFIX}/lib"
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--cc=$CC \
|
--cc=$CC \
|
||||||
--nm=$NM \
|
--nm=$NM \
|
||||||
|
@ -24,8 +54,8 @@ echo "Configuring..."
|
||||||
--enable-inline-asm \
|
--enable-inline-asm \
|
||||||
--cross-prefix=$CROSS_PREFIX \
|
--cross-prefix=$CROSS_PREFIX \
|
||||||
--sysroot=$PLATFORM \
|
--sysroot=$PLATFORM \
|
||||||
--extra-cflags="-Wl,-Bsymbolic -Os -DCONFIG_LINUX_PERF=0 -DANDROID $OPTIMIZE_CFLAGS -fPIE -pie --static -fPIC" \
|
--extra-cflags="${INCLUDES} -Wl,-Bsymbolic -Os -DCONFIG_LINUX_PERF=0 -DANDROID $OPTIMIZE_CFLAGS -fPIE -pie --static -fPIC" \
|
||||||
--extra-ldflags="-Wl,-Bsymbolic -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -fPIC" \
|
--extra-ldflags="${LIBS} -Wl,-Bsymbolic -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -fPIC" \
|
||||||
--extra-libs="-lgcc" \
|
--extra-libs="-lgcc" \
|
||||||
\
|
\
|
||||||
--enable-version3 \
|
--enable-version3 \
|
||||||
|
@ -44,6 +74,8 @@ echo "Configuring..."
|
||||||
--disable-programs \
|
--disable-programs \
|
||||||
--disable-network \
|
--disable-network \
|
||||||
\
|
\
|
||||||
|
--enable-libvpx \
|
||||||
|
--enable-decoder=libvpx_vp9 \
|
||||||
--enable-runtime-cpudetect \
|
--enable-runtime-cpudetect \
|
||||||
--enable-pthreads \
|
--enable-pthreads \
|
||||||
--enable-avresample \
|
--enable-avresample \
|
||||||
|
@ -57,6 +89,7 @@ echo "Configuring..."
|
||||||
--enable-demuxer=mov \
|
--enable-demuxer=mov \
|
||||||
--enable-demuxer=gif \
|
--enable-demuxer=gif \
|
||||||
--enable-demuxer=ogg \
|
--enable-demuxer=ogg \
|
||||||
|
--enable-demuxer=matroska \
|
||||||
--enable-hwaccels \
|
--enable-hwaccels \
|
||||||
--enable-runtime-cpudetect \
|
--enable-runtime-cpudetect \
|
||||||
$ADDITIONAL_CONFIGURE_FLAG
|
$ADDITIONAL_CONFIGURE_FLAG
|
||||||
|
@ -67,8 +100,6 @@ make -j8 install
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NDK=path_to_ndk
|
|
||||||
|
|
||||||
#x86_64
|
#x86_64
|
||||||
PREBUILT=$NDK/toolchains/x86_64-4.9/prebuilt/darwin-x86_64
|
PREBUILT=$NDK/toolchains/x86_64-4.9/prebuilt/darwin-x86_64
|
||||||
PLATFORM=$NDK/platforms/android-21/arch-x86_64
|
PLATFORM=$NDK/platforms/android-21/arch-x86_64
|
||||||
|
@ -80,7 +111,7 @@ CC=$PREBUILT/bin/x86_64-linux-android-gcc
|
||||||
CROSS_PREFIX=$PREBUILT/bin/x86_64-linux-android-
|
CROSS_PREFIX=$PREBUILT/bin/x86_64-linux-android-
|
||||||
ARCH=x86_64
|
ARCH=x86_64
|
||||||
CPU=x86_64
|
CPU=x86_64
|
||||||
PREFIX=./android/$CPU
|
PREFIX=./android/x86_64
|
||||||
ADDITIONAL_CONFIGURE_FLAG="--disable-mmx --disable-inline-asm"
|
ADDITIONAL_CONFIGURE_FLAG="--disable-mmx --disable-inline-asm"
|
||||||
build_one
|
build_one
|
||||||
|
|
||||||
|
@ -96,7 +127,7 @@ CROSS_PREFIX=$PREBUILT/bin/aarch64-linux-android-
|
||||||
ARCH=arm64
|
ARCH=arm64
|
||||||
CPU=arm64-v8a
|
CPU=arm64-v8a
|
||||||
OPTIMIZE_CFLAGS=
|
OPTIMIZE_CFLAGS=
|
||||||
PREFIX=./android/$CPU
|
PREFIX=./android/arm64-v8a
|
||||||
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --enable-optimizations"
|
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --enable-optimizations"
|
||||||
build_one
|
build_one
|
||||||
|
|
||||||
|
@ -112,7 +143,7 @@ CROSS_PREFIX=$PREBUILT/bin/arm-linux-androideabi-
|
||||||
ARCH=arm
|
ARCH=arm
|
||||||
CPU=armv7-a
|
CPU=armv7-a
|
||||||
OPTIMIZE_CFLAGS="-marm -march=$CPU"
|
OPTIMIZE_CFLAGS="-marm -march=$CPU"
|
||||||
PREFIX=./android/$CPU
|
PREFIX=./android/armeabi-v7a
|
||||||
ADDITIONAL_CONFIGURE_FLAG=--enable-neon
|
ADDITIONAL_CONFIGURE_FLAG=--enable-neon
|
||||||
build_one
|
build_one
|
||||||
|
|
||||||
|
@ -128,8 +159,14 @@ CROSS_PREFIX=$PREBUILT/bin/i686-linux-android-
|
||||||
ARCH=x86
|
ARCH=x86
|
||||||
CPU=i686
|
CPU=i686
|
||||||
OPTIMIZE_CFLAGS="-march=$CPU"
|
OPTIMIZE_CFLAGS="-march=$CPU"
|
||||||
PREFIX=./android/$CPU
|
PREFIX=./android/x86
|
||||||
ADDITIONAL_CONFIGURE_FLAG="--disable-mmx --disable-yasm"
|
ADDITIONAL_CONFIGURE_FLAG="--disable-mmx --disable-yasm"
|
||||||
build_one
|
build_one
|
||||||
|
|
||||||
|
if [[ -e ./build_ffmpeg/android ]]; then
|
||||||
|
rm -rf ./build_ffmpeg/android
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv ./android ./build_ffmpeg/
|
||||||
|
|
||||||
|
|
103
TMessagesProj/jni/ffmpeg/build_ffmpeg/vpx-android/_settings.sh
Normal file
103
TMessagesProj/jni/ffmpeg/build_ffmpeg/vpx-android/_settings.sh
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z $ANDROID_NDK ]] || [[ ! -d $ANDROID_NDK ]] ; then
|
||||||
|
echo "You need to set ANDROID_NDK environment variable, exiting"
|
||||||
|
echo "Use: export ANDROID_NDK=/your/path/to/android-ndk-rxx"
|
||||||
|
echo "e.g.: export ANDROID_NDK=/opt/android/android-ndk-r18b"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
ANDROID_API=21
|
||||||
|
|
||||||
|
ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64")
|
||||||
|
|
||||||
|
BASEDIR=`pwd`
|
||||||
|
NDK=${ANDROID_NDK}
|
||||||
|
HOST_NUM_CORES=$(nproc)
|
||||||
|
|
||||||
|
CFLAGS_="-DANDROID -fpic -fpie"
|
||||||
|
LDFLAGS_=""
|
||||||
|
|
||||||
|
configure() {
|
||||||
|
ABI=$1;
|
||||||
|
|
||||||
|
case $ABI in
|
||||||
|
armeabi)
|
||||||
|
NDK_ARCH="arm"
|
||||||
|
NDK_ABIARCH="arm-linux-androideabi"
|
||||||
|
CFLAGS="-march=armv5 -marm -finline-limit=64"
|
||||||
|
LDFLAGS=""
|
||||||
|
ASFLAGS=""
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
NDK_ARCH="arm"
|
||||||
|
NDK_ABIARCH="arm-linux-androideabi"
|
||||||
|
CFLAGS="${CFLAGS_} -Os -march=armv7-a -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -mthumb -D__thumb__"
|
||||||
|
LDFLAGS="${LDFLAGS_} -march=armv7-a"
|
||||||
|
ASFLAGS=""
|
||||||
|
;;
|
||||||
|
arm64-v8a)
|
||||||
|
NDK_ARCH="arm64"
|
||||||
|
NDK_ABIARCH="aarch64-linux-android"
|
||||||
|
CFLAGS="${CFLAGS_} -O3 -march=armv8-a"
|
||||||
|
LDFLAGS="${LDFLAGS_}"
|
||||||
|
ASFLAGS=""
|
||||||
|
;;
|
||||||
|
x86)
|
||||||
|
NDK_ARCH="x86"
|
||||||
|
NDK_ABIARCH="i686-linux-android"
|
||||||
|
CFLAGS="${CFLAGS_} -O3 -march=i686 -mtune=intel -msse3 -mfpmath=sse -m32 -fPIC"
|
||||||
|
LDFLAGS="-m32"
|
||||||
|
ASFLAGS="-D__ANDROID__"
|
||||||
|
;;
|
||||||
|
x86_64)
|
||||||
|
NDK_ARCH="x86_64"
|
||||||
|
NDK_ABIARCH="x86_64-linux-android"
|
||||||
|
CFLAGS="${CFLAGS_} -O3 -march=x86-64 -mtune=intel -msse4.2 -mpopcnt -m64 -fPIC"
|
||||||
|
LDFLAGS=""
|
||||||
|
ASFLAGS="-D__ANDROID__"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
TOOLCHAIN_PREFIX=${BASEDIR}/android-toolchain
|
||||||
|
NDK_SYSROOT=${TOOLCHAIN_PREFIX}/sysroot
|
||||||
|
|
||||||
|
if [[ -e ${TOOLCHAIN_PREFIX} ]]; then
|
||||||
|
rm -rf ${TOOLCHAIN_PREFIX}
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -d ${TOOLCHAIN_PREFIX} ]] || python ${NDK}/build/tools/make_standalone_toolchain.py \
|
||||||
|
--arch ${NDK_ARCH} \
|
||||||
|
--api ${ANDROID_API} \
|
||||||
|
--stl libc++ \
|
||||||
|
--install-dir=${TOOLCHAIN_PREFIX}
|
||||||
|
|
||||||
|
PREFIX=../../../android/${ABI}
|
||||||
|
|
||||||
|
|
||||||
|
export PATH=${TOOLCHAIN_PREFIX}/bin:$PATH
|
||||||
|
export CROSS_PREFIX=${TOOLCHAIN_PREFIX}/bin/${NDK_ABIARCH}-
|
||||||
|
export CFLAGS="${CFLAGS}"
|
||||||
|
export CPPFLAGS="${CFLAGS}"
|
||||||
|
export CXXFLAGS="${CFLAGS} -std=c++11"
|
||||||
|
export ASFLAGS="${ASFLAGS}"
|
||||||
|
export LDFLAGS="${LDFLAGS} -L${NDK_SYSROOT}/usr/lib"
|
||||||
|
|
||||||
|
export AR="${CROSS_PREFIX}ar"
|
||||||
|
export AS="${CROSS_PREFIX}clang"
|
||||||
|
export CC="${CROSS_PREFIX}clang"
|
||||||
|
export CXX="${CROSS_PREFIX}clang++"
|
||||||
|
export LD="${CROSS_PREFIX}ld"
|
||||||
|
export STRIP="${CROSS_PREFIX}strip"
|
||||||
|
export RANLIB="${CROSS_PREFIX}ranlib"
|
||||||
|
export CPP="${CROSS_PREFIX}cpp"
|
||||||
|
export NM="${CROSS_PREFIX}nm"
|
||||||
|
|
||||||
|
echo "**********************************************"
|
||||||
|
echo "### Use NDK=${NDK}"
|
||||||
|
echo "### Use ANDROID_API=${ANDROID_API}"
|
||||||
|
echo "### Install directory: PREFIX=${PREFIX}"
|
||||||
|
echo "**********************************************"
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -u
|
||||||
|
. _settings.sh
|
||||||
|
|
||||||
|
LIB_VPX="libvpx"
|
||||||
|
LIB_GIT=v1.10.0
|
||||||
|
|
||||||
|
if [[ -f "${LIB_VPX}/build/make/version.sh" ]]; then
|
||||||
|
version=`"${LIB_VPX}/build/make/version.sh" --bare "${LIB_VPX}"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
configure_make() {
|
||||||
|
pushd "${LIB_VPX}" || exit
|
||||||
|
ABI=$1;
|
||||||
|
echo -e "\n** BUILD STARTED: ${LIB_VPX} (${version}) for ${ABI} **"
|
||||||
|
|
||||||
|
configure "$@"
|
||||||
|
case ${ABI} in
|
||||||
|
armeabi)
|
||||||
|
TARGET="armv7-android-gcc --disable-neon --disable-neon-asm"
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
TARGET="armv7-android-gcc --enable-neon --disable-neon-asm"
|
||||||
|
;;
|
||||||
|
arm64-v8a)
|
||||||
|
TARGET="arm64-android-gcc"
|
||||||
|
;;
|
||||||
|
x86)
|
||||||
|
TARGET="x86-android-gcc"
|
||||||
|
;;
|
||||||
|
x86_64)
|
||||||
|
TARGET="x86_64-android-gcc"
|
||||||
|
;;
|
||||||
|
mips)
|
||||||
|
TARGET="mips32-linux-gcc"
|
||||||
|
;;
|
||||||
|
mips64)
|
||||||
|
TARGET="mips64-linux-gcc"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
CPU_DETECT="--disable-runtime-cpu-detect"
|
||||||
|
if [[ $1 =~ x86.* ]]; then
|
||||||
|
CPU_DETECT="--enable-runtime-cpu-detect"
|
||||||
|
fi
|
||||||
|
|
||||||
|
./configure \
|
||||||
|
--extra-cflags="-isystem ${NDK_SYSROOT}/usr/include/${NDK_ABIARCH} -isystem ${NDK_SYSROOT}/usr/include" \
|
||||||
|
--libc=${NDK_SYSROOT} \
|
||||||
|
--prefix=${PREFIX} \
|
||||||
|
--target=${TARGET} \
|
||||||
|
${CPU_DETECT} \
|
||||||
|
--as=auto \
|
||||||
|
--disable-docs \
|
||||||
|
--enable-pic \
|
||||||
|
--enable-libyuv \
|
||||||
|
--enable-static \
|
||||||
|
--enable-small \
|
||||||
|
--enable-optimizations \
|
||||||
|
--enable-better-hw-compatibility \
|
||||||
|
--enable-realtime-only \
|
||||||
|
--enable-vp8 \
|
||||||
|
--enable-vp9 \
|
||||||
|
--disable-webm-io \
|
||||||
|
--disable-examples \
|
||||||
|
--disable-tools \
|
||||||
|
--disable-debug \
|
||||||
|
--disable-unit-tests || exit 1
|
||||||
|
|
||||||
|
make -j${HOST_NUM_CORES} install
|
||||||
|
popd || true
|
||||||
|
}
|
||||||
|
|
||||||
|
for ((i=0; i < ${#ABIS[@]}; i++))
|
||||||
|
do
|
||||||
|
if [[ $# -eq 0 ]] || [[ "$1" == "${ABIS[i]}" ]]; then
|
||||||
|
[[ ${ANDROID_API} -lt 21 ]] && ( echo "${ABIS[i]}" | grep 64 > /dev/null ) && continue;
|
||||||
|
configure_make "${ABIS[i]}"
|
||||||
|
echo -e "** BUILD COMPLETED: ${LIB_VPX} for ${ABIS[i]} **\n\n"
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in a new issue