diff --git a/.travis.yml b/.travis.yml index cbcfcc4..453e913 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ install: - curl http://archive.ubuntu.com/ubuntu/pool/universe/n/nasm/nasm_2.14.02-1_amd64.deb --output $HOME/nasm_2.14.02-1_amd64.deb - sudo dpkg -i $HOME/nasm_2.14.02-1_amd64.deb script: - - ./ffmpeg-android-maker.sh -all -android=18 + - ./ffmpeg-android-maker.sh -all-free -all-gpl -android=18 diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 402e442..db8c7bc 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -10,6 +10,10 @@ case $ANDROID_ABI in ;; esac +if [ "$FFMPEG_GPL_ENABLED" = true ] ; then + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-gpl" +fi + # Preparing flags for enabling requested libraries ADDITIONAL_COMPONENTS= for LIBARY_NAME in ${FFMPEG_EXTERNAL_LIBRARIES[@]} diff --git a/scripts/libx264/build.sh b/scripts/libx264/build.sh new file mode 100755 index 0000000..14198ad --- /dev/null +++ b/scripts/libx264/build.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +X264_AS=${FAM_CC} + +X264_ADDITIONAL_FLAGS= + +case $ANDROID_ABI in + x86) + # Disabling assembler optimizations due to text relocations + X264_ADDITIONAL_FLAGS=--disable-asm + ;; + x86_64) + X264_AS=${NASM_EXECUTABLE} + ;; +esac + +CC=${FAM_CC} \ +AR=${FAM_AR} \ +AS=${X264_AS} \ +RANLIB=${FAM_RANLIB} \ +STRIP=${FAM_STRIP} \ +./configure \ + --prefix=${INSTALL_DIR} \ + --host=${TARGET} \ + --sysroot=${SYSROOT_PATH} \ + --enable-pic \ + --enable-static \ + --disable-cli \ + --disable-avs \ + --disable-lavf \ + --disable-cli \ + --disable-ffms \ + --disable-opencl \ + --chroma-format=all \ + --bit-depth=all \ + ${X264_ADDITIONAL_FLAGS} || exit 1 + +${MAKE_EXECUTABLE} clean +${MAKE_EXECUTABLE} -j${HOST_NPROC} +${MAKE_EXECUTABLE} install diff --git a/scripts/libx264/download.sh b/scripts/libx264/download.sh new file mode 100755 index 0000000..46cec38 --- /dev/null +++ b/scripts/libx264/download.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +source ${SCRIPTS_DIR}/common-functions.sh + +# Libx264 doesn't have any versioning system. Currently it has 2 branches: master and stable. +# Latest commit in stable branch +# Tue Jun 30 22:28:05 2020 +0300 +LIBX264_VERSION=cde9a93319bea766a92e306d69059c76de970190 + +downloadTarArchive \ + "libx264" \ + "https://code.videolan.org/videolan/x264/-/archive/${LIBX264_VERSION}/x264-${LIBX264_VERSION}.tar.gz" diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index cd46652..a27fb8d 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -12,8 +12,10 @@ SOURCE_TYPE=TAR SOURCE_VALUE=4.3.1 BINUTILS=gnu EXTERNAL_LIBRARIES=() +FFMPEG_GPL_ENABLED=false -ALL_SUPPORTED_LIBRARIES=( +# All FREE libraries that are supported +SUPPORTED_LIBRARIES_FREE=( "libaom" "libdav1d" "libmp3lame" @@ -26,95 +28,108 @@ ALL_SUPPORTED_LIBRARIES=( "libfribidi" ) +# All GPL libraries that are supported +SUPPORTED_LIBRARIES_GPL=( + "libx264" +) + for argument in "$@"; do case $argument in - # Build for only specified ABIs (separated by comma) - --target-abis=*|-abis=*) - IFS=',' read -ra ABIS <<< "${argument#*=}" - for abi in "${ABIS[@]}"; do - case $abi in - x86|x86_64|armeabi-v7a|arm64-v8a) - ABIS_TO_BUILD+=( "$abi" ) - ;; - arm) - ABIS_TO_BUILD+=( "armeabi-v7a" ) - ;; - arm64) - ABIS_TO_BUILD+=( "arm64-v8a" ) - ;; - *) - echo "Unknown ABI: $abi" - ;; - esac - done - ;; - # Use this value as Android platform version during compilation. - --android-api-level=*|-android=*) - API_LEVEL="${argument#*=}" - ;; - # Checkout the particular tag in the FFmpeg's git repository - --source-git-tag=*) - SOURCE_TYPE=GIT_TAG - SOURCE_VALUE="${argument#*=}" - ;; - # Checkout the particular branch in the FFmpeg's git repository - --source-git-branch=*) - SOURCE_TYPE=GIT_BRANCH - SOURCE_VALUE="${argument#*=}" - ;; - # Download the particular tar archive by its version - --source-tar=*) - SOURCE_TYPE=TAR - SOURCE_VALUE="${argument#*=}" - ;; - # Which binutils to use (gnu or llvm) - --binutils=*|-binutils=*) - binutils_value="${argument#*=}" - case $binutils_value in - gnu|llvm) - BINUTILS=$binutils_value + # Build for only specified ABIs (separated by comma) + --target-abis=* | -abis=*) + IFS=',' read -ra ABIS <<<"${argument#*=}" + for abi in "${ABIS[@]}"; do + case $abi in + x86 | x86_64 | armeabi-v7a | arm64-v8a) + ABIS_TO_BUILD+=("$abi") + ;; + arm) + ABIS_TO_BUILD+=("armeabi-v7a") + ;; + arm64) + ABIS_TO_BUILD+=("arm64-v8a") ;; - *) - echo "Unknown binutils: $binutils_value" + *) + echo "Unknown ABI: $abi" ;; esac + done + ;; + # Use this value as Android platform version during compilation. + --android-api-level=* | -android=*) + API_LEVEL="${argument#*=}" + ;; + # Checkout the particular tag in the FFmpeg's git repository + --source-git-tag=*) + SOURCE_TYPE=GIT_TAG + SOURCE_VALUE="${argument#*=}" + ;; + # Checkout the particular branch in the FFmpeg's git repository + --source-git-branch=*) + SOURCE_TYPE=GIT_BRANCH + SOURCE_VALUE="${argument#*=}" + ;; + # Download the particular tar archive by its version + --source-tar=*) + SOURCE_TYPE=TAR + SOURCE_VALUE="${argument#*=}" + ;; + # Which binutils to use (gnu or llvm) + --binutils=* | -binutils=*) + binutils_value="${argument#*=}" + case $binutils_value in + gnu | llvm) + BINUTILS=$binutils_value + ;; + *) + echo "Unknown binutils: $binutils_value" + ;; + esac ;; - # Arguments below enable certain external libraries to build into FFmpeg - --enable-libaom|-aom) - EXTERNAL_LIBRARIES+=( "libaom" ) + # Arguments below enable certain external libraries to build into FFmpeg + --enable-libaom | -aom) + EXTERNAL_LIBRARIES+=("libaom") ;; - --enable-libdav1d|-dav1d) - EXTERNAL_LIBRARIES+=( "libdav1d" ) + --enable-libdav1d | -dav1d) + EXTERNAL_LIBRARIES+=("libdav1d") ;; - --enable-libmp3lame|-mp3lame|-lame) - EXTERNAL_LIBRARIES+=( "libmp3lame" ) + --enable-libmp3lame | -mp3lame | -lame) + EXTERNAL_LIBRARIES+=("libmp3lame") ;; - --enable-libopus|-opus) - EXTERNAL_LIBRARIES+=( "libopus" ) + --enable-libopus | -opus) + EXTERNAL_LIBRARIES+=("libopus") ;; - --enable-libwavpack|-wavpack) - EXTERNAL_LIBRARIES+=( "libwavpack" ) + --enable-libwavpack | -wavpack) + EXTERNAL_LIBRARIES+=("libwavpack") ;; - --enable-libtwolame|-twolame) - EXTERNAL_LIBRARIES+=( "libtwolame" ) + --enable-libtwolame | -twolame) + EXTERNAL_LIBRARIES+=("libtwolame") ;; - --enable-libspeex|-speex) - EXTERNAL_LIBRARIES+=( "libspeex" ) + --enable-libspeex | -speex) + EXTERNAL_LIBRARIES+=("libspeex") ;; - --enable-libvpx|-vpx) - EXTERNAL_LIBRARIES+=( "libvpx" ) + --enable-libvpx | -vpx) + EXTERNAL_LIBRARIES+=("libvpx") ;; - --enable-libfreetype|-freetype) - EXTERNAL_LIBRARIES+=( "libfreetype" ) + --enable-libfreetype | -freetype) + EXTERNAL_LIBRARIES+=("libfreetype") ;; - --enable-libfribidi|-fribidi) - EXTERNAL_LIBRARIES+=( "libfribidi" ) + --enable-libfribidi | -fribidi) + EXTERNAL_LIBRARIES+=("libfribidi") ;; - --enable-all-external|-all) - EXTERNAL_LIBRARIES=${ALL_SUPPORTED_LIBRARIES[@]} + --enable-libx264 | -x264) + EXTERNAL_LIBRARIES+=("libx264") + FFMPEG_GPL_ENABLED=true ;; - *) - echo "Unknown argument $argument" + --enable-all-free | -all-free) + EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_FREE[@]}" + ;; + --enable-all-gpl | -all-gpl) + EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_GPL[@]}" + FFMPEG_GPL_ENABLED=true + ;; + *) + echo "Unknown argument $argument" ;; esac shift @@ -124,7 +139,7 @@ done # The x86 is the first, because it is more likely to have Text Relocations. # In this case the rest ABIs will not be assembled at all. if [ ${#ABIS_TO_BUILD[@]} -eq 0 ]; then - ABIS_TO_BUILD=( "x86" "x86_64" "armeabi-v7a" "arm64-v8a" ) + ABIS_TO_BUILD=("x86" "x86_64" "armeabi-v7a" "arm64-v8a") fi # The FFmpeg will be build for ABIs in this list export FFMPEG_ABIS_TO_BUILD=${ABIS_TO_BUILD[@]}