Merge branch 'master' into what-the-codec

media-file
Javernaut 4 years ago
commit f02599f7cb
  1. 15
      .travis.yml
  2. 24
      README.md
  3. 2
      scripts/common-functions.sh
  4. 2
      scripts/export-build-variables.sh
  5. 4
      scripts/export-host-variables.sh
  6. 8
      scripts/ffmpeg/build.sh
  7. 2
      scripts/libdav1d/build.sh
  8. 29
      scripts/libfreetype/build.sh
  9. 9
      scripts/libfreetype/download.sh
  10. 23
      scripts/libfribidi/build.sh
  11. 9
      scripts/libfribidi/download.sh
  12. 63
      scripts/libvpx/build.sh
  13. 10
      scripts/libvpx/download.sh
  14. 40
      scripts/libx264/build.sh
  15. 12
      scripts/libx264/download.sh
  16. 42
      scripts/parse-arguments.sh
  17. 41
      tools/docker/Dockerfile

@ -16,5 +16,18 @@ install:
- sudo pip3 install meson==0.53.2
- 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
jobs:
include:
- name: armeabi-v7a
env: TARGET_ABI=armeabi-v7a
- name: arm64-v8a
env: TARGET_ABI=arm64-v8a
- name: x86
env: TARGET_ABI=x86
- name: x86_64
env: TARGET_ABI=x86_64
script:
- ./ffmpeg-android-maker.sh -dav1d
- ./ffmpeg-android-maker.sh -dav1d -abis=$TARGET_ABI

@ -13,7 +13,7 @@ The script also produces `ffmpeg` and `ffprobe` executables that can be used in
The main focus of ffmpeg-android-maker is to prepare shared libraries for seamless integration into an Android project. The script prepares the `output` directory that is meant to be used. And it's not the only thing this project does.
By default this script downloads and builds the FFmpeg **4.3**, but the version can be overridden.
By default this script downloads and builds the FFmpeg **4.3.1**, but the version can be overridden.
The details of how this script is implemented are described in this series of posts:
* [Part 1](https://proandroiddev.com/a-story-about-ffmpeg-in-android-part-i-compilation-898e4a249422)
@ -39,26 +39,26 @@ Also there are a lot of arguments that you can pass to the `ffmpeg-android-maker
* x86
* x86_64
You can build only some of these ABIs by specifying a [flag](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Available-script-arguments#desired-abis-to-build).
If you need to build only some of these ABIs, you can do so by specifying a [flag](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Available-script-arguments#desired-abis-to-build).
## Supported host OS
On **macOS** or **Linux** just execute the ffmpeg-android-maker.sh script in terminal. Please follow the instructions in [Requirements](#Requirements) section.
Regardless of the OS you use, you need to setup it before executing the script. Please follow the instructions in [Requirements](#Requirements) section.
~~It is also possible to execute this script on a **Windows** machine with [MSYS2](https://www.msys2.org). You also need to install specific packages to it: *make*, *git*, *diffutils* and *tar*. The script supports both 32-bit and 64-bit versions of Windows. Also see Prerequisites section for necessary software.~~
On **macOS** and **Linux** the script is supported natively. Just execute it script in the terminal.
Since v2.0.0 the MSYS2 support is temporary absent.
On **Windows 10** you can use [WSL](https://docs.microsoft.com/en-us/windows/wsl/about) technology to install [Ubuntu 20.04 LTS](https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71?activetab=pivot:overviewtab) app. Then follow the Linux way of executing the script. Note that you will need to manually install exactly Linux versions of Android SDK and NDK into your Linux subsystem. The [Dockerfile](https://github.com/Javernaut/ffmpeg-android-maker/blob/master/tools/docker/Dockerfile) may help to understand how to do the setup.
Since v2.1.1 the **Windows** support is done with [Docker](https://www.docker.com) tool.
Check [this WIKI page](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Docker-support) for more info.
Also on **any OS** you can use [Docker](https://www.docker.com) tool to execute the script.
Check [this WIKI page](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Docker-support) out to understand benefits of this approach.
## Requirements
The script expects to use **at least** Android NDK **r19** (both **r20** and **r21** also work ok).
The script assumes you have Android SDK and NDK already installed. In order to tell the script their locations you have to define 2 environment variables:
* `ANDROID_SDK_HOME` - absolute path to your Android SDK
* `ANDROID_NDK_HOME` - absolute path to your Android NDK
Before the script is executed you have to define two environment variables:
* `ANDROID_SDK_HOME` - path to your Android SDK
* `ANDROID_NDK_HOME` - path to your Android NDK
The script expects to use **at least** Android NDK **r19** (both **r20** and **r21** also work ok).
Certain external libraries require additional software to be installed. Check this [WIKI page](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Supported-external-libraries) out for more info. Note that if you don't need these external libraries then you also don't need to install the additional software. These external libraries are not built by default.
@ -75,3 +75,5 @@ Certain external libraries require additional software to be installed. Check th
## License
The ffmpeg-android-maker's source code is available under the MIT license. See the `LICENSE.txt` file for more details.
However, the binaries that are produced have different license. The FFmpeg itself is under [LGPL 2.1](http://ffmpeg.org/legal.html). Enabling certain external libraries (like libx264) changes the license to be GPL 2 or later.

@ -17,7 +17,7 @@ function downloadTarArchive() {
echo "Ensuring sources of ${LIBRARY_NAME} in ${LIBRARY_SOURCES}"
if [[ ! -d "$LIBRARY_SOURCES" ]]; then
curl -O ${DOWNLOAD_URL}
curl -LO ${DOWNLOAD_URL}
EXTRACTION_DIR="."
if [ "$NEED_EXTRA_DIRECTORY" = true ] ; then

@ -65,6 +65,7 @@ export CROSS_PREFIX_WITH_PATH=${TOOLCHAIN_PATH}/bin/${CROSS_PREFIX}
# Exporting Binutils paths, if passing just CROSS_PREFIX_WITH_PATH is not enough
# The FAM_ prefix is used to eliminate passing those values implicitly to build systems
export FAM_ADDR2LINE=${CROSS_PREFIX_WITH_PATH}addr2line
export FAM_AS=${CROSS_PREFIX_WITH_PATH}as
export FAM_AR=${CROSS_PREFIX_WITH_PATH}ar
export FAM_NM=${CROSS_PREFIX_WITH_PATH}nm
export FAM_OBJCOPY=${CROSS_PREFIX_WITH_PATH}objcopy
@ -80,7 +81,6 @@ export TARGET=${TARGET_TRIPLE_MACHINE_CC}-linux-${TARGET_TRIPLE_OS}${ANDROID_PLA
export FAM_CC=${TOOLCHAIN_PATH}/bin/${TARGET}-clang
export FAM_CXX=${FAM_CC}++
export FAM_LD=${FAM_CC}
export FAM_AS=${FAM_CC}
# TODO consider abondaning this strategy of defining the name of the clang wrapper
# in favour of just passing -mstackrealign and -fno-addrsig depending on

@ -33,5 +33,7 @@ export MAKE_EXECUTABLE=$(which make)
export NINJA_EXECUTABLE=$(which ninja)
# Meson is used for libdav1d building. Needs to be installed
export MESON_EXECUTABLE=$(which meson)
# Nasm is used for libdav1d building. Needs to be installed
# Nasm is used for libdav1d and libx264 building. Needs to be installed
export NASM_EXECUTABLE=$(which nasm)
# A utility to properly pick shared libraries by FFmpeg's configure script. Needs to be installed
export PKG_CONFIG_EXECUTABLE=$(which pkg-config)

@ -13,6 +13,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[@]}
@ -37,7 +41,7 @@ DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS"
--cxx=${FAM_CXX} \
--ld=${FAM_LD} \
--ar=${FAM_AR} \
--as=${FAM_AS} \
--as=${FAM_CC} \
--nm=${FAM_NM} \
--ranlib=${FAM_RANLIB} \
--strip=${FAM_STRIP} \
@ -45,7 +49,7 @@ DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS"
--extra-ldflags="$DEP_LD_FLAGS" \
--enable-shared \
--disable-static \
--pkg-config=$(which pkg-config) \
--pkg-config=${PKG_CONFIG_EXECUTABLE} \
${EXTRA_BUILD_CONFIGURATION_FLAGS} \
--disable-runtime-cpudetect \
--disable-programs \

@ -10,7 +10,7 @@ c = '${FAM_CC}'
ar = '${FAM_AR}'
strip = '${FAM_STRIP}'
nasm = '${NASM_EXECUTABLE}'
pkgconfig = '$(which pkg-config)'
pkgconfig = '${PKG_CONFIG_EXECUTABLE}'
[properties]
needs_exe_wrapper = true

@ -0,0 +1,29 @@
#!/usr/bin/env bash
./configure \
--prefix=${INSTALL_DIR} \
--host=${TARGET} \
--with-sysroot=${SYSROOT_PATH} \
--disable-shared \
--enable-static \
--with-pic \
--with-zlib \
--without-bzip2 \
--without-png \
--without-harfbuzz \
--without-brotli \
--without-old-mac-fonts \
--without-fsspec \
--without-fsref \
--without-quickdraw-toolbox \
--without-quickdraw-carbon \
--without-ats \
CC=${FAM_CC} \
AR=${FAM_AR} \
RANLIB=${FAM_RANLIB} || exit 1
export FFMPEG_EXTRA_LD_FLAGS="${FFMPEG_EXTRA_LD_FLAGS} -lz"
${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

@ -0,0 +1,9 @@
#!/usr/bin/env bash
source ${SCRIPTS_DIR}/common-functions.sh
FREETYPE_VERSION=2.10.2
downloadTarArchive \
"libfreetype" \
"https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz" \

@ -0,0 +1,23 @@
#!/usr/bin/env bash
./configure \
--prefix=${INSTALL_DIR} \
--host=${TARGET} \
--with-sysroot=${SYSROOT_PATH} \
--disable-shared \
--enable-static \
--disable-dependency-tracking \
--disable-fast-install \
--disable-debug \
--disable-deprecated \
--with-pic \
CC=${FAM_CC} \
AR=${FAM_AR} \
RANLIB=${FAM_RANLIB} || exit 1
${MAKE_EXECUTABLE} clean
# Compiling only the static library. Just 'make' will build an executable and docs as well.
${MAKE_EXECUTABLE} -j${HOST_NPROC} -C lib
${MAKE_EXECUTABLE} install -C lib
# Installing the .pc file
${MAKE_EXECUTABLE} install-data-am

@ -0,0 +1,9 @@
#!/usr/bin/env bash
source ${SCRIPTS_DIR}/common-functions.sh
FRIBIDI_VERSION=1.0.10
downloadTarArchive \
"libfribidi" \
"https://github.com/fribidi/fribidi/releases/download/v${FRIBIDI_VERSION}/fribidi-${FRIBIDI_VERSION}.tar.xz"

@ -0,0 +1,63 @@
#!/usr/bin/env bash
VPX_AS=${FAM_AS}
case $ANDROID_ABI in
x86)
EXTRA_BUILD_FLAGS="--target=x86-android-gcc --disable-sse4_1 --disable-avx --disable-avx2 --disable-avx512"
VPX_AS=${FAM_YASM}
;;
x86_64)
EXTRA_BUILD_FLAGS="--target=x86_64-android-gcc --disable-avx --disable-avx2 --disable-avx512"
VPX_AS=${FAM_YASM}
;;
armeabi-v7a)
EXTRA_BUILD_FLAGS="--target=armv7-android-gcc --enable-thumb"
;;
arm64-v8a)
EXTRA_BUILD_FLAGS="--target=arm64-android-gcc --enable-thumb"
;;
esac
CC=${FAM_CC} \
CXX=${FAM_CXX} \
AR=${FAM_AR} \
LD=${FAM_LD} \
AS=${VPX_AS} \
STRIP=${FAM_STRIP} \
NM=${FAM_NM} \
./configure \
${EXTRA_BUILD_FLAGS} \
--prefix=${INSTALL_DIR} \
--libc=${SYSROOT_PATH} \
--enable-pic \
--enable-realtime-only \
--enable-install-libs \
--enable-multithread \
--enable-webm-io \
--enable-libyuv \
--enable-small \
--enable-better-hw-compatibility \
--enable-vp8 \
--enable-vp9 \
--enable-static \
--disable-shared \
--disable-ccache \
--disable-debug \
--disable-gprof \
--disable-gcov \
--disable-dependency-tracking \
--disable-install-docs \
--disable-install-bins \
--disable-install-srcs \
--disable-examples \
--disable-tools \
--disable-docs \
--disable-unit-tests \
--disable-decode-perf-tests \
--disable-encode-perf-tests \
--disable-runtime-cpu-detect || exit 1
${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

@ -0,0 +1,10 @@
#!/usr/bin/env bash
source ${SCRIPTS_DIR}/common-functions.sh
VPX_VERSION=v1.8.2
downloadTarArchive \
"libvpx" \
"https://chromium.googlesource.com/webm/libvpx/+archive/${VPX_VERSION}.tar.gz" \
true

@ -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

@ -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"

@ -9,9 +9,29 @@
ABIS_TO_BUILD=()
API_LEVEL=16
SOURCE_TYPE=TAR
SOURCE_VALUE=4.3
SOURCE_VALUE=4.3.1
BINUTILS=gnu
EXTERNAL_LIBRARIES=()
FFMPEG_GPL_ENABLED=false
# All FREE libraries that are supported
SUPPORTED_LIBRARIES_FREE=(
"libaom"
"libdav1d"
"libmp3lame"
"libopus"
"libwavpack"
"libtwolame"
"libspeex"
"libvpx"
"libfreetype"
"libfribidi"
)
# All GPL libraries that are supported
SUPPORTED_LIBRARIES_GPL=(
"libx264"
)
for argument in "$@"; do
case $argument in
@ -88,6 +108,26 @@ for argument in "$@"; do
--enable-libspeex | -speex)
EXTERNAL_LIBRARIES+=("libspeex")
;;
--enable-libvpx | -vpx)
EXTERNAL_LIBRARIES+=("libvpx")
;;
--enable-libfreetype | -freetype)
EXTERNAL_LIBRARIES+=("libfreetype")
;;
--enable-libfribidi | -fribidi)
EXTERNAL_LIBRARIES+=("libfribidi")
;;
--enable-libx264 | -x264)
EXTERNAL_LIBRARIES+=("libx264")
FFMPEG_GPL_ENABLED=true
;;
--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"
;;

@ -6,21 +6,6 @@ ARG VERSION_SDK=6609375
ARG VERSION_NDK=21.3.6528147
ARG VERSION_CMAKE=3.10.2.4988404
# Packages to install via apt-get
ARG VERSION_PYTHON3=3.8.2-0ubuntu2
ARG VERSION_PYTHON3_PIP=20.0.2-5ubuntu1
ARG VERSION_PYTHON3_SETUPTOOLS=45.2.0-1
ARG VERSION_PYTHON3_WHEEL=0.34.2-1
ARG VERSION_NINJA_BUILD=1.10.0-1build1
ARG VERSION_BUILD_ESSENTIAL=12.8ubuntu1
ARG VERSION_OPENJDK_8_JDK_HEADLESS=8u252-b09-1ubuntu1
ARG VERSION_CURL=7.68.0-1ubuntu2
ARG VERSION_UNZIP=6.0-25ubuntu1
ARG VERSION_BASH=5.0-6ubuntu1
ARG VERSION_NASM=2.14.02-1
ARG VERSION_PKG_CONFIG=0.29.1-0ubuntu4
ARG VERSION_MAKE=4.2.1-1.2
# Package to install via pip3
ARG VERSION_MESON=0.53.2
@ -34,19 +19,19 @@ ENV ANDROID_NDK_HOME=${ANDROID_SDK_HOME}/ndk/${VERSION_NDK}
# Installing basic software
RUN apt-get update && apt-get install -y --no-install-recommends \
python3=$VERSION_PYTHON3 \
python3-pip=$VERSION_PYTHON3_PIP \
python3-setuptools=$VERSION_PYTHON3_SETUPTOOLS \
python3-wheel=$VERSION_PYTHON3_WHEEL \
ninja-build=$VERSION_NINJA_BUILD \
build-essential=$VERSION_BUILD_ESSENTIAL \
openjdk-8-jdk-headless=$VERSION_OPENJDK_8_JDK_HEADLESS \
curl=$VERSION_CURL \
unzip=$VERSION_UNZIP \
bash=$VERSION_BASH \
nasm=$VERSION_NASM \
pkg-config=$VERSION_PKG_CONFIG \
make=$VERSION_MAKE \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
ninja-build \
build-essential \
openjdk-8-jdk-headless \
curl \
unzip \
bash \
nasm \
pkg-config \
make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Loading…
Cancel
Save