ffmpeg-kit/scripts/android/ffmpeg.sh

481 lines
19 KiB
Bash
Raw Normal View History

2020-08-05 03:53:02 +03:00
#!/bin/bash
HOST_PKG_CONFIG_PATH=$(command -v pkg-config)
if [ -z "${HOST_PKG_CONFIG_PATH}" ]; then
echo -e "\n(*) pkg-config command not found\n"
exit 1
fi
2020-11-23 00:51:45 +02:00
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
2020-08-05 03:53:02 +03:00
LIB_NAME="ffmpeg"
2020-11-23 00:51:45 +02:00
echo -e "----------------------------------------------------------------" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "\nINFO: Building ${LIB_NAME} with the following environment variables\n" 1>>"${BASEDIR}"/build.log 2>&1
env 1>>"${BASEDIR}"/build.log 2>&1
echo -e "----------------------------------------------------------------\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: System information\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: $(uname -a)\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "----------------------------------------------------------------\n" 1>>"${BASEDIR}"/build.log 2>&1
FFMPEG_LIBRARY_PATH="${LIB_INSTALL_BASE}/${LIB_NAME}"
ANDROID_SYSROOT="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/"${TOOLCHAIN}"/sysroot
# SET PATHS
set_toolchain_paths "${LIB_NAME}"
# SET BUILD FLAGS
HOST=$(get_host)
export CFLAGS=$(get_cflags "${LIB_NAME}")
export CXXFLAGS=$(get_cxxflags "${LIB_NAME}")
export LDFLAGS=$(get_ldflags "${LIB_NAME}")
2020-08-05 03:53:02 +03:00
export PKG_CONFIG_LIBDIR="${INSTALL_PKG_CONFIG_DIR}"
2020-11-23 00:51:45 +02:00
cd "${BASEDIR}"/src/"${LIB_NAME}" 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
# SET BUILD OPTIONS
2020-08-05 03:53:02 +03:00
TARGET_CPU=""
TARGET_ARCH=""
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=""
2020-08-05 03:53:02 +03:00
case ${ARCH} in
arm-v7a)
TARGET_CPU="armv7-a"
TARGET_ARCH="armv7-a"
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=" --disable-neon --enable-asm --enable-inline-asm"
2020-08-05 03:53:02 +03:00
;;
arm-v7a-neon)
TARGET_CPU="armv7-a"
TARGET_ARCH="armv7-a"
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm --build-suffix=_neon"
2020-08-05 03:53:02 +03:00
;;
arm64-v8a)
TARGET_CPU="armv8-a"
TARGET_ARCH="aarch64"
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm"
2020-08-05 03:53:02 +03:00
;;
x86)
TARGET_CPU="i686"
TARGET_ARCH="i686"
# asm disabled due to this ticket https://trac.ffmpeg.org/ticket/4928
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=" --disable-neon --disable-asm --disable-inline-asm"
2020-08-05 03:53:02 +03:00
;;
x86-64)
TARGET_CPU="x86_64"
TARGET_ARCH="x86_64"
2020-11-23 00:51:45 +02:00
ASM_OPTIONS=" --disable-neon --enable-asm --enable-inline-asm"
2020-08-05 03:53:02 +03:00
;;
esac
CONFIGURE_POSTFIX=""
HIGH_PRIORITY_INCLUDES=""
2020-11-23 00:51:45 +02:00
# SET CONFIGURE OPTIONS
2020-08-05 03:53:02 +03:00
for library in {1..58}; do
if [[ ${!library} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name $((library - 1)))
echo -e "INFO: Enabling library ${ENABLED_LIBRARY}\n" 1>>"${BASEDIR}"/build.log 2>&1
2020-11-23 00:51:45 +02:00
case ${ENABLED_LIBRARY} in
2020-08-05 03:53:02 +03:00
chromaprint)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libchromaprint 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libchromaprint 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-chromaprint"
;;
cpu-features)
2020-11-23 00:51:45 +02:00
pkg-config --libs --static cpu-features 2>>"${BASEDIR}"/build.log 1>/dev/null
2020-08-05 03:53:02 +03:00
if [[ $? -eq 1 ]]; then
2020-11-23 00:51:45 +02:00
echo -e "ERROR: cpu-features was not found in the pkg-config search path\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "\nffmpeg: failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
fi
;;
fontconfig)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags fontconfig 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static fontconfig 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libfontconfig"
;;
freetype)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags freetype2 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static freetype2 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libfreetype"
;;
fribidi)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags fribidi 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static fribidi 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libfribidi"
;;
gmp)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags gmp 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static gmp 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-gmp"
;;
gnutls)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags gnutls 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static gnutls 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-gnutls"
;;
kvazaar)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags kvazaar 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static kvazaar 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libkvazaar"
;;
lame)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libmp3lame 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libmp3lame 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libmp3lame"
;;
libaom)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags aom 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static aom 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libaom"
;;
libass)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libass 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libass 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libass"
;;
libiconv)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libiconv 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libiconv 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-iconv"
2020-11-23 00:51:45 +02:00
HIGH_PRIORITY_INCLUDES+=" $(pkg-config --cflags libiconv 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
libilbc)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libilbc 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libilbc 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libilbc"
;;
libtheora)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags theora 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static theora 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libtheora"
;;
libvidstab)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags vidstab 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static vidstab 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libvidstab --enable-gpl"
;;
libvorbis)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags vorbis 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static vorbis 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libvorbis"
;;
libvpx)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags vpx 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs vpx 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs cpu-features 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libvpx"
;;
libwebp)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libwebp 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libwebp 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libwebp"
;;
libxml2)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libxml-2.0 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libxml-2.0 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libxml2"
;;
opencore-amr)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags opencore-amrnb 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static opencore-amrnb 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libopencore-amrnb"
;;
openh264)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags openh264 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static openh264 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libopenh264"
;;
opus)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags opus 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static opus 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libopus"
;;
rubberband)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags rubberband 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static rubberband 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-librubberband --enable-gpl"
;;
sdl)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags sdl2 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static sdl2 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-sdl2"
;;
2020-11-23 00:51:45 +02:00
shine)
CFLAGS+=" $(pkg-config --cflags shine 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static shine 2>>"${BASEDIR}"/build.log)"
CONFIGURE_POSTFIX+=" --enable-libshine"
;;
2020-08-05 03:53:02 +03:00
snappy)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags snappy 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static snappy 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libsnappy"
;;
soxr)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags soxr 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static soxr 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libsoxr"
;;
speex)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags speex 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static speex 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libspeex"
;;
tesseract)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags tesseract 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static tesseract 2>>"${BASEDIR}"/build.log)"
CFLAGS+=" $(pkg-config --cflags giflib 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static giflib 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libtesseract"
;;
twolame)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags twolame 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static twolame 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libtwolame"
;;
vo-amrwbenc)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags vo-amrwbenc 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static vo-amrwbenc 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libvo-amrwbenc"
;;
wavpack)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags wavpack 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static wavpack 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libwavpack"
;;
x264)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags x264 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static x264 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libx264 --enable-gpl"
;;
x265)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags x265 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static x265 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libx265 --enable-gpl"
;;
xvidcore)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags xvidcore 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static xvidcore 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-libxvid --enable-gpl"
;;
expat)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags expat 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static expat 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
libogg)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags ogg 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static ogg 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
libpng)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags libpng 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static libpng 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
libuuid)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags uuid 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static uuid 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
nettle)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags nettle 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static nettle 2>>"${BASEDIR}"/build.log)"
CFLAGS+=" $(pkg-config --cflags hogweed 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static hogweed 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
;;
android-zlib)
2020-11-23 00:51:45 +02:00
CFLAGS+=" $(pkg-config --cflags zlib 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static zlib 2>>"${BASEDIR}"/build.log)"
2020-08-05 03:53:02 +03:00
CONFIGURE_POSTFIX+=" --enable-zlib"
;;
android-media-codec)
CONFIGURE_POSTFIX+=" --enable-mediacodec"
;;
esac
else
# THE FOLLOWING LIBRARIES SHOULD BE EXPLICITLY DISABLED TO PREVENT AUTODETECT
# NOTE THAT IDS MUST BE +1 OF THE INDEX VALUE
if [[ ${library} -eq $((LIBRARY_SDL + 1)) ]]; then
CONFIGURE_POSTFIX+=" --disable-sdl2"
elif [[ ${library} -eq $((LIBRARY_ANDROID_ZLIB + 1)) ]]; then
CONFIGURE_POSTFIX+=" --disable-zlib"
elif [[ ${library} -eq $((LIBRARY_ANDROID_MEDIA_CODEC + 1)) ]]; then
CONFIGURE_POSTFIX+=" --disable-mediacodec"
fi
fi
done
2020-11-23 00:51:45 +02:00
export LDFLAGS+=" -L${ANDROID_NDK_ROOT}/platforms/android-${API}/arch-${TOOLCHAIN_ARCH}/usr/lib"
2020-08-05 03:53:02 +03:00
# LINKING WITH ANDROID LTS SUPPORT LIBRARY IS NECESSARY FOR API < 18
if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]] && [[ ${API} -lt 18 ]]; then
2020-11-23 00:51:45 +02:00
export LDFLAGS+=" -Wl,--whole-archive ${BASEDIR}/android/app/src/main/cpp/libandroidltssupport.a -Wl,--no-whole-archive"
2020-08-05 03:53:02 +03:00
fi
# ALWAYS BUILD SHARED LIBRARIES
BUILD_LIBRARY_OPTIONS="--disable-static --enable-shared"
# OPTIMIZE FOR SPEED INSTEAD OF SIZE
if [[ -z ${FFMPEG_KIT_OPTIMIZED_FOR_SPEED} ]]; then
SIZE_OPTIONS="--enable-small"
else
SIZE_OPTIONS=""
fi
# SET DEBUG OPTIONS
if [[ -z ${FFMPEG_KIT_DEBUG} ]]; then
# SET LTO FLAGS
if [[ -z ${NO_LINK_TIME_OPTIMIZATION} ]]; then
DEBUG_OPTIONS="--disable-debug --enable-lto"
else
DEBUG_OPTIONS="--disable-debug --disable-lto"
fi
else
DEBUG_OPTIONS="--enable-debug --disable-stripping"
fi
echo -n -e "\n${LIB_NAME}: "
if [[ -z ${NO_WORKSPACE_CLEANUP_ffmpeg} ]]; then
echo -e "INFO: Cleaning workspace for ${LIB_NAME}\n" 1>>"${BASEDIR}"/build.log 2>&1
make distclean 2>/dev/null 1>/dev/null
fi
2020-11-23 00:51:45 +02:00
# UPDATE BUILD FLAGS
2020-08-05 03:53:02 +03:00
export CFLAGS="${HIGH_PRIORITY_INCLUDES} ${CFLAGS}"
# USE HIGHER LIMITS FOR FFMPEG LINKING
ulimit -n 2048 1>>"${BASEDIR}"/build.log 2>&1
########################### CUSTOMIZATIONS #######################
# 1. Use thread local log levels
2020-11-23 00:51:45 +02:00
${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR}"/src/"${LIB_NAME}"/libavutil/log.c 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
2020-08-05 03:53:02 +03:00
###################################################################
./configure \
2020-11-23 00:51:45 +02:00
--cross-prefix="${HOST}-" \
--sysroot="${ANDROID_SYSROOT}" \
--prefix="${FFMPEG_LIBRARY_PATH}" \
2020-08-05 03:53:02 +03:00
--pkg-config="${HOST_PKG_CONFIG_PATH}" \
--enable-version3 \
--arch="${TARGET_ARCH}" \
--cpu="${TARGET_CPU}" \
--cc="${CC}" \
--cxx="${CXX}" \
2020-11-23 00:51:45 +02:00
--ranlib="${RANLIB}" \
--strip="${STRIP}" \
--nm="${NM}" \
--extra-libs="$(pkg-config --libs --static cpu-features)" \
2020-08-05 03:53:02 +03:00
--target-os=android \
2020-11-23 00:51:45 +02:00
${ASM_OPTIONS} \
2020-08-05 03:53:02 +03:00
--enable-cross-compile \
--enable-pic \
--enable-jni \
--enable-optimizations \
--enable-swscale \
${BUILD_LIBRARY_OPTIONS} \
--enable-v4l2-m2m \
--disable-outdev=fbdev \
--disable-indev=fbdev \
${SIZE_OPTIONS} \
--disable-openssl \
--disable-xmm-clobber-test \
${DEBUG_OPTIONS} \
--disable-neon-clobber-test \
--disable-programs \
--disable-postproc \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-sndio \
--disable-schannel \
--disable-securetransport \
--disable-xlib \
--disable-cuda \
--disable-cuvid \
--disable-nvenc \
--disable-vaapi \
--disable-vdpau \
--disable-videotoolbox \
--disable-audiotoolbox \
--disable-appkit \
--disable-alsa \
--disable-cuda \
--disable-cuvid \
--disable-nvenc \
--disable-vaapi \
--disable-vdpau \
${CONFIGURE_POSTFIX} 1>>"${BASEDIR}"/build.log 2>&1
2020-11-23 00:51:45 +02:00
if [[ $? -ne 0 ]]; then
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
fi
if [[ -z ${NO_OUTPUT_REDIRECTION} ]]; then
make -j$(get_cpu_count) 1>>"${BASEDIR}"/build.log 2>&1
2020-11-23 00:51:45 +02:00
if [[ $? -ne 0 ]]; then
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
fi
else
echo -e "started\n"
2020-11-23 00:51:45 +02:00
make -j$(get_cpu_count)
2020-08-05 03:53:02 +03:00
2020-11-23 00:51:45 +02:00
if [[ $? -ne 0 ]]; then
echo -n -e "\n${LIB_NAME}: failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
else
echo -n -e "\n${LIB_NAME}: "
fi
fi
2020-11-23 00:51:45 +02:00
# DELETE THE PREVIOUS BUILD OF THE LIBRARY BEFORE INSTALLING
if [ -d "${FFMPEG_LIBRARY_PATH}" ]; then
rm -rf "${FFMPEG_LIBRARY_PATH}" 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
fi
2020-08-05 03:53:02 +03:00
make install 1>>"${BASEDIR}"/build.log 2>&1
2020-11-23 00:51:45 +02:00
if [[ $? -ne 0 ]]; then
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
fi
# MANUALLY ADD REQUIRED HEADERS
2020-11-23 00:51:45 +02:00
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86 1>>"${BASEDIR}"/build.log 2>&1
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/arm 1>>"${BASEDIR}"/build.log 2>&1
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/aarch64 1>>"${BASEDIR}"/build.log 2>&1
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavcodec/x86 1>>"${BASEDIR}"/build.log 2>&1
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavcodec/arm 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/config.h "${FFMPEG_LIBRARY_PATH}"/include/config.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/mathops.h "${FFMPEG_LIBRARY_PATH}"/include/libavcodec/mathops.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/x86/mathops.h "${FFMPEG_LIBRARY_PATH}"/include/libavcodec/x86/mathops.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/arm/mathops.h "${FFMPEG_LIBRARY_PATH}"/include/libavcodec/arm/mathops.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/network.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/network.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/os_support.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/os_support.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/url.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/url.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/internal.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/internal.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/libm.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/libm.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/reverse.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/reverse.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/thread.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/thread.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/timer.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/timer.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/x86/asm.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86/asm.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/x86/timer.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86/timer.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/arm/timer.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/arm/timer.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/aarch64/timer.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/aarch64/timer.h 1>>"${BASEDIR}"/build.log 2>&1
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/x86/emms.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86/emms.h 1>>"${BASEDIR}"/build.log 2>&1
2020-08-05 03:53:02 +03:00
if [ $? -eq 0 ]; then
echo "ok"
else
2020-11-23 00:51:45 +02:00
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
fi