Compare commits

..

13 Commits

  1. 8
      .github/workflows/compilability_check.yml
  2. 2
      LICENSE.txt
  3. 2
      README.md
  4. 5
      scripts/export-build-variables.sh
  5. 2
      scripts/export-host-variables.sh
  6. 27
      scripts/ffmpeg/build.sh
  7. 2
      scripts/libaom/android.cmake
  8. 1
      scripts/libaom/build.sh
  9. 2
      scripts/libaom/download.sh
  10. 22
      scripts/libbluray/build.sh
  11. 10
      scripts/libbluray/download.sh
  12. 2
      scripts/libdav1d/download.sh
  13. 4
      scripts/libfreetype/download.sh
  14. 2
      scripts/libfribidi/download.sh
  15. 2
      scripts/libspeex/download.sh
  16. 2
      scripts/libvpx/download.sh
  17. 2
      scripts/libwavpack/download.sh
  18. 12
      scripts/libwebp/build.sh
  19. 2
      scripts/libwebp/download.sh
  20. 4
      scripts/libx264/download.sh
  21. 21
      scripts/mbedtls/build.sh
  22. 9
      scripts/mbedtls/download.sh
  23. 12
      scripts/parse-arguments.sh
  24. 13
      tools/docker/Dockerfile

@ -2,21 +2,21 @@ name: Compilability check
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
strategy:
matrix:
abi: [ "armeabi-v7a", "arm64-v8a", "x86", "x86_64" ]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Setup the environment
run: |
sudo pip3 install meson==1.2.1
sudo pip3 install meson==0.58.2
sudo apt-get install nasm ninja-build
- name: Executing the script
run: |
export ANDROID_SDK_HOME=$ANDROID_HOME
export ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME
./ffmpeg-android-maker.sh -all-free -all-gpl -android=21 -abis=${{ matrix.abi }}
./ffmpeg-android-maker.sh -dav1d -android=16 -abis=${{ matrix.abi }}

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Oleksandr Berezhnyi
Copyright (c) 2021 Alexander Berezhnoi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

@ -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 **6.0**, but the version can be overridden.
By default this script downloads and builds the FFmpeg **5.0**, 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)

@ -55,7 +55,6 @@ export CROSS_PREFIX_WITH_PATH=${TOOLCHAIN_PATH}/bin/llvm-
# The FAM_ prefix is used to eliminate passing those values implicitly to build systems
export FAM_ADDR2LINE=${CROSS_PREFIX_WITH_PATH}addr2line
export FAM_AR=${CROSS_PREFIX_WITH_PATH}ar
export FAM_AS=${CROSS_PREFIX_WITH_PATH}as
export FAM_NM=${CROSS_PREFIX_WITH_PATH}nm
export FAM_OBJCOPY=${CROSS_PREFIX_WITH_PATH}objcopy
export FAM_OBJDUMP=${CROSS_PREFIX_WITH_PATH}objdump
@ -70,6 +69,7 @@ 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
@ -81,9 +81,6 @@ export FAM_YASM=${TOOLCHAIN_PATH}/bin/yasm
# A variable to which certain dependencies can add -l arguments during build.sh
export FFMPEG_EXTRA_LD_FLAGS=
# A variable to which certain dependencies can add addtional arguments during ffmpeg build.sh
export EXTRA_BUILD_CONFIGURATION_FLAGS=
export INSTALL_DIR=${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}
# Forcing FFmpeg and its dependencies to look for dependencies

@ -26,7 +26,7 @@ export HOST_TAG=$HOST_TAG
export HOST_NPROC=$HOST_NPROC
# Using CMake from the Android SDK
export CMAKE_EXECUTABLE=${ANDROID_SDK_HOME}/cmake/3.22.1/bin/cmake
export CMAKE_EXECUTABLE=${ANDROID_SDK_HOME}/cmake/3.10.2.4988404/bin/cmake
# Using Make from the Android SDK
export MAKE_EXECUTABLE=${ANDROID_NDK_HOME}/prebuilt/${HOST_TAG}/bin/make
# Using Build machine's Ninja. It is used for libdav1d building. Needs to be installed

@ -1,12 +1,15 @@
#!/usr/bin/env bash
case $ANDROID_ABI in
armeabi-v7a)
EXTRA_BUILD_CONFIGURATION_FLAGS=--enable-thumb
;;
x86)
# Disabling assembler optimizations, because they have text relocations
EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --disable-asm"
EXTRA_BUILD_CONFIGURATION_FLAGS=--disable-asm
;;
x86_64)
EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --x86asmexe=${FAM_YASM}"
EXTRA_BUILD_CONFIGURATION_FLAGS=--x86asmexe=${FAM_YASM}
;;
esac
@ -25,6 +28,9 @@ done
DEP_CFLAGS="-I${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/include"
DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS"
# Everything that goes below ${EXTRA_BUILD_CONFIGURATION_FLAGS} is my project-specific.
# You are free to enable/disable whatever you actually need.
./configure \
--prefix=${BUILD_DIR_FFMPEG}/${ANDROID_ABI} \
--enable-cross-compile \
@ -43,9 +49,24 @@ DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS"
--extra-ldflags="$DEP_LD_FLAGS" \
--enable-shared \
--disable-static \
--disable-vulkan \
--pkg-config=${PKG_CONFIG_EXECUTABLE} \
${EXTRA_BUILD_CONFIGURATION_FLAGS} \
--disable-runtime-cpudetect \
--disable-programs \
--disable-muxers \
--disable-encoders \
--disable-avdevice \
--disable-postproc \
--disable-swresample \
--disable-avfilter \
--disable-doc \
--disable-debug \
--disable-pthreads \
--disable-network \
--disable-bsfs \
--disable-protocols \
--enable-protocol=file \
--enable-protocol=pipe \
$ADDITIONAL_COMPONENTS || exit 1
${MAKE_EXECUTABLE} clean

@ -16,7 +16,7 @@ include("$ENV{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake")
if(DEFINED CMAKE_ASM_NASM_COMPILER)
set(AS_EXECUTABLE ${CMAKE_ASM_NASM_COMPILER})
else()
set(AS_EXECUTABLE ${ANDROID_ASM_COMPILER})
set(AS_EXECUTABLE ${_CMAKE_TOOLCHAIN_PREFIX}as)
endif()
# AV1 Codec Library doesn't recognise 'i686' as CMAKE_SYSTEM_PROCESSOR

@ -12,6 +12,7 @@ ${CMAKE_EXECUTABLE} .. \
-DCMAKE_TOOLCHAIN_FILE=${SCRIPTS_DIR}/libaom/android.cmake \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
-DCONFIG_PIC=1 \
-DCONFIG_AV1_ENCODER=0 \
-DCONFIG_RUNTIME_CPU_DETECT=0 \
-DENABLE_TESTS=0 \
-DENABLE_DOCS=0 \

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
AOM_VERSION=v3.6.1
AOM_VERSION=v3.3.0
downloadTarArchive \
"libaom" \

@ -1,22 +0,0 @@
#!/usr/bin/env bash
CC=${FAM_CC} \
AR=${FAM_AR} \
AS=${FAM_AS} \
RANLIB=${FAM_RANLIB} \
./configure \
--prefix=${INSTALL_DIR} \
--host=${TARGET} \
--with-sysroot=${SYSROOT_PATH} \
--disable-shared \
--enable-static \
--disable-examples \
--with-pic \
--without-libxml2 \
--without-freetype \
--without-fontconfig \
--disable-bdjava-jar || exit 1
${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

@ -1,10 +0,0 @@
#!/usr/bin/env bash
source ${SCRIPTS_DIR}/common-functions.sh
LIBBLURAY_VERSION=1.3.4
downloadTarArchive \
"libbluray" \
"https://download.videolan.org/pub/videolan/libbluray/${LIBBLURAY_VERSION}/libbluray-${LIBBLURAY_VERSION}.tar.bz2"

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
DAV1D_VERSION=1.2.1
DAV1D_VERSION=1.0.0
downloadTarArchive \
"libdav1d" \

@ -2,8 +2,8 @@
source ${SCRIPTS_DIR}/common-functions.sh
FREETYPE_VERSION=2.13.2
FREETYPE_VERSION=2.11.1
downloadTarArchive \
"libfreetype" \
"https://nav.dl.sourceforge.net/project/freetype/freetype2/${FREETYPE_VERSION}/freetype-${FREETYPE_VERSION}.tar.gz"
"https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz" \

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
FRIBIDI_VERSION=1.0.13
FRIBIDI_VERSION=1.0.11
downloadTarArchive \
"libfribidi" \

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
SPEEX_VERSION=1.2.1
SPEEX_VERSION=1.2.0
downloadTarArchive \
"libspeex" \

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
VPX_VERSION=v1.13.0
VPX_VERSION=v1.11.0
downloadTarArchive \
"libvpx" \

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
WAVPACK_VERSION=5.6.0
WAVPACK_VERSION=5.4.0
downloadTarArchive \
"libwavpack" \

@ -2,16 +2,10 @@
./configure \
--prefix=${INSTALL_DIR} \
--host=${TARGET} \
--host=${TARGET_TRIPLE_MACHINE_ARCH}-linux-android \
--with-sysroot=${SYSROOT_PATH} \
--disable-shared \
--enable-static \
--with-pic \
CC=${FAM_CC} \
AR=${FAM_AR} \
RANLIB=${FAM_RANLIB} || exit 1
export FFMPEG_EXTRA_LD_FLAGS="${FFMPEG_EXTRA_LD_FLAGS} -lm"
--target=${TARGET} \
CC=${FAM_CC} || exit 1
${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}

@ -2,7 +2,7 @@
source ${SCRIPTS_DIR}/common-functions.sh
WEBP_VERSION=1.3.0
WEBP_VERSION=1.2.2
downloadTarArchive \
"libwebp" \

@ -4,8 +4,8 @@ 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
# 01 Jun, 2022
LIBX264_VERSION=baee400fa9ced6f5481a728138fed6e867b0ff7f
# Jun 13, 2021 3:43pm GMT+0300
LIBX264_VERSION=5db6aa6cab1b146e07b60cc1736a01f21da01154
downloadTarArchive \
"libx264" \

@ -1,21 +0,0 @@
#!/usr/bin/env bash
CMAKE_BUILD_DIR=mbedtls_build_${ANDROID_ABI}
# mbedtls authors park their source in a directory named mbedtls-${MBEDTLS_VERSION}
# instead of root directory
cd mbedtls-${MBEDTLS_VERSION}
rm -rf ${CMAKE_BUILD_DIR}
mkdir ${CMAKE_BUILD_DIR}
cd ${CMAKE_BUILD_DIR}
${CMAKE_EXECUTABLE} .. \
-DANDROID_PLATFORM=${ANDROID_PLATFORM} \
-DANDROID_ABI=${ANDROID_ABI} \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
-DENABLE_TESTING=0
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install
export EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-protocol=https --enable-version3"

@ -1,9 +0,0 @@
#!/usr/bin/env bash
source ${SCRIPTS_DIR}/common-functions.sh
export MBEDTLS_VERSION=3.4.1
downloadTarArchive \
"mbedtls" \
"https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${MBEDTLS_VERSION}.tar.gz" \
true

@ -9,7 +9,7 @@
ABIS_TO_BUILD=()
API_LEVEL=19
SOURCE_TYPE=TAR
SOURCE_VALUE=6.0
SOURCE_VALUE=5.0
EXTERNAL_LIBRARIES=()
FFMPEG_GPL_ENABLED=false
@ -25,8 +25,6 @@ SUPPORTED_LIBRARIES_FREE=(
"libwebp"
"libfreetype"
"libfribidi"
"mbedtls"
"libbluray"
)
# All GPL libraries that are supported
@ -88,7 +86,7 @@ for argument in "$@"; do
--enable-libopus | -opus)
EXTERNAL_LIBRARIES+=("libopus")
;;
--enable-libwebp | -webp)
--enable-webp | -webp)
EXTERNAL_LIBRARIES+=("libwebp")
;;
--enable-libwavpack | -wavpack)
@ -113,12 +111,6 @@ for argument in "$@"; do
EXTERNAL_LIBRARIES+=("libx264")
FFMPEG_GPL_ENABLED=true
;;
--enable-mbedtls | -mbedtls)
EXTERNAL_LIBRARIES+=("mbedtls")
;;
--enable-libbluray | -bluray)
EXTERNAL_LIBRARIES+=("libbluray")
;;
--enable-all-free | -all-free)
EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_FREE[@]}"
;;

@ -1,13 +1,13 @@
FROM --platform=linux/amd64 ubuntu:22.04
FROM ubuntu:20.04
# Arguments that can be overridden in 'docker build' command:
# Versions of Android SDK and NDK. The CMake is installed via NDK.
ARG VERSION_SDK=10406996
ARG VERSION_NDK=25.2.9519653
ARG VERSION_CMAKE=3.22.1
ARG VERSION_SDK=6858069
ARG VERSION_NDK=21.4.7075529
ARG VERSION_CMAKE=3.10.2.4988404
# Package to install via pip3
ARG VERSION_MESON=1.2.1
ARG VERSION_MESON=0.58.2
# The HOME variable isn't available for ENV directive (during building an image).
# So we define one manually. For alpine and ubuntu it should be '/root'
@ -18,7 +18,7 @@ ENV ANDROID_SDK_HOME=${HOME_TWIN}/android-sdk
ENV ANDROID_NDK_HOME=${ANDROID_SDK_HOME}/ndk/${VERSION_NDK}
# Installing basic software
RUN apt-get --allow-releaseinfo-change update && apt-get install -y --no-install-recommends \
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-setuptools \
@ -32,7 +32,6 @@ RUN apt-get --allow-releaseinfo-change update && apt-get install -y --no-install
nasm \
pkg-config \
make \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Loading…
Cancel
Save