From 7fe79d09c5a2e2d0b2e41a9ae25de234d0756cbe Mon Sep 17 00:00:00 2001 From: Markus Perl Date: Tue, 10 Nov 2020 10:36:40 +0100 Subject: [PATCH 001/111] Readme update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4c202a5f..6e281aff 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS ## Disclaimer And Data Privacy Notice -This script will download different packages from different sources which may track your usage. These sources are out of control -by the developers of this script. By downloading and using this script you are fully aware of this. +This script will download different packages with different licenses from various sources which may track your usage. +These sources are out of control by the developers of this script. By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems other than Debian 10 and macOS 10.15.x From da511ac14245b6b6b7e157a670b69332818ad3b8 Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Sun, 22 Nov 2020 10:04:41 -0500 Subject: [PATCH 002/111] The check for the cleanup flag in $1 also matches --full-static There is an ambiguity in how short and long cli flags are passed that causes the script to clean whenever a full-static build is attempted with long cli option `--full-static``. The second clause of the conditional that checks for the cleanup flag if [[ "$1" == "--cleanup" || "$1" =~ 'c' ]]; then is overly broad and evaluates as truthy if $1 is "--full-cleanup". This can be easily fixed by appending an additional string check against the string "==", e.g `! "$1" =~ '--'`. --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index b172de4c..1cde5909 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -179,7 +179,7 @@ while (( $# > 0 )); do if [[ "$1" == "--build" || "$1" =~ 'b' ]]; then bflag='-b' fi - if [[ "$1" == "--cleanup" || "$1" =~ 'c' ]]; then + if [[ "$1" == "--cleanup" || "$1" =~ 'c' && ! "$1" =~ '--' ]]; then cflag='-c' cleanup fi From d2d5eea5d778b0d5d230b851affe2541c87d83d0 Mon Sep 17 00:00:00 2001 From: Maximiliano Lira Del Canto <8040628+mliradelc@users.noreply.github.com> Date: Tue, 8 Dec 2020 10:49:08 +0100 Subject: [PATCH 003/111] Update libaom v2.0.1 --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 1cde5909..f23c079a 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -380,7 +380,7 @@ CONFIGURE_OPTIONS+=("--enable-libvidstab") if build "av1"; then - download "https://aomedia.googlesource.com/aom/+archive/430d58446e1f71ec2283af0d6c1879bc7a3553dd.tar.gz" "av1.tar.gz" "av1" + download "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1 From 3563a1cc5365409b51f497f71be6a0391c908c02 Mon Sep 17 00:00:00 2001 From: Markus Perl Date: Thu, 24 Dec 2020 14:13:05 +0100 Subject: [PATCH 004/111] lv2 support --- Dockerfile | 2 +- README.md | 4 +- build-ffmpeg | 94 ++++++++++++++++++++++++++++++++++++------ cuda-centos.dockerfile | 2 +- cuda-ubuntu.dockerfile | 2 +- full-static.dockerfile | 4 +- 6 files changed, 89 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4b0045c..428a828b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:20.04 AS build ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev python \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates diff --git a/README.md b/README.md index 6e281aff..c78e3462 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ This script will download different packages with different licenses from variou These sources are out of control by the developers of this script. By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. -Please do not file bug reports for systems other than Debian 10 and macOS 10.15.x -because I don't have the resources and the time to maintain other systems. +Please do not file bug reports for systems other than Debian 10 and macOS 10.15.x, +because I don't have the resources or time to maintain other systems. ## Supported Codecs * `x264`: H.264 Video Codec (MPEG-4 AVC) diff --git a/build-ffmpeg b/build-ffmpeg index f23c079a..0778d847 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -240,11 +240,91 @@ if ! command_exists "curl"; then exit 1 fi +if ! command_exists "python"; then + echo "Python command not found. Lv2 filter will not be available."; +fi + ## ## build tools ## +if build "pkg-config"; then + download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" + execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib + execute make -j $MJOBS + execute make install + build_done "pkg-config" +fi + + +if command_exists "python"; then + + if build "lv2"; then + download "https://lv2plug.in/spec/lv2-1.18.0.tar.bz2" "lv2-1.18.0.tar.bz2" + execute ./waf configure --prefix="${WORKSPACE}" --lv2-user + execute ./waf + execute ./waf install + + build_done "lv2" + fi + + if build "waflib"; then + download "https://gitlab.com/drobilla/autowaf/-/archive/cc37724b9bfa889baebd8cb10f38b8c7cab83e37/autowaf-cc37724b9bfa889baebd8cb10f38b8c7cab83e37.tar.gz" "autowaf.tar.gz" + build_done "waflib" + fi + + if build "serd"; then + download "https://gitlab.com/drobilla/serd/-/archive/v0.30.6/serd-v0.30.6.tar.gz" "serd-v0.30.6.tar.gz" + execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/serd-v0.30.6/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix + execute ./waf + execute ./waf install + build_done "serd" + fi + + if build "pcre"; then + download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + + build_done "pcre" + fi + + if build "sord"; then + download "https://gitlab.com/drobilla/sord/-/archive/v0.16.6/sord-v0.16.6.tar.gz" "sord-v0.16.6.tar.gz" + execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/sord-v0.16.6/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" CFLAGS=${CFLAGS} --static --no-shared --no-utils + execute ./waf CFLAGS=${CFLAGS} + execute ./waf install + + build_done "sord" + fi + + if build "sratom"; then + download "https://gitlab.com/lv2/sratom/-/archive/v0.6.6/sratom-v0.6.6.tar.gz" "sratom-v0.6.6.tar.gz" + execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/sratom-v0.6.6/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared + execute ./waf + execute ./waf install + + build_done "sratom" + fi + + if build "lilv"; then + download "https://gitlab.com/lv2/lilv/-/archive/v0.24.10/lilv-v0.24.10.tar.gz" "lilv-v0.24.10.tar.gz" + execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/lilv-v0.24.10/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils + execute ./waf + execute ./waf install + CFLAGS+=" -I$WORKSPACE/include/lilv-0" + build_done "lilv" + fi + + CONFIGURE_OPTIONS+=("--enable-lv2") +fi + if build "yasm"; then download "https://github.com/yasm/yasm/releases/download/v1.3.0/yasm-1.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" @@ -261,17 +341,9 @@ if build "nasm"; then build_done "nasm" fi -if build "pkg-config"; then - download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" - execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib - execute make -j $MJOBS - execute make install - build_done "pkg-config" -fi - if build "zlib"; then download "https://www.zlib.net/zlib-1.2.11.tar.gz" - execute ./configure --static --prefix="${WORKSPACE}" + execute ./configure --static --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install build_done "zlib" @@ -281,7 +353,7 @@ if build "openssl"; then download "https://www.openssl.org/source/openssl-1.1.1h.tar.gz" execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib execute make -j $MJOBS - execute make install + execute make install_sw build_done "openssl" fi @@ -378,7 +450,6 @@ if build "vid_stab"; then fi CONFIGURE_OPTIONS+=("--enable-libvidstab") - if build "av1"; then download "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build @@ -391,7 +462,6 @@ if build "av1"; then fi CONFIGURE_OPTIONS+=("--enable-libaom") - ## ## audio library ## diff --git a/cuda-centos.dockerfile b/cuda-centos.dockerfile index 1b02594a..a8d20443 100644 --- a/cuda-centos.dockerfile +++ b/cuda-centos.dockerfile @@ -6,7 +6,7 @@ ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN yum group install -y "Development Tools" \ - && yum install -y curl libva-devel \ + && yum install -y curl libva-devel python2 \ && rm -rf /var/cache/yum/* \ && yum clean all diff --git a/cuda-ubuntu.dockerfile b/cuda-ubuntu.dockerfile index e067a261..44abd495 100644 --- a/cuda-ubuntu.dockerfile +++ b/cuda-ubuntu.dockerfile @@ -7,7 +7,7 @@ ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev python \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates diff --git a/full-static.dockerfile b/full-static.dockerfile index a3f2d187..03eee7ee 100644 --- a/full-static.dockerfile +++ b/full-static.dockerfile @@ -1,11 +1,11 @@ -FROM nvidia/cuda:11.1-devel-ubuntu20.04 AS build +FROM ubuntu:20.04 AS build ENV DEBIAN_FRONTEND noninteractive ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates python \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates From 01f91409116da09e140e84e7a76f2e62b0352149 Mon Sep 17 00:00:00 2001 From: Markus Perl Date: Thu, 24 Dec 2020 14:17:23 +0100 Subject: [PATCH 005/111] Readme Update --- README.md | 2 ++ build-ffmpeg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c78e3462..92613c6b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ because I don't have the resources or time to maintain other systems. * VP8 `vp8_vaapi` * VP9 `vp9_vaapi` +### LV2 Plugin Support +If python is available the binary will be built with lv2 plugin support. ## Continuos Integration ffmpeg-build-script is rockstable. Every commit runs against Linux and MacOS with https://github.com/markus-perl/ffmpeg-build-script/actions just to make sure everything works as expected. diff --git a/build-ffmpeg b/build-ffmpeg index 0778d847..88b1e273 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.20 +VERSION=1.21 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From ea460e00c4dcab079ba9fa21ed3d33ce1e7fc3fa Mon Sep 17 00:00:00 2001 From: Markus Perl Date: Thu, 24 Dec 2020 14:18:03 +0100 Subject: [PATCH 006/111] Readme Update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92613c6b..154171c9 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ because I don't have the resources or time to maintain other systems. * VP9 `vp9_vaapi` ### LV2 Plugin Support -If python is available the binary will be built with lv2 plugin support. +If Python is available the script will be built a ffmpeg binary with lv2 plugin support. ## Continuos Integration ffmpeg-build-script is rockstable. Every commit runs against Linux and MacOS with https://github.com/markus-perl/ffmpeg-build-script/actions just to make sure everything works as expected. From 11ffcd671e39e2dc7f851db786b348259db5830d Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Mon, 18 Jan 2021 13:08:44 -0600 Subject: [PATCH 007/111] Random patches and tricks for building on M1 Needs newer code in some cases, and some conditionals to check platform. The external patches possibly should be brought in? Seems to work for now if anyone is in need. Learnings from https://github.com/ssut/ffmpeg-on-apple-silicon --- build-ffmpeg | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 88b1e273..dcdbbdc5 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -8,11 +8,18 @@ VERSION=1.21 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" -CFLAGS="-I$WORKSPACE/include" +CFLAGS='-I$WORKSPACE/include' LDFLAGS="-L$WORKSPACE/lib" LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" CONFIGURE_OPTIONS=() +# Check for Apple Silicon +if [[ ( "$(uname -m)" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + # If arm64 AND darwin (macOS) + export ARCH=arm64 + export MACOSX_DEPLOYMENT_TARGET=11.0 +fi + # Speed up the process # Env Var NUMJOBS overrides automatic detection @@ -350,11 +357,15 @@ if build "zlib"; then fi if build "openssl"; then - download "https://www.openssl.org/source/openssl-1.1.1h.tar.gz" - execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib + download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" + if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf + execute ./Configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc + else + execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib + fi execute make -j $MJOBS execute make install_sw - build_done "openssl" fi CONFIGURE_OPTIONS+=("--enable-openssl") @@ -377,7 +388,11 @@ if build "x264"; then if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" - else + elif [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + ## Get latest code to support arm64 + git clone --depth 1 -b master https://code.videolan.org/videolan/x264.git + cd x264 + else execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic fi @@ -392,6 +407,7 @@ CONFIGURE_OPTIONS+=("--enable-libx264") if build "x265"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" cd build/linux || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source execute make -j $MJOBS execute make install @@ -442,6 +458,12 @@ CONFIGURE_OPTIONS+=("--enable-libxvid") if build "vid_stab"; then download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" + ## rich + if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch + patch -p1 < fix_cmake_quoting.patch + fi + ## rich execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DUSE_OMP=OFF -DENABLE_SHARED=off . execute make execute make install @@ -454,7 +476,13 @@ if build "av1"; then download "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit - execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1 + ## rich + if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCONFIG_RUNTIME_CPU_DETECT=0 "$PACKAGES"/av1 + else + execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1 + fi + ## rich (added runtime detect ) execute make -j $MJOBS execute make install @@ -560,7 +588,7 @@ CONFIGURE_OPTIONS+=("--enable-libwebp") ## if build "libsdl"; then - download "https://www.libsdl.org/release/SDL2-2.0.12.tar.gz" + download "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install From b18759f9fc4112314145c7f755dd5d6cf32aa434 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Tue, 19 Jan 2021 10:25:40 -0600 Subject: [PATCH 008/111] Changes per request, plus bonus * Define M1 variable once * Grab x264 archive vs git * configure vs Configure * bonus: output binary type. Feel free to take or leave :) --- build-ffmpeg | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index dcdbbdc5..c7bc7760 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -12,12 +12,14 @@ CFLAGS='-I$WORKSPACE/include' LDFLAGS="-L$WORKSPACE/lib" LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" +MACOS_M1=false CONFIGURE_OPTIONS=() # Check for Apple Silicon if [[ ( "$(uname -m)" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then # If arm64 AND darwin (macOS) export ARCH=arm64 export MACOSX_DEPLOYMENT_TARGET=11.0 + MACOS_M1=true fi @@ -153,6 +155,19 @@ build_done () { touch "$PACKAGES/$1.done" } +verify_binary_type () { + BINARY_TYPE=$(file $WORKSPACE/bin/ffmpeg | sed -n 's/^.*\:\ \(.*$\)/\1/p') + echo "" + case $BINARY_TYPE in + "Mach-O 64-bit executable arm64") + echo "Successfully built Apple Silicon (M1): ${BINARY_TYPE}" + ;; + *) + echo "Successfully built binary for ${OSTYPE}: ${BINARY_TYPE}" + ;; + esac +} + cleanup () { remove_dir "$PACKAGES" remove_dir "$WORKSPACE" @@ -358,9 +373,9 @@ fi if build "openssl"; then download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" - if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + if $MACOS_M1 ; then sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf - execute ./Configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc + execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc else execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib fi @@ -388,13 +403,14 @@ if build "x264"; then if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" - elif [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + elif $MACOS_M1 ; then ## Get latest code to support arm64 - git clone --depth 1 -b master https://code.videolan.org/videolan/x264.git - cd x264 - else + download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" + cd "${PACKAGES}"/x264-0d754ec + else execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic fi + execute make -j $MJOBS execute make install @@ -458,9 +474,10 @@ CONFIGURE_OPTIONS+=("--enable-libxvid") if build "vid_stab"; then download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" - ## rich - if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then - curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch + + if $MACOS_M1 ; then + + curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch patch -p1 < fix_cmake_quoting.patch fi ## rich @@ -476,13 +493,11 @@ if build "av1"; then download "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit - ## rich - if [[ ( "$ARCH" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then + if $MACOS_M1 ; then execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCONFIG_RUNTIME_CPU_DETECT=0 "$PACKAGES"/av1 else execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1 fi - ## rich (added runtime detect ) execute make -j $MJOBS execute make install @@ -680,9 +695,11 @@ execute make install INSTALL_FOLDER="/usr/bin" if [[ "$OSTYPE" == "darwin"* ]]; then -INSTALL_FOLDER="/usr/local/bin" + INSTALL_FOLDER="/usr/local/bin" fi +verify_binary_type + echo "" echo "Building done. The following binaries can be found here:" echo "- ffmpeg: $WORKSPACE/bin/ffmpeg" @@ -710,11 +727,11 @@ elif [[ ! "$SKIPINSTALL" == "yes" ]]; then if command_exists "sudo"; then sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" - sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" else cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" - cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" fi echo "Done. FFmpeg is now installed to your system." ;; From 64a2c0ed8c892a409d3013b947d7663a0af7976d Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Tue, 19 Jan 2021 10:29:45 -0600 Subject: [PATCH 009/111] Make binary echo statements balanced --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index c7bc7760..85141eb3 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -160,7 +160,7 @@ verify_binary_type () { echo "" case $BINARY_TYPE in "Mach-O 64-bit executable arm64") - echo "Successfully built Apple Silicon (M1): ${BINARY_TYPE}" + echo "Successfully built Apple Silicon (M1) for ${OSTYPE}: ${BINARY_TYPE}" ;; *) echo "Successfully built binary for ${OSTYPE}: ${BINARY_TYPE}" From c5434ee4a2ebec2b409500325602721119bd0be5 Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Tue, 19 Jan 2021 12:32:22 -0600 Subject: [PATCH 010/111] Use referenced commit for x264 to test in CI/CD branched from "apple_silicon" branch. --- build-ffmpeg | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 85141eb3..e5641c3c 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -399,14 +399,12 @@ fi ## if build "x264"; then - download "https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.bz2" + download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" + cd "${PACKAGES}"/x264-0d754ec + if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" - elif $MACOS_M1 ; then - ## Get latest code to support arm64 - download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" - cd "${PACKAGES}"/x264-0d754ec else execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic fi @@ -477,10 +475,10 @@ if build "vid_stab"; then if $MACOS_M1 ; then - curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch + curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch patch -p1 < fix_cmake_quoting.patch fi - ## rich + execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DUSE_OMP=OFF -DENABLE_SHARED=off . execute make execute make install From e574579208e232b083334f5e88ff1dd7e2286fbc Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 20 Jan 2021 07:56:45 +0100 Subject: [PATCH 011/111] libsvtav1 support --- README.md | 1 + build-ffmpeg | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 154171c9..e0c6ea4a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ because I don't have the resources or time to maintain other systems. ## Supported Codecs * `x264`: H.264 Video Codec (MPEG-4 AVC) * `x265`: H.265 Video Codec (HEVC) +* `libsvtav1`, SVT-AV1 Encoder and Decoder * `aom`: AV1 Video Codec (Experimental and very slow!) * `fdk_aac`: Fraunhofer FDK AAC Codec * `xvidcore`: MPEG-4 video coding standard diff --git a/build-ffmpeg b/build-ffmpeg index 88b1e273..48ddae21 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -368,6 +368,19 @@ if build "cmake"; then fi +if build "svtav1"; then + download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" + cd Build/linux || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + execute make -j $MJOBS + execute make install + execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" + execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" + build_done "svtav1" +fi +CONFIGURE_OPTIONS+=("--enable-libsvtav1") + + ## ## video library ## @@ -627,7 +640,7 @@ fi ## build "ffmpeg" -download "https://ffmpeg.org/releases/ffmpeg-4.3.1.tar.bz2" +download "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/553eb0773763798a6b9656b621cb125e1f6edbcc.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ From d9d9701da4592033c43fb70146de5217e42364e3 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 20 Jan 2021 08:50:08 +0100 Subject: [PATCH 012/111] Apple M1 Support + libsvtav1 support --- README.md | 12 +- build-ffmpeg | 848 +++++++++++++++++++++++++-------------------------- 2 files changed, 428 insertions(+), 432 deletions(-) diff --git a/README.md b/README.md index e0c6ea4a..ad5982d1 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,13 @@ The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS ## Disclaimer And Data Privacy Notice -This script will download different packages with different licenses from various sources which may track your usage. +This script will download different packages with different licenses from various sources, which may track your usage. These sources are out of control by the developers of this script. By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. -Please do not file bug reports for systems other than Debian 10 and macOS 10.15.x, -because I don't have the resources or time to maintain other systems. +Please do not file bug reports for systems other than Debian 10 and macOS 11.x, +because I don't have the resources or time to maintain different systems. + ## Supported Codecs * `x264`: H.264 Video Codec (MPEG-4 AVC) @@ -63,8 +64,11 @@ because I don't have the resources or time to maintain other systems. * VP8 `vp8_vaapi` * VP9 `vp9_vaapi` +### Apple M1 (Apple Silicon) Support +The script also builds FFmpeg on a new MacBook with an Apple Silicon M1 processor. + ### LV2 Plugin Support -If Python is available the script will be built a ffmpeg binary with lv2 plugin support. +If Python is available, the script will build a ffmpeg binary with lv2 plugin support. ## Continuos Integration ffmpeg-build-script is rockstable. Every commit runs against Linux and MacOS with https://github.com/markus-perl/ffmpeg-build-script/actions just to make sure everything works as expected. diff --git a/build-ffmpeg b/build-ffmpeg index edccf5ef..431cfbd8 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,221 +4,223 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.21 +VERSION=1.22 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" -CFLAGS='-I$WORKSPACE/include' +CFLAGS="-I$WORKSPACE/include" LDFLAGS="-L$WORKSPACE/lib" LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" MACOS_M1=false CONFIGURE_OPTIONS=() -# Check for Apple Silicon -if [[ ( "$(uname -m)" == "arm64" ) && ( "$OSTYPE" == "darwin"* ) ]]; then +# Check for Apple Silicon +if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then # If arm64 AND darwin (macOS) export ARCH=arm64 export MACOSX_DEPLOYMENT_TARGET=11.0 MACOS_M1=true fi - # Speed up the process # Env Var NUMJOBS overrides automatic detection if [[ -n "$NUMJOBS" ]]; then - MJOBS="$NUMJOBS" + MJOBS="$NUMJOBS" elif [[ -f /proc/cpuinfo ]]; then - MJOBS=$(grep -c processor /proc/cpuinfo) + MJOBS=$(grep -c processor /proc/cpuinfo) elif [[ "$OSTYPE" == "darwin"* ]]; then - MJOBS=$(sysctl -n machdep.cpu.thread_count) - CONFIGURE_OPTIONS=("--enable-videotoolbox") + MJOBS=$(sysctl -n machdep.cpu.thread_count) + CONFIGURE_OPTIONS=("--enable-videotoolbox") else - MJOBS=4 + MJOBS=4 fi -make_dir () { - remove_dir "$1" - if ! mkdir "$1"; then - printf "\n Failed to create dir %s" "$1"; - exit 1 - fi +make_dir() { + remove_dir "$1" + if ! mkdir "$1"; then + printf "\n Failed to create dir %s" "$1" + exit 1 + fi } -remove_dir () { - if [ -d "$1" ]; then - rm -r "$1" - fi +remove_dir() { + if [ -d "$1" ]; then + rm -r "$1" + fi } -download () { - # download url [filename[dirname]] - - DOWNLOAD_PATH="$PACKAGES" - DOWNLOAD_FILE="${2:-"${1##*/}"}" - - if [[ "$DOWNLOAD_FILE" =~ "tar." ]]; then - TARGETDIR="${DOWNLOAD_FILE%.*}" - TARGETDIR="${3:-"${TARGETDIR%.*}"}" - else - TARGETDIR="${3:-"${DOWNLOAD_FILE%.*}"}" - fi - - if [ ! -f "$DOWNLOAD_PATH/$DOWNLOAD_FILE" ]; then - echo "Downloading $1 as $DOWNLOAD_FILE" - curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1" - - EXITCODE=$? - if [ $EXITCODE -ne 0 ]; then - echo "" - echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds"; - sleep 10 - curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1" - fi - - EXITCODE=$? - if [ $EXITCODE -ne 0 ]; then - echo "" - echo "Failed to download $1. Exitcode $EXITCODE"; - exit 1 - fi - - echo "... Done" - else - echo "$DOWNLOAD_FILE has already downloaded." - fi - - make_dir "$DOWNLOAD_PATH/$TARGETDIR" - - if [ -n "$3" ]; then - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE"; - exit 1 - fi - else - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE"; - exit 1 - fi - fi - - echo "Extracted $DOWNLOAD_FILE"; - - cd "$DOWNLOAD_PATH/$TARGETDIR" || (echo "Error has occurred." ; exit 1) +download() { + # download url [filename[dirname]] + + DOWNLOAD_PATH="$PACKAGES" + DOWNLOAD_FILE="${2:-"${1##*/}"}" + + if [[ "$DOWNLOAD_FILE" =~ tar. ]]; then + TARGETDIR="${DOWNLOAD_FILE%.*}" + TARGETDIR="${3:-"${TARGETDIR%.*}"}" + else + TARGETDIR="${3:-"${DOWNLOAD_FILE%.*}"}" + fi + + if [ ! -f "$DOWNLOAD_PATH/$DOWNLOAD_FILE" ]; then + echo "Downloading $1 as $DOWNLOAD_FILE" + curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1" + + EXITCODE=$? + if [ $EXITCODE -ne 0 ]; then + echo "" + echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds" + sleep 10 + curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1" + fi + + EXITCODE=$? + if [ $EXITCODE -ne 0 ]; then + echo "" + echo "Failed to download $1. Exitcode $EXITCODE" + exit 1 + fi + + echo "... Done" + else + echo "$DOWNLOAD_FILE has already downloaded." + fi + + make_dir "$DOWNLOAD_PATH/$TARGETDIR" + + if [ -n "$3" ]; then + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 + fi + else + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 + fi + fi + + echo "Extracted $DOWNLOAD_FILE" + + cd "$DOWNLOAD_PATH/$TARGETDIR" || ( + echo "Error has occurred." + exit 1 + ) } -execute () { - echo "$ $*" +execute() { + echo "$ $*" - OUTPUT=$("$@" 2>&1) + OUTPUT=$("$@" 2>&1) - # shellcheck disable=SC2181 - if [ $? -ne 0 ]; then - echo "$OUTPUT" - echo "" - echo "Failed to Execute $*" >&2 - exit 1 - fi + # shellcheck disable=SC2181 + if [ $? -ne 0 ]; then + echo "$OUTPUT" + echo "" + echo "Failed to Execute $*" >&2 + exit 1 + fi } -build () { - echo "" - echo "building $1" - echo "=======================" +build() { + echo "" + echo "building $1" + echo "=======================" - if [ -f "$PACKAGES/$1.done" ]; then - echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it." - return 1 - fi + if [ -f "$PACKAGES/$1.done" ]; then + echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it." + return 1 + fi - return 0 + return 0 } -command_exists () { - if ! [[ -x $(command -v "$1") ]]; then - return 1 - fi +command_exists() { + if ! [[ -x $(command -v "$1") ]]; then + return 1 + fi - return 0 + return 0 } -library_exists () { - local result=0 - local output=$(pkg-config --exists --print-errors "$1" 2>&1 > /dev/null) || result=$? - if [ ! "$result" = "0" ]; then - return 1 - fi +library_exists() { + local result=0 + local output=$(pkg-config --exists --print-errors "$1" 2>&1 >/dev/null) || result=$? + if [ ! "$result" = "0" ]; then + return 1 + fi - return 0 + return 0 } -build_done () { - touch "$PACKAGES/$1.done" +build_done() { + touch "$PACKAGES/$1.done" } -verify_binary_type () { - BINARY_TYPE=$(file $WORKSPACE/bin/ffmpeg | sed -n 's/^.*\:\ \(.*$\)/\1/p') - echo "" - case $BINARY_TYPE in - "Mach-O 64-bit executable arm64") - echo "Successfully built Apple Silicon (M1) for ${OSTYPE}: ${BINARY_TYPE}" - ;; - *) - echo "Successfully built binary for ${OSTYPE}: ${BINARY_TYPE}" - ;; - esac +verify_binary_type() { + BINARY_TYPE=$(file $WORKSPACE/bin/ffmpeg | sed -n 's/^.*\:\ \(.*$\)/\1/p') + echo "" + case $BINARY_TYPE in + "Mach-O 64-bit executable arm64") + echo "Successfully built Apple Silicon (M1) for ${OSTYPE}: ${BINARY_TYPE}" + ;; + *) + echo "Successfully built binary for ${OSTYPE}: ${BINARY_TYPE}" + ;; + esac } -cleanup () { - remove_dir "$PACKAGES" - remove_dir "$WORKSPACE" - echo "Cleanup done." - echo "" +cleanup() { + remove_dir "$PACKAGES" + remove_dir "$WORKSPACE" + echo "Cleanup done." + echo "" } -usage () { - echo "Usage: $PROGNAME [OPTIONS]" - echo "Options:" - echo " -h, --help Display usage information" - echo " --version Display version information" - echo " -b, --build Starts the build process" - echo " -c, --cleanup Remove all working dirs" - echo " -f, --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" - echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." - echo "" +usage() { + echo "Usage: $PROGNAME [OPTIONS]" + echo "Options:" + echo " -h, --help Display usage information" + echo " --version Display version information" + echo " -b, --build Starts the build process" + echo " -c, --cleanup Remove all working dirs" + echo " -f, --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" + echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." + echo "" } -while (( $# > 0 )); do - case $1 in - -h | --help) - usage - exit 0 - ;; - --version) - echo "$VERSION" - exit 0 - ;; - -*) - if [[ "$1" == "--build" || "$1" =~ 'b' ]]; then - bflag='-b' - fi - if [[ "$1" == "--cleanup" || "$1" =~ 'c' && ! "$1" =~ '--' ]]; then - cflag='-c' - cleanup - fi - if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then - if [[ "$OSTYPE" == "darwin"* ]]; then - echo "Error: A full static binary can only be build on Linux." - exit 1 - fi - LDEXEFLAGS="-static" - fi - shift - ;; - *) - usage - exit 1 - ;; - esac +while (($# > 0)); do + case $1 in + -h | --help) + usage + exit 0 + ;; + --version) + echo "$VERSION" + exit 0 + ;; + -*) + if [[ "$1" == "--build" || "$1" =~ 'b' ]]; then + bflag='-b' + fi + if [[ "$1" == "--cleanup" || "$1" =~ 'c' && ! "$1" =~ '--' ]]; then + cflag='-c' + cleanup + fi + if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Error: A full static binary can only be build on Linux." + exit 1 + fi + LDEXEFLAGS="-static" + fi + shift + ;; + *) + usage + exit 1 + ;; + esac done echo "ffmpeg-build-script v$VERSION" @@ -226,17 +228,17 @@ echo "=========================" echo "" if [ -z "$bflag" ]; then - if [ -z "$cflag" ]; then - usage - exit 1 - fi - exit 0 + if [ -z "$cflag" ]; then + usage + exit 1 + fi + exit 0 fi echo "Using $MJOBS make jobs simultaneously." if [ -n "$LDEXEFLAGS" ]; then - echo "Start the build in full static mode." + echo "Start the build in full static mode." fi mkdir -p "$PACKAGES" @@ -248,38 +250,36 @@ PKG_CONFIG_PATH+=":/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfi export PKG_CONFIG_PATH if ! command_exists "make"; then - echo "make not installed."; - exit 1 + echo "make not installed." + exit 1 fi if ! command_exists "g++"; then - echo "g++ not installed."; - exit 1 + echo "g++ not installed." + exit 1 fi if ! command_exists "curl"; then - echo "curl not installed."; - exit 1 + echo "curl not installed." + exit 1 fi if ! command_exists "python"; then - echo "Python command not found. Lv2 filter will not be available."; + echo "Python command not found. Lv2 filter will not be available." fi - ## ## build tools ## if build "pkg-config"; then - download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" - execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib - execute make -j $MJOBS - execute make install - build_done "pkg-config" + download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" + execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib + execute make -j $MJOBS + execute make install + build_done "pkg-config" fi - if command_exists "python"; then if build "lv2"; then @@ -340,7 +340,7 @@ if command_exists "python"; then execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils execute ./waf execute ./waf install - CFLAGS+=" -I$WORKSPACE/include/lilv-0" + CFLAGS+=" -I$WORKSPACE/include/lilv-0" build_done "lilv" fi @@ -348,171 +348,167 @@ if command_exists "python"; then fi if build "yasm"; then - download "https://github.com/yasm/yasm/releases/download/v1.3.0/yasm-1.3.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" - execute make -j $MJOBS - execute make install - build_done "yasm" + download "https://github.com/yasm/yasm/releases/download/v1.3.0/yasm-1.3.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "yasm" fi if build "nasm"; then - download "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install - build_done "nasm" + download "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + build_done "nasm" fi if build "zlib"; then - download "https://www.zlib.net/zlib-1.2.11.tar.gz" - execute ./configure --static --prefix="${WORKSPACE}" - execute make -j $MJOBS - execute make install - build_done "zlib" + download "https://www.zlib.net/zlib-1.2.11.tar.gz" + execute ./configure --static --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "zlib" fi if build "openssl"; then - download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" - if $MACOS_M1 ; then - sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf - execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc - else - execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib - fi - execute make -j $MJOBS - execute make install_sw - build_done "openssl" + download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" + if $MACOS_M1; then + sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf + execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc + else + execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib + fi + execute make -j $MJOBS + execute make install_sw + build_done "openssl" fi CONFIGURE_OPTIONS+=("--enable-openssl") if build "cmake"; then - download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --system-zlib - execute make -j $MJOBS - execute make install - build_done "cmake" + download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --system-zlib + execute make -j $MJOBS + execute make install + build_done "cmake" fi - if build "svtav1"; then - download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" - cd Build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release - execute make -j $MJOBS - execute make install - execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" - execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" - build_done "svtav1" + download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" + cd Build/linux || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + execute make -j $MJOBS + execute make install + execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" + execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" + build_done "svtav1" fi CONFIGURE_OPTIONS+=("--enable-libsvtav1") - ## ## video library ## if build "x264"; then - download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" - cd "${PACKAGES}"/x264-0d754ec + download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" + cd "${PACKAGES}"/x264-0d754ec + if [[ "$OSTYPE" == "linux-gnu" ]]; then + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" + else + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic + fi - if [[ "$OSTYPE" == "linux-gnu" ]]; then - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" - else - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic - fi - - - execute make -j $MJOBS - execute make install - execute make install-lib-static + execute make -j $MJOBS + execute make install + execute make install-lib-static - build_done "x264" + build_done "x264" fi CONFIGURE_OPTIONS+=("--enable-libx264") if build "x265"; then - download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" - cd build/linux || exit + download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" + cd build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source - execute make -j $MJOBS - execute make install + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source + execute make -j $MJOBS + execute make install - if [ -n "$LDEXEFLAGS" ]; then - sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux - fi + if [ -n "$LDEXEFLAGS" ]; then + sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux + fi - build_done "x265" + build_done "x265" fi CONFIGURE_OPTIONS+=("--enable-libx265") if build "libvpx"; then - download "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" "libvpx-1.9.0.tar.gz" + download "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" "libvpx-1.9.0.tar.gz" - if [[ "$OSTYPE" == "darwin"* ]]; then - echo "Applying Darwin patch" - sed "s/,--version-script//g" build/make/Makefile > build/make/Makefile.patched - sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched > build/make/Makefile - fi + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Applying Darwin patch" + sed "s/,--version-script//g" build/make/Makefile >build/make/Makefile.patched + sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile + fi - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm - execute make -j $MJOBS - execute make install + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm + execute make -j $MJOBS + execute make install - build_done "libvpx" + build_done "libvpx" fi CONFIGURE_OPTIONS+=("--enable-libvpx") if build "xvidcore"; then - download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" - cd build/generic || exit - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install - - if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then - execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib" - fi + download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" + cd build/generic || exit + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + + if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then + execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib" + fi - if [[ -f ${WORKSPACE}/lib/libxvidcore.so ]]; then - execute rm "${WORKSPACE}"/lib/libxvidcore.so* - fi + if [[ -f ${WORKSPACE}/lib/libxvidcore.so ]]; then + execute rm "${WORKSPACE}"/lib/libxvidcore.so* + fi - build_done "xvidcore" + build_done "xvidcore" fi CONFIGURE_OPTIONS+=("--enable-libxvid") if build "vid_stab"; then - download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" + download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" + + if $MACOS_M1; then - if $MACOS_M1 ; then + curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch + patch -p1 configure.patched - chmod +x configure.patched - mv configure.patched configure - execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec - execute make -j $MJOBS - execute make install + download "https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-1.1.1.tar.gz" + sed "s/-fforce-addr//g" configure >configure.patched + chmod +x configure.patched + mv configure.patched configure + execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec + execute make -j $MJOBS + execute make install - build_done "libtheora" + build_done "libtheora" fi CONFIGURE_OPTIONS+=("--enable-libtheora") if build "fdk_aac"; then - download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.1.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install + download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.1.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.1.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install - build_done "fdk_aac" + build_done "fdk_aac" fi CONFIGURE_OPTIONS+=("--enable-libfdk-aac") - ## ## image library ## if build "libwebp"; then - download "https://github.com/webmproject/libwebp/archive/v1.1.0.tar.gz" "libwebp-1.1.0.tar.gz" - make_dir build - cd build || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ - execute make -j $MJOBS - execute make install + download "https://github.com/webmproject/libwebp/archive/v1.1.0.tar.gz" "libwebp-1.1.0.tar.gz" + make_dir build + cd build || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ + execute make -j $MJOBS + execute make install - build_done "libwebp" + build_done "libwebp" fi CONFIGURE_OPTIONS+=("--enable-libwebp") - ## ## other library ## if build "libsdl"; then - download "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install + download "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install - build_done "libsdl" + build_done "libsdl" fi if build "srt"; then - download "https://github.com/Haivision/srt/archive/v1.4.1.tar.gz" "srt-1.4.1.tar.gz" - export OPENSSL_ROOT_DIR="${WORKSPACE}" - export OPENSSL_LIB_DIR="${WORKSPACE}"/lib - export OPENSSL_INCLUDE_DIR="${WORKSPACE}"/include/ - execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON - execute make install - - if [ -n "$LDEXEFLAGS" ]; then - sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}"/lib/pkgconfig/srt.pc # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux - fi + download "https://github.com/Haivision/srt/archive/v1.4.1.tar.gz" "srt-1.4.1.tar.gz" + export OPENSSL_ROOT_DIR="${WORKSPACE}" + export OPENSSL_LIB_DIR="${WORKSPACE}"/lib + export OPENSSL_INCLUDE_DIR="${WORKSPACE}"/include/ + execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON + execute make install + + if [ -n "$LDEXEFLAGS" ]; then + sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}"/lib/pkgconfig/srt.pc # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux + fi - build_done "srt" + build_done "srt" fi CONFIGURE_OPTIONS+=("--enable-libsrt") - ## ## HWaccel library ## if [[ "$OSTYPE" == "linux-gnu" ]]; then - if command_exists "nvcc" ; then - if build "nv-codec"; then - download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.0/nv-codec-headers-11.0.10.0.tar.gz" - execute make PREFIX="${WORKSPACE}" - execute make install PREFIX="${WORKSPACE}" - build_done "nv-codec" - fi - CFLAGS+=" -I/usr/local/cuda/include" - LDFLAGS+=" -L/usr/local/cuda/lib64" - CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvenc" "--enable-cuda-llvm") - - if [ -z "$LDEXEFLAGS" ]; then - CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked. - fi - - # https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ - CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52") - fi - - # Vaapi doesn't work well with static links FFmpeg. - if [ -z "$LDEXEFLAGS" ]; then - # If the libva development SDK is installed, enable vaapi. - if library_exists "libva" ; then - if build "vaapi"; then - build_done "vaapi" - fi - CONFIGURE_OPTIONS+=("--enable-vaapi") - fi - fi -fi + if command_exists "nvcc"; then + if build "nv-codec"; then + download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.0/nv-codec-headers-11.0.10.0.tar.gz" + execute make PREFIX="${WORKSPACE}" + execute make install PREFIX="${WORKSPACE}" + build_done "nv-codec" + fi + CFLAGS+=" -I/usr/local/cuda/include" + LDFLAGS+=" -L/usr/local/cuda/lib64" + CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvenc" "--enable-cuda-llvm") + + if [ -z "$LDEXEFLAGS" ]; then + CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked. + fi + + # https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ + CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52") + fi + # Vaapi doesn't work well with static links FFmpeg. + if [ -z "$LDEXEFLAGS" ]; then + # If the libva development SDK is installed, enable vaapi. + if library_exists "libva"; then + if build "vaapi"; then + build_done "vaapi" + fi + CONFIGURE_OPTIONS+=("--enable-vaapi") + fi + fi +fi ## ## FFmpeg @@ -684,29 +676,29 @@ build "ffmpeg" download "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/553eb0773763798a6b9656b621cb125e1f6edbcc.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ - --disable-debug \ - --disable-doc \ - --disable-shared \ - --enable-gpl \ - --enable-nonfree \ - --enable-pthreads \ - --enable-static \ - --enable-small \ - --enable-version3 \ - --extra-cflags="${CFLAGS}" \ - --extra-ldexeflags="${LDEXEFLAGS}" \ - --extra-ldflags="${LDFLAGS}" \ - --extra-libs="${EXTRALIBS}" \ - --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ - --pkg-config-flags="--static" \ - --prefix="${WORKSPACE}" + --disable-debug \ + --disable-doc \ + --disable-shared \ + --enable-gpl \ + --enable-nonfree \ + --enable-pthreads \ + --enable-static \ + --enable-small \ + --enable-version3 \ + --extra-cflags="${CFLAGS}" \ + --extra-ldexeflags="${LDEXEFLAGS}" \ + --extra-ldflags="${LDFLAGS}" \ + --extra-libs="${EXTRALIBS}" \ + --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ + --pkg-config-flags="--static" \ + --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install INSTALL_FOLDER="/usr/bin" if [[ "$OSTYPE" == "darwin"* ]]; then - INSTALL_FOLDER="/usr/local/bin" + INSTALL_FOLDER="/usr/local/bin" fi verify_binary_type @@ -720,33 +712,33 @@ echo "- ffplay: $WORKSPACE/bin/ffplay" echo "" if [[ "$AUTOINSTALL" == "yes" ]]; then - if command_exists "sudo"; then - sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" - sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" + if command_exists "sudo"; then + sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" + sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" - echo "Done. FFmpeg is now installed to your system." - else - cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" - cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" + echo "Done. FFmpeg is now installed to your system." + else + cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" + cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" - echo "Done. FFmpeg is now installed to your system." - fi + echo "Done. FFmpeg is now installed to your system." + fi elif [[ ! "$SKIPINSTALL" == "yes" ]]; then - read -r -p "Install these binaries to your $INSTALL_FOLDER folder? Existing binaries will be replaced. [Y/n] " response - case $response in - [yY][eE][sS]|[yY]) - if command_exists "sudo"; then - sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" - sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" - sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" - else - cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" - cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" - cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" - fi - echo "Done. FFmpeg is now installed to your system." - ;; - esac + read -r -p "Install these binaries to your $INSTALL_FOLDER folder? Existing binaries will be replaced. [Y/n] " response + case $response in + [yY][eE][sS] | [yY]) + if command_exists "sudo"; then + sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" + sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" + sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + else + cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" + cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" + cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + fi + echo "Done. FFmpeg is now installed to your system." + ;; + esac fi exit 0 From 4e4196d841c1cfe583943121a39024c859c8748d Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 20 Jan 2021 08:50:12 +0100 Subject: [PATCH 013/111] Apple M1 Support + libsvtav1 support --- build-ffmpeg | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 431cfbd8..86ac6b30 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -144,9 +144,7 @@ command_exists() { } library_exists() { - local result=0 - local output=$(pkg-config --exists --print-errors "$1" 2>&1 >/dev/null) || result=$? - if [ ! "$result" = "0" ]; then + if ! [[ -x $(pkg-config --exists --print-errors "$1" 2>&1 >/dev/null) ]]; then return 1 fi @@ -158,7 +156,7 @@ build_done() { } verify_binary_type() { - BINARY_TYPE=$(file $WORKSPACE/bin/ffmpeg | sed -n 's/^.*\:\ \(.*$\)/\1/p') + BINARY_TYPE=$(file "$WORKSPACE/bin/ffmpeg" | sed -n 's/^.*\:\ \(.*$\)/\1/p') echo "" case $BINARY_TYPE in "Mach-O 64-bit executable arm64") @@ -298,7 +296,7 @@ if command_exists "python"; then if build "serd"; then download "https://gitlab.com/drobilla/serd/-/archive/v0.30.6/serd-v0.30.6.tar.gz" "serd-v0.30.6.tar.gz" - execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/serd-v0.30.6/waflib/" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.6/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix execute ./waf execute ./waf install @@ -316,9 +314,9 @@ if command_exists "python"; then if build "sord"; then download "https://gitlab.com/drobilla/sord/-/archive/v0.16.6/sord-v0.16.6.tar.gz" "sord-v0.16.6.tar.gz" - execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/sord-v0.16.6/waflib/" - execute ./waf configure --prefix="${WORKSPACE}" CFLAGS=${CFLAGS} --static --no-shared --no-utils - execute ./waf CFLAGS=${CFLAGS} + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.6/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" CFLAGS="${CFLAGS}" --static --no-shared --no-utils + execute ./waf CFLAGS="${CFLAGS}" execute ./waf install build_done "sord" @@ -326,7 +324,7 @@ if command_exists "python"; then if build "sratom"; then download "https://gitlab.com/lv2/sratom/-/archive/v0.6.6/sratom-v0.6.6.tar.gz" "sratom-v0.6.6.tar.gz" - execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/sratom-v0.6.6/waflib/" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.6/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared execute ./waf execute ./waf install @@ -336,7 +334,7 @@ if command_exists "python"; then if build "lilv"; then download "https://gitlab.com/lv2/lilv/-/archive/v0.24.10/lilv-v0.24.10.tar.gz" "lilv-v0.24.10.tar.gz" - execute cp -r ${PACKAGES}/autowaf/* "${PACKAGES}/lilv-v0.24.10/waflib/" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.10/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils execute ./waf execute ./waf install @@ -411,7 +409,7 @@ CONFIGURE_OPTIONS+=("--enable-libsvtav1") if build "x264"; then download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" - cd "${PACKAGES}"/x264-0d754ec + cd "${PACKAGES}"/x264-0d754ec || exit if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" From 6fd0116c8f6867fcc9dabbf4037014a8ebbb26ac Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 28 Jan 2021 14:03:20 +0100 Subject: [PATCH 014/111] binary check fix --- build-ffmpeg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-ffmpeg b/build-ffmpeg index 86ac6b30..100429d7 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -156,6 +156,10 @@ build_done() { } verify_binary_type() { + if ! command_exists "file"; then + return + fi + BINARY_TYPE=$(file "$WORKSPACE/bin/ffmpeg" | sed -n 's/^.*\:\ \(.*$\)/\1/p') echo "" case $BINARY_TYPE in From 6901f9dc55b657e76a2cbde5e5e7c330551b9864 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 10 Feb 2021 14:47:48 +0100 Subject: [PATCH 015/111] Fix #78 M1 Build --- build-ffmpeg | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 100429d7..d8a988ee 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -395,17 +395,19 @@ if build "cmake"; then build_done "cmake" fi -if build "svtav1"; then - download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" - cd Build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release - execute make -j $MJOBS - execute make install - execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" - execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" - build_done "svtav1" +if ! $MACOS_M1; then + if build "svtav1"; then + download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" + cd Build/linux || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + execute make -j $MJOBS + execute make install + execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" + execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" + build_done "svtav1" + fi + CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi -CONFIGURE_OPTIONS+=("--enable-libsvtav1") ## ## video library From 2f2f903f31658b46ebacfc0ae546c33576ae7204 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 10 Feb 2021 15:47:50 +0100 Subject: [PATCH 016/111] Version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index d8a988ee..c47ad2fd 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.22 +VERSION=1.23 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From 18e6e24e99765730f0dd936037e03b539eeed5c0 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 10 Feb 2021 16:04:50 +0100 Subject: [PATCH 017/111] Readme update --- README.md | 95 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index ad5982d1..11935ab6 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,29 @@ ![FFmpeg build script](https://raw.github.com/markus-perl/ffmpeg-build-script/master/ffmpeg-build-script.png) +### If you like the script, please "★" this project! build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with **non-free codecs** included. - +The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with ** non-free +codecs** included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") -*Youtube: How-To build and install FFmpeg on MacOS* - +*Youtube: How-To build and install FFmpeg on macOS* ## Disclaimer And Data Privacy Notice -This script will download different packages with different licenses from various sources, which may track your usage. -These sources are out of control by the developers of this script. By downloading and using this script, you are fully aware of this. -Use this script at your own risk. I maintain this script in my spare time. -Please do not file bug reports for systems other than Debian 10 and macOS 11.x, -because I don't have the resources or time to maintain different systems. +This script will download different packages with different licenses from various sources, which may track your usage. +These sources are out of control by the developers of this script. By downloading and using this script, you are fully +aware of this. +Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems +other than Debian 10 and macOS 11.x, because I don't have the resources or time to maintain different systems. ## Supported Codecs + * `x264`: H.264 Video Codec (MPEG-4 AVC) * `x265`: H.265 Video Codec (HEVC) * `libsvtav1`, SVT-AV1 Encoder and Decoder @@ -41,7 +42,10 @@ because I don't have the resources or time to maintain different systems. * `webp`: Image format both lossless and lossy ### HardwareAccel -* `nv-codec`: [NVIDIA's GPU accelerated video codecs](https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/). These encoders/decoders will only be available if a CUDA installation was found while building the binary. Follow [these](#Cuda-installation) instructions for installation. Supported codecs in nvcodec: + +* `nv-codec`: [NVIDIA's GPU accelerated video codecs](https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/). + These encoders/decoders will only be available if a CUDA installation was found while building the binary. + Follow [these](#Cuda-installation) instructions for installation. Supported codecs in nvcodec: * Decoders * H264 `h264_cuvid` * H265 `hevc_cuvid` @@ -55,7 +59,9 @@ because I don't have the resources or time to maintain different systems. * Encoders * H264 `nvenc_h264` * H265 `nvenc_hevc` -* `vaapi`: [Video Acceleration API](https://trac.ffmpeg.org/wiki/Hardware/VAAPI). These encoders/decoders will only be available if a libva driver installation was found while building the binary. Follow [these](#Vaapi-installation) instructions for installation. Supported codecs in vaapi: +* `vaapi`: [Video Acceleration API](https://trac.ffmpeg.org/wiki/Hardware/VAAPI). These encoders/decoders will only be + available if a libva driver installation was found while building the binary. Follow [these](#Vaapi-installation) + instructions for installation. Supported codecs in vaapi: * Encoders * H264 `h264_vaapi` * H265 `hevc_vaapi` @@ -65,16 +71,20 @@ because I don't have the resources or time to maintain different systems. * VP9 `vp9_vaapi` ### Apple M1 (Apple Silicon) Support + The script also builds FFmpeg on a new MacBook with an Apple Silicon M1 processor. ### LV2 Plugin Support + If Python is available, the script will build a ffmpeg binary with lv2 plugin support. -## Continuos Integration -ffmpeg-build-script is rockstable. Every commit runs against Linux and MacOS with https://github.com/markus-perl/ffmpeg-build-script/actions just to make sure everything works as expected. +## Continuous Integration +ffmpeg-build-script is very stable. Every commit runs against Linux and macOS +with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure everything works as expected. ## Requirements + ### macOS * XCode 10.x or greater @@ -96,7 +106,7 @@ $ sudo dnf install @development-tools curl ### Quick install and run (macOS, Linux) -Open your command line and run (needs curl to be installed): +Open your command line and run (curl needs to be installed): ```bash $ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") @@ -114,31 +124,38 @@ $ ./build-ffmpeg --help ### Build in Docker (Linux) -With Docker, FFmpeg can be built reliably without altering the host system. -Also, there is no need to have the CUDA SDK installed outside of the Docker image. +With Docker, FFmpeg can be built reliably without altering the host system. Also, there is no need to have the CUDA SDK +installed outside of the Docker image. A Docker engine with version 19.03 or higher is required to build images based on the following distributions: + * Ubuntu >= 16.04 (16.04, 18.04, 20.04) * Centos >= 7 (7, 8) 1. Enable Docker BuildKit + ```bash $ export DOCKER_BUILDKIT=1 ``` -2. Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment variables to select the preferred Docker base image. +2. Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment + variables to select the preferred Docker base image. + ```bash $ export DIST=centos $ export VER=8 ``` 3. Start the build as follows. + ```bash $ sudo -E docker build --tag=ffmpeg:cuda-$DIST -f cuda-$DIST.dockerfile --build-arg VER=$VER . ``` -4. Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. -Since we have matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit the `export.dockerfile` and copy the necessary libraries and try again. +4. Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, + move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. Since we have + matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit + the `export.dockerfile` and copy the necessary libraries and try again. ```bash $ sudo -E docker build --output type=local,dest=build -f export.dockerfile --build-arg DIST=$DIST . @@ -151,16 +168,20 @@ libnppc.so.11 libnppicc.so.11 libnppidei.so.11 libnppig.so.11 ``` ### Build in Docker (full static ver.) (Linux) -If you're running an operating system other than the one above, a completely static build may work. -To build a full statically linked binary inside Docker, just run the following command: + +If you're running an operating system other than the one above, a completely static build may work. To build a full +statically linked binary inside Docker, just run the following command: + ```bash $ sudo -E docker build --tag=ffmpeg:cuda-static --output type=local,dest=build -f full-static.dockerfile . ``` ### Run with Docker (macOS, Linux) + You can also run the FFmpeg directly inside a Docker container. #### Default - Without CUDA (macOS, Linux) + If CUDA is not required, a dockerized FFmpeg build can be executed with the following command: ```bash @@ -169,9 +190,12 @@ $ sudo docker run ffmpeg -i https://files.coconut.co.s3.amazonaws.com/test.mp4 - ``` #### With CUDA (Linux) -To use CUDA from inside the container, the installed Docker version must be >= 19.03. -Install the driver and `nvidia-docker2` from [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-docker-ce). + +To use CUDA from inside the container, the installed Docker version must be >= 19.03. Install the driver +and `nvidia-docker2` +from [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-docker-ce). You can then run FFmpeg inside Docker with GPU hardware acceleration enabled, as follows: + ```bash $ sudo docker build --tag=ffmpeg:cuda -f cuda-ubuntu.dockerfile . $ sudo docker run --gpus all ffmpeg-cuda -hwaccel cuvid -c:v h264_cuvid -i https://files.coconut.co.s3.amazonaws.com/test.mp4 -c:v hevc_nvenc -vf scale_npp=-1:1080 - > test.mp4 @@ -189,13 +213,14 @@ $ ./build-ffmpeg --build ## Cuda installation -CUDA is a parallel computing platform developed by NVIDIA. -To be able to compile ffmpeg with CUDA support, you first need a compatible NVIDIA GPU. -- Ubuntu: To install the CUDA toolkit on Ubuntu, simply run "sudo apt install nvidia-cuda-toolkit" +CUDA is a parallel computing platform developed by NVIDIA. To be able to compile ffmpeg with CUDA support, you first +need a compatible NVIDIA GPU. + +- Ubuntu: To install the CUDA toolkit on Ubuntu, run "sudo apt install nvidia-cuda-toolkit" - Other Linux distributions: Once you have the GPU and display driver installed, you can follow the -[official instructions](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) -or [this blog](https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-1-on-Ubuntu-19-04-1405/) -to setup the CUDA toolkit. + [official instructions](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) + or [this blog](https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-1-on-Ubuntu-19-04-1405/) + to setup the CUDA toolkit. ## Vaapi installation @@ -223,8 +248,9 @@ Options: ``` ## Notes of static link -- Because of the NSS (Name Service Switch), glibc does **not recommend** static links. - See detail below: https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F + +- Because of the NSS (Name Service Switch), glibc does **not recommend** static links. See detail + below: https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F - The libnpp in the CUDA SDK cannot be statically linked. - Vaapi cannot be statically linked. @@ -234,7 +260,6 @@ Contact * Github: [http://www.github.com/markus-perl/](https://github.com/markus-perl/ffmpeg-build-script) - Tested on --------- @@ -693,7 +718,7 @@ avfoundation lavfi Enabled outdevs: sdl2 -License: nonfree and unredistributable +License: non-free and unredistributable $ make -j 12 $ make install @@ -707,12 +732,12 @@ Password: Done. FFmpeg is now installed to your system. ``` - Other Projects Of Mine ------------ + - [Pushover CLI Client](https://github.com/markus-perl/pushover-cli) - [Gender API](https://gender-api.com): [Genderize A Name](https://gender-api.com) - [Gender API Client PHP](https://github.com/markus-perl/gender-api-client) - [Gender API Client NPM](https://github.com/markus-perl/gender-api-client-npm) - [Genderize Names](https://www.youtube.com/watch?v=2SLIAguaygo) -- [Genderize API](https://gender-api.io) +- [Genderize API](https://gender-api.io) \ No newline at end of file From b058b4c4a01b4a89639f4ea77d5b56c35cf6d748 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 10 Feb 2021 16:07:04 +0100 Subject: [PATCH 018/111] Readme update --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 11935ab6..4cdb2567 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,26 @@ aware of this. Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems other than Debian 10 and macOS 11.x, because I don't have the resources or time to maintain different systems. +## Installation + +### Quick install and run (macOS, Linux) + +Open your command line and run (curl needs to be installed): + +```bash +$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") +``` + +This command downloads the build script and automatically starts the build process. + +### Common installation (macOS, Linux) + +```bash +$ git clone https://github.com/markus-perl/ffmpeg-build-script.git +$ cd ffmpeg-build-script +$ ./build-ffmpeg --build +``` + ## Supported Codecs * `x264`: H.264 Video Codec (MPEG-4 AVC) @@ -102,26 +122,6 @@ $ sudo apt install build-essential curl $ sudo dnf install @development-tools curl ``` -## Installation - -### Quick install and run (macOS, Linux) - -Open your command line and run (curl needs to be installed): - -```bash -$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") -``` - -This command downloads the build script and automatically starts the build process. - -### Common installation (macOS, Linux) - -```bash -$ git clone https://github.com/markus-perl/ffmpeg-build-script.git -$ cd ffmpeg-build-script -$ ./build-ffmpeg --help -``` - ### Build in Docker (Linux) With Docker, FFmpeg can be built reliably without altering the host system. Also, there is no need to have the CUDA SDK From e7ae427c3484dc4efc7f3f5f65f6bdf75ab5b0c2 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Tue, 30 Mar 2021 11:59:37 +0200 Subject: [PATCH 019/111] readme update --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4cdb2567..923bd903 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with ** non-free -codecs** included. +The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with **non-freecodecs** included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") @@ -17,7 +16,7 @@ codecs** included. ## Disclaimer And Data Privacy Notice This script will download different packages with different licenses from various sources, which may track your usage. -These sources are out of control by the developers of this script. By downloading and using this script, you are fully +These sources are out of control by the developers of this script. Also, this script creates a non-free and unredistributable binary. By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems @@ -740,4 +739,4 @@ Other Projects Of Mine - [Gender API Client PHP](https://github.com/markus-perl/gender-api-client) - [Gender API Client NPM](https://github.com/markus-perl/gender-api-client-npm) - [Genderize Names](https://www.youtube.com/watch?v=2SLIAguaygo) -- [Genderize API](https://gender-api.io) \ No newline at end of file +- [Genderize API](https://gender-api.io) From f88b91adcc0238cb14802fa40bd3ae2638d15eee Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 31 Mar 2021 12:00:46 +0200 Subject: [PATCH 020/111] Readme update, gpl-and-non-free --- .github/workflows/build.yml | 4 +-- README.md | 56 ++++++++++++++++++------------------- build-ffmpeg | 52 ++++++++++++++++++++++------------ cuda-centos.dockerfile | 2 +- cuda-ubuntu.dockerfile | 2 +- 5 files changed, 65 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0efb7e..09332739 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: build ffmpeg run: | while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build + SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build --enable-gpl-and-non-free kill %1 - name: check shared library run: | @@ -45,7 +45,7 @@ jobs: - name: build ffmpeg run: | while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build + SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build --enable-gpl-and-non-free kill %1 - name: check shared library run: | diff --git a/README.md b/README.md index 923bd903..88607a95 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with **non-freecodecs** included. +The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free) included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") @@ -16,8 +16,8 @@ The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS ## Disclaimer And Data Privacy Notice This script will download different packages with different licenses from various sources, which may track your usage. -These sources are out of control by the developers of this script. Also, this script creates a non-free and unredistributable binary. By downloading and using this script, you are fully -aware of this. +These sources are out of control by the developers of this script. Also, this script can create a non-free and unredistributable binary. +By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems other than Debian 10 and macOS 11.x, because I don't have the resources or time to maintain different systems. @@ -126,38 +126,35 @@ $ sudo dnf install @development-tools curl With Docker, FFmpeg can be built reliably without altering the host system. Also, there is no need to have the CUDA SDK installed outside of the Docker image. -A Docker engine with version 19.03 or higher is required to build images based on the following distributions: +##### Default -* Ubuntu >= 16.04 (16.04, 18.04, 20.04) -* Centos >= 7 (7, 8) - -1. Enable Docker BuildKit +If you're running an operating system other than the one above, a completely static build may work. To build a full +statically linked binary inside Docker, just run the following command: ```bash -$ export DOCKER_BUILDKIT=1 +$ docker build --tag=ffmpeg:default --output type=local,dest=build -f Dockerfile . ``` -2. Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment - variables to select the preferred Docker base image. - +##### CUDA +These builds are always built with the --enable-gpl-and-non-free switch, as CUDA is non-free. See https://ffmpeg.org/legal.html ```bash +export DOCKER_BUILDKIT=1 + +## Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment variables to select the preferred Docker base image. $ export DIST=centos $ export VER=8 -``` -3. Start the build as follows. - -```bash -$ sudo -E docker build --tag=ffmpeg:cuda-$DIST -f cuda-$DIST.dockerfile --build-arg VER=$VER . +## Start the build +$ docker build --tag=ffmpeg:cuda-$DIST -f cuda-$DIST.dockerfile --build-arg VER=$VER . ``` -4. Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, - move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. Since we have - matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit - the `export.dockerfile` and copy the necessary libraries and try again. +Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, +move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. Since we have +matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit +the `export.dockerfile` and copy the necessary libraries and try again. ```bash -$ sudo -E docker build --output type=local,dest=build -f export.dockerfile --build-arg DIST=$DIST . +$ docker build --output type=local,dest=build -f export.dockerfile --build-arg DIST=$DIST . $ ls build bin lib $ ls build/bin @@ -166,7 +163,7 @@ $ ls build/lib libnppc.so.11 libnppicc.so.11 libnppidei.so.11 libnppig.so.11 ``` -### Build in Docker (full static ver.) (Linux) +##### Full static version If you're running an operating system other than the one above, a completely static build may work. To build a full statically linked binary inside Docker, just run the following command: @@ -238,12 +235,13 @@ $ sudo dnf install libva-devel libva-intel-driver libva-utils ```bash Usage: build-ffmpeg [OPTIONS] Options: - -h, --help Display usage information - --version Display version information - -b, --build Starts the build process - -c, --cleanup Remove all working dirs - -f, --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux** - Note: Because of the NSS (Name Service Switch), glibc does not recommend static links. + -h, --help Display usage information + --version Display version information + -b, --build Starts the build process + --enable-gpl-and-non-free Enable non-free codecs - https://ffmpeg.org/legal.html + -c, --cleanup Remove all working dirs + --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux** + Note: Because of the NSS (Name Service Switch), glibc does not recommend static links. ``` ## Notes of static link diff --git a/build-ffmpeg b/build-ffmpeg index c47ad2fd..8f0357c0 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.23 +VERSION=1.24 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -14,6 +14,8 @@ LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" MACOS_M1=false CONFIGURE_OPTIONS=() +NONFREE_AND_GPL=false + # Check for Apple Silicon if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then # If arm64 AND darwin (macOS) @@ -182,12 +184,13 @@ cleanup() { usage() { echo "Usage: $PROGNAME [OPTIONS]" echo "Options:" - echo " -h, --help Display usage information" - echo " --version Display version information" - echo " -b, --build Starts the build process" - echo " -c, --cleanup Remove all working dirs" - echo " -f, --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" - echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." + echo " -h, --help Display usage information" + echo " --version Display version information" + echo " -b, --build Starts the build process" + echo " --enable-gpl-and-non-free Enable GPL and non-free codecs - https://ffmpeg.org/legal.html" + echo " -c, --cleanup Remove all working dirs" + echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" + echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." echo "" } @@ -202,14 +205,19 @@ while (($# > 0)); do exit 0 ;; -*) - if [[ "$1" == "--build" || "$1" =~ 'b' ]]; then + if [[ "$1" == "--build" || "$1" =~ '-b' ]]; then bflag='-b' fi - if [[ "$1" == "--cleanup" || "$1" =~ 'c' && ! "$1" =~ '--' ]]; then + if [[ "$1" == "--enable-gpl-and-non-free" ]]; then + CONFIGURE_OPTIONS+=("--enable-nonfree") + CONFIGURE_OPTIONS+=("--enable-gpl") + NONFREE_AND_GPL=true + fi + if [[ "$1" == "--cleanup" || "$1" =~ '-c' && ! "$1" =~ '--' ]]; then cflag='-c' cleanup fi - if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then + if [[ "$1" == "--full-static" ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then echo "Error: A full static binary can only be build on Linux." exit 1 @@ -373,6 +381,7 @@ if build "zlib"; then build_done "zlib" fi +if $NONFREE_AND_GPL; then if build "openssl"; then download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" if $MACOS_M1; then @@ -386,10 +395,12 @@ if build "openssl"; then build_done "openssl" fi CONFIGURE_OPTIONS+=("--enable-openssl") +fi if build "cmake"; then download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --system-zlib + execute ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF + execute ./configure --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install build_done "cmake" @@ -409,10 +420,7 @@ if ! $MACOS_M1; then CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi -## -## video library -## - +if $NONFREE_AND_GPL; then if build "x264"; then download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" cd "${PACKAGES}"/x264-0d754ec || exit @@ -430,7 +438,9 @@ if build "x264"; then build_done "x264" fi CONFIGURE_OPTIONS+=("--enable-libx264") +fi +if $NONFREE_AND_GPL; then if build "x265"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" cd build/linux || exit @@ -446,6 +456,7 @@ if build "x265"; then build_done "x265" fi CONFIGURE_OPTIONS+=("--enable-libx265") +fi if build "libvpx"; then download "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" "libvpx-1.9.0.tar.gz" @@ -464,6 +475,7 @@ if build "libvpx"; then fi CONFIGURE_OPTIONS+=("--enable-libvpx") +if $NONFREE_AND_GPL; then if build "xvidcore"; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit @@ -482,12 +494,13 @@ if build "xvidcore"; then build_done "xvidcore" fi CONFIGURE_OPTIONS+=("--enable-libxvid") +fi +if $NONFREE_AND_GPL; then if build "vid_stab"; then download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" if $MACOS_M1; then - curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch patch -p1 Date: Wed, 31 Mar 2021 13:22:33 +0200 Subject: [PATCH 021/111] Readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88607a95..f8835b5f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free) included. +The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free, see https://ffmpeg.org/legal.html) included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") From b3e9a847889525fb7eb78c7891040d2c0b5846fd Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Wed, 31 Mar 2021 16:21:42 +0200 Subject: [PATCH 022/111] Readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8835b5f..430f9884 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free, see https://ffmpeg.org/legal.html) included. +The FFmpeg build script provides an easy way to build a **static** FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free, see https://ffmpeg.org/legal.html) included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") From 90c4a9f3e7d5d6f08731a6e5e155010b6d1d87d4 Mon Sep 17 00:00:00 2001 From: Rokib Hasan Sagar Date: Tue, 27 Apr 2021 02:47:09 +0600 Subject: [PATCH 023/111] Update ffmpeg source till stable v4.4 snapshot --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 8f0357c0..6cae60ef 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -695,7 +695,7 @@ fi ## build "ffmpeg" -download "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/553eb0773763798a6b9656b621cb125e1f6edbcc.tar.gz" +download "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/dc91b913b6260e85e1304c74ff7bb3c22a8c9fb1.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ From 837c50500ffdc69d831dc07af7d12a27b9c213ef Mon Sep 17 00:00:00 2001 From: rokibhasansagar Date: Tue, 4 May 2021 12:59:12 +0600 Subject: [PATCH 024/111] Update plugins to latest stable version/commit - lv2 - 1.18.0 > 1.18.2 - waflib - cc37724b9bfa889baebd8cb10f38b8c7cab83e37 > b600c928b221a001faeab7bd92786d0b25714bc8 - serd - v0.30.6 > v0.30.10 - sord - v0.16.6 > v0.16.8 - sratom - v0.6.6 > v0.6.8 - lilv - v0.24.10 > v0.24.12 - openssl - 1.1.1i > 1.1.1k - cmake - 3.18.4 > 3.20.2 - only './configure' is needed which eventually triggers './bootstrap' - used parallel jobs for configuring cmake with '--parallel' flag per core - x264 - 0d754ec36013fee82978496cd56fbd48824910b3 > stable - libvpx - v1.9.0 > v1.10.0 - libaom/av1 - v2.0.1/b52ee6d44adaef8a08f6984390de050d64df9faa > v3.1.0/c0f14141bd71414b004dccd66d48b27570299fa3 - [!] Removed >> Broken in Native MacOS: libogg 1.3.3>1.3.4, libvorbis 1.3.6>1.3.7, libtheora 1.1.1>1.2.0alpha1 - fdk-aac - 2.0.1 > 2.0.2 - added option '--enable-pic' - libwebp - 1.1.0 > 1.2.0 - libsrt - 1.4.1 > 1.4.3 - nv-codec - n11.0.10.1 > n11.0.10.0 Signed-off-by: rokibhasansagar <10854164+rokibhasansagar@users.noreply.github.com> --- build-ffmpeg | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 6cae60ef..6d7a3452 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -293,7 +293,7 @@ fi if command_exists "python"; then if build "lv2"; then - download "https://lv2plug.in/spec/lv2-1.18.0.tar.bz2" "lv2-1.18.0.tar.bz2" + download "https://lv2plug.in/spec/lv2-1.18.2.tar.bz2" "lv2-1.18.2.tar.bz2" execute ./waf configure --prefix="${WORKSPACE}" --lv2-user execute ./waf execute ./waf install @@ -302,13 +302,13 @@ if command_exists "python"; then fi if build "waflib"; then - download "https://gitlab.com/drobilla/autowaf/-/archive/cc37724b9bfa889baebd8cb10f38b8c7cab83e37/autowaf-cc37724b9bfa889baebd8cb10f38b8c7cab83e37.tar.gz" "autowaf.tar.gz" + download "https://gitlab.com/drobilla/autowaf/-/archive/b600c928b221a001faeab7bd92786d0b25714bc8/autowaf-b600c928b221a001faeab7bd92786d0b25714bc8.tar.gz" "autowaf.tar.gz" build_done "waflib" fi if build "serd"; then - download "https://gitlab.com/drobilla/serd/-/archive/v0.30.6/serd-v0.30.6.tar.gz" "serd-v0.30.6.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.6/waflib/" + download "https://gitlab.com/drobilla/serd/-/archive/v0.30.10/serd-v0.30.10.tar.gz" "serd-v0.30.10.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.10/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix execute ./waf execute ./waf install @@ -325,8 +325,8 @@ if command_exists "python"; then fi if build "sord"; then - download "https://gitlab.com/drobilla/sord/-/archive/v0.16.6/sord-v0.16.6.tar.gz" "sord-v0.16.6.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.6/waflib/" + download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.8/waflib/" execute ./waf configure --prefix="${WORKSPACE}" CFLAGS="${CFLAGS}" --static --no-shared --no-utils execute ./waf CFLAGS="${CFLAGS}" execute ./waf install @@ -335,8 +335,8 @@ if command_exists "python"; then fi if build "sratom"; then - download "https://gitlab.com/lv2/sratom/-/archive/v0.6.6/sratom-v0.6.6.tar.gz" "sratom-v0.6.6.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.6/waflib/" + download "https://gitlab.com/lv2/sratom/-/archive/v0.6.8/sratom-v0.6.8.tar.gz" "sratom-v0.6.8.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.8/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared execute ./waf execute ./waf install @@ -345,8 +345,8 @@ if command_exists "python"; then fi if build "lilv"; then - download "https://gitlab.com/lv2/lilv/-/archive/v0.24.10/lilv-v0.24.10.tar.gz" "lilv-v0.24.10.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.10/waflib/" + download "https://gitlab.com/lv2/lilv/-/archive/v0.24.12/lilv-v0.24.12.tar.gz" "lilv-v0.24.12.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.12/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils execute ./waf execute ./waf install @@ -383,7 +383,7 @@ fi if $NONFREE_AND_GPL; then if build "openssl"; then - download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" + download "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" if $MACOS_M1; then sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc @@ -398,9 +398,8 @@ CONFIGURE_OPTIONS+=("--enable-openssl") fi if build "cmake"; then - download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" - execute ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF - execute ./configure --prefix="${WORKSPACE}" + download "https://cmake.org/files/LatestRelease/cmake-3.20.2.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF execute make -j $MJOBS execute make install build_done "cmake" @@ -422,8 +421,8 @@ fi if $NONFREE_AND_GPL; then if build "x264"; then - download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" - cd "${PACKAGES}"/x264-0d754ec || exit + download "https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.gz" "x264-stable.tar.gz" + cd "${PACKAGES}"/x264-stable || exit if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" @@ -459,7 +458,7 @@ CONFIGURE_OPTIONS+=("--enable-libx265") fi if build "libvpx"; then - download "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" "libvpx-1.9.0.tar.gz" + download "https://github.com/webmproject/libvpx/archive/refs/tags/v1.10.0.tar.gz" "libvpx-1.10.0.tar.gz" if [[ "$OSTYPE" == "darwin"* ]]; then echo "Applying Darwin patch" @@ -515,7 +514,7 @@ CONFIGURE_OPTIONS+=("--enable-libvidstab") fi if build "av1"; then - download "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" "av1.tar.gz" "av1" + download "https://aomedia.googlesource.com/aom/+archive/c0f14141bd71414b004dccd66d48b27570299fa3.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit if $MACOS_M1; then @@ -597,8 +596,8 @@ CONFIGURE_OPTIONS+=("--enable-libtheora") if $NONFREE_AND_GPL; then if build "fdk_aac"; then - download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.1.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.2.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.2.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --enable-pic execute make -j $MJOBS execute make install @@ -612,7 +611,7 @@ fi ## if build "libwebp"; then - download "https://github.com/webmproject/libwebp/archive/v1.1.0.tar.gz" "libwebp-1.1.0.tar.gz" + download "https://github.com/webmproject/libwebp/archive/v1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" make_dir build cd build || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ @@ -638,7 +637,7 @@ fi if $NONFREE_AND_GPL; then if build "srt"; then - download "https://github.com/Haivision/srt/archive/v1.4.1.tar.gz" "srt-1.4.1.tar.gz" + download "https://github.com/Haivision/srt/archive/v1.4.3.tar.gz" "srt-1.4.3.tar.gz" export OPENSSL_ROOT_DIR="${WORKSPACE}" export OPENSSL_LIB_DIR="${WORKSPACE}"/lib export OPENSSL_INCLUDE_DIR="${WORKSPACE}"/include/ @@ -661,7 +660,7 @@ fi if [[ "$OSTYPE" == "linux-gnu" ]]; then if command_exists "nvcc"; then if build "nv-codec"; then - download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.0/nv-codec-headers-11.0.10.0.tar.gz" + download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.1/nv-codec-headers-11.0.10.1.tar.gz" execute make PREFIX="${WORKSPACE}" execute make install PREFIX="${WORKSPACE}" build_done "nv-codec" From 59f675542b99441501a40e93e37800775ec9cfdf Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Fri, 14 May 2021 19:58:01 +0200 Subject: [PATCH 025/111] Version update --- build-ffmpeg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 6d7a3452..4eae1db6 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.24 +VERSION=1.25 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -194,6 +194,10 @@ usage() { echo "" } +echo "ffmpeg-build-script v$VERSION" +echo "=========================" +echo "" + while (($# > 0)); do case $1 in -h | --help) @@ -233,10 +237,6 @@ while (($# > 0)); do esac done -echo "ffmpeg-build-script v$VERSION" -echo "=========================" -echo "" - if [ -z "$bflag" ]; then if [ -z "$cflag" ]; then usage From 8683e0f88dea4ae1ef956b7c4ade238d7754034b Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 17 May 2021 08:03:25 +0200 Subject: [PATCH 026/111] Formatter --- build-ffmpeg | 196 ++++++++++++++++++++++++++++----------------------- 1 file changed, 108 insertions(+), 88 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 4eae1db6..d02ce319 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -382,19 +382,19 @@ if build "zlib"; then fi if $NONFREE_AND_GPL; then -if build "openssl"; then - download "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" - if $MACOS_M1; then - sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf - execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc - else - execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib + if build "openssl"; then + download "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" + if $MACOS_M1; then + sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf + execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc + else + execute ./config --prefix="${WORKSPACE}" --openssldir="${WORKSPACE}" --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib no-shared zlib + fi + execute make -j $MJOBS + execute make install_sw + build_done "openssl" fi - execute make -j $MJOBS - execute make install_sw - build_done "openssl" -fi -CONFIGURE_OPTIONS+=("--enable-openssl") + CONFIGURE_OPTIONS+=("--enable-openssl") fi if build "cmake"; then @@ -407,7 +407,7 @@ fi if ! $MACOS_M1; then if build "svtav1"; then - download "https://github.com/AOMediaCodec/SVT-AV1/archive/v0.8.6.tar.gz" + download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/master/SVT-AV1-master.tar.gz" cd Build/linux || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release execute make -j $MJOBS @@ -420,41 +420,42 @@ if ! $MACOS_M1; then fi if $NONFREE_AND_GPL; then -if build "x264"; then - download "https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.gz" "x264-stable.tar.gz" - cd "${PACKAGES}"/x264-stable || exit - if [[ "$OSTYPE" == "linux-gnu" ]]; then - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" - else - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic - fi + if build "x264"; then + download "https://code.videolan.org/videolan/x264/-/archive/b684ebe04a6f80f8207a57940a1fa00e25274f81/x264-b684ebe04a6f80f8207a57940a1fa00e25274f81.tar.gz" "x264-b684eb.tar.gz" + cd "${PACKAGES}"/x264-b684eb || exit - execute make -j $MJOBS - execute make install - execute make install-lib-static + if [[ "$OSTYPE" == "linux-gnu" ]]; then + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" + else + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic + fi - build_done "x264" -fi -CONFIGURE_OPTIONS+=("--enable-libx264") + execute make -j $MJOBS + execute make install + execute make install-lib-static + + build_done "x264" + fi + CONFIGURE_OPTIONS+=("--enable-libx264") fi if $NONFREE_AND_GPL; then -if build "x265"; then - download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" - cd build/linux || exit + if build "x265"; then + download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" + cd build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source - execute make -j $MJOBS - execute make install + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source + execute make -j $MJOBS + execute make install - if [ -n "$LDEXEFLAGS" ]; then - sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux - fi + if [ -n "$LDEXEFLAGS" ]; then + sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux + fi - build_done "x265" -fi -CONFIGURE_OPTIONS+=("--enable-libx265") + build_done "x265" + fi + CONFIGURE_OPTIONS+=("--enable-libx265") fi if build "libvpx"; then @@ -466,7 +467,7 @@ if build "libvpx"; then sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile fi - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm --enable-vp9-highbitdepth execute make -j $MJOBS execute make install @@ -475,42 +476,42 @@ fi CONFIGURE_OPTIONS+=("--enable-libvpx") if $NONFREE_AND_GPL; then -if build "xvidcore"; then - download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" - cd build/generic || exit - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install + if build "xvidcore"; then + download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" + cd build/generic || exit + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install - if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then - execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib" - fi + if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then + execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib" + fi - if [[ -f ${WORKSPACE}/lib/libxvidcore.so ]]; then - execute rm "${WORKSPACE}"/lib/libxvidcore.so* - fi + if [[ -f ${WORKSPACE}/lib/libxvidcore.so ]]; then + execute rm "${WORKSPACE}"/lib/libxvidcore.so* + fi - build_done "xvidcore" -fi -CONFIGURE_OPTIONS+=("--enable-libxvid") + build_done "xvidcore" + fi + CONFIGURE_OPTIONS+=("--enable-libxvid") fi if $NONFREE_AND_GPL; then -if build "vid_stab"; then - download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" + if build "vid_stab"; then + download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" - if $MACOS_M1; then - curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch - patch -p1 Date: Mon, 17 May 2021 10:29:28 +0200 Subject: [PATCH 027/111] bugfix release --- build-ffmpeg | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index d02ce319..796efe12 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.25 +VERSION=1.26 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -530,25 +530,6 @@ if build "av1"; then fi CONFIGURE_OPTIONS+=("--enable-libaom") -if build "dav1d"; then - download "https://code.videolan.org/videolan/dav1d/-/archive/0.8.2/dav1d-0.8.2.tar.gz" "dav1d-0.8.2.tar.gz" - make_dir "$PACKAGES"/dav1d/build - cd "$PACKAGES"/dav1d/build || exit - execute meson .. --default-library=static -Dprefix="${WORKSPACE}" - execute ninja - execute ninja install - mv ${WORKSPACE}/lib/x86_64-linux-gnu/pkgconfig/dav1d.pc ${WORKSPACE}/lib/pkgconfig/dav1d.pc - build_done "dav1d" -fi -CONFIGURE_OPTIONS+=("--enable-libdav1d") - -if build "rav1e"; then - download "https://github.com/xiph/rav1e/archive/master.tar.gz" "rav1e.tar.gz" - execute cargo cinstall --release --prefix="${WORKSPACE}" --library-type staticlib - build_done "rav1e" -fi -CONFIGURE_OPTIONS+=("--enable-librav1e") - ## ## audio library ## From faa30b957889846822e7398106d0e696a2f61d71 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 31 May 2021 16:21:17 +0200 Subject: [PATCH 028/111] FFmpeg Update to version 4.4 --- build-ffmpeg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 796efe12..21751f26 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -247,6 +247,10 @@ fi echo "Using $MJOBS make jobs simultaneously." +if $NONFREE_AND_GPL; then +echo "With GPL and non-free codecs" +fi + if [ -n "$LDEXEFLAGS" ]; then echo "Start the build in full static mode." fi @@ -695,7 +699,7 @@ fi ## build "ffmpeg" -download "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/dc91b913b6260e85e1304c74ff7bb3c22a8c9fb1.tar.gz" +download "https://www.ffmpeg.org/releases/ffmpeg-4.4.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ From 945fbb426d6f63a0c7828eb0f8461b696e3676ee Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 10 Jun 2021 15:18:20 +0200 Subject: [PATCH 029/111] Fixes #94 --- README.md | 5 +++++ web-install-gpl-and-non-free.sh | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 web-install-gpl-and-non-free.sh diff --git a/README.md b/README.md index 430f9884..92d72475 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ other than Debian 10 and macOS 11.x, because I don't have the resources or time Open your command line and run (curl needs to be installed): ```bash + +# Without GPL and non-free codes, see https://ffmpeg.org/legal.html +$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") + +# With GPL and non-free codes, see https://ffmpeg.org/legal.html $ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") ``` diff --git a/web-install-gpl-and-non-free.sh b/web-install-gpl-and-non-free.sh new file mode 100755 index 00000000..1a75788e --- /dev/null +++ b/web-install-gpl-and-non-free.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Helper script to download and run the build-ffmpeg script. + +make_dir () { + if [ ! -d $1 ]; then + if ! mkdir $1; then + printf "\n Failed to create dir %s" "$1"; + exit 1 + fi + fi +} + +command_exists() { + if ! [[ -x $(command -v "$1") ]]; then + return 1 + fi + + return 0 +} + +TARGET='ffmpeg-build' + +if ! command_exists "curl"; then + echo "curl not installed."; + exit 1 +fi + +echo "ffmpeg-build-script-downloader v0.1" +echo "=========================================" +echo "" + +echo "First we create the ffmpeg build directory $TARGET" +make_dir $TARGET +cd $TARGET + +echo "Now we download and execute the build script" +echo "" + +bash <(curl -s https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/build-ffmpeg) --build --enable-gpl-and-non-free + From 3e64b45289a445d1b8a82910b6af1974006ce4ca Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 10 Jun 2021 15:19:17 +0200 Subject: [PATCH 030/111] Readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92d72475..df2ecbf2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Open your command line and run (curl needs to be installed): $ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") # With GPL and non-free codes, see https://ffmpeg.org/legal.html -$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1") +$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install-gpl-and-non-free.sh?v1") ``` This command downloads the build script and automatically starts the build process. From 7b158503e3abbbb52be3f6610832882f7ace07f1 Mon Sep 17 00:00:00 2001 From: Rokib Hasan Sagar <10854164+rokibhasansagar@users.noreply.github.com> Date: Sat, 24 Jul 2021 12:35:31 +0600 Subject: [PATCH 031/111] build-ffmpeg: cmake minor version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 21751f26..62dfe8f8 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -402,7 +402,7 @@ if $NONFREE_AND_GPL; then fi if build "cmake"; then - download "https://cmake.org/files/LatestRelease/cmake-3.20.2.tar.gz" + download "https://cmake.org/files/LatestRelease/cmake-3.21.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF execute make -j $MJOBS execute make install From fb3776bb2ffc21e1aeffa714741aa44246b9ea06 Mon Sep 17 00:00:00 2001 From: Rokib Hasan Sagar <10854164+rokibhasansagar@users.noreply.github.com> Date: Sat, 24 Jul 2021 13:18:57 +0600 Subject: [PATCH 032/111] Use git release head snapshot for ffmpeg source - Tagged snapshot from ffmpeg.org is not updated once published. But the release head branches in git source is occasionally updated with most-stable changes from master branch. --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 62dfe8f8..483a716f 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -699,7 +699,7 @@ fi ## build "ffmpeg" -download "https://www.ffmpeg.org/releases/ffmpeg-4.4.tar.gz" +download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/4.4.tar.gz" "FFmpeg-release-4.4.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ From e0542c4f2e86f7a0e09971d7f328249c77709a00 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Sat, 24 Jul 2021 22:47:45 +0200 Subject: [PATCH 033/111] build fixes mac --- build-ffmpeg | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 483a716f..257320ea 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.26 +VERSION=1.27 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -611,12 +611,29 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libfdk-aac") fi +if build "libtiff"; then + download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + build_done "libtiff" +fi + +if build "libpng"; then + download "https://deac-riga.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + build_done "libpng" +fi + ## ## image library ## if build "libwebp"; then - download "https://github.com/webmproject/libwebp/archive/v1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" + download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static make_dir build cd build || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ From 41f8dc8ce4627b0c4d8dbefd481ba5757a53cd8e Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 26 Jul 2021 14:19:30 +0200 Subject: [PATCH 034/111] libpng fixes --- build-ffmpeg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-ffmpeg b/build-ffmpeg index 257320ea..25c8354d 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -382,6 +382,7 @@ if build "zlib"; then execute ./configure --static --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install + LDFLAGS+=" -L/zlib/lib" build_done "zlib" fi @@ -621,6 +622,8 @@ fi if build "libpng"; then download "https://deac-riga.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz" + export LDFLAGS="${LDFLAGS}" + export CPPFLAGS="${CFLAGS}" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install From c9907324a3f9d034acb0ef113af8995e92b0d9f6 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Tue, 27 Jul 2021 15:22:23 +0200 Subject: [PATCH 035/111] Version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 25c8354d..934461c5 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.27 +VERSION=1.28 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From 8338593767f127cf51be585c40c73f142d8ccdb6 Mon Sep 17 00:00:00 2001 From: markus-perl <1220081+markus-perl@users.noreply.github.com> Date: Fri, 27 Aug 2021 10:02:45 +0200 Subject: [PATCH 036/111] Update build-ffmpeg --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 934461c5..4230a61d 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -388,7 +388,7 @@ fi if $NONFREE_AND_GPL; then if build "openssl"; then - download "https://www.openssl.org/source/openssl-1.1.1k.tar.gz" + download "https://www.openssl.org/source/openssl-1.1.1l.tar.gz" if $MACOS_M1; then sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf execute ./configure --prefix="${WORKSPACE}" no-shared no-asm darwin64-arm64-cc From e729a3cf97eba666271bbf9a3b6b067e6793dec4 Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Mon, 6 Sep 2021 18:54:39 -0500 Subject: [PATCH 037/111] Adding support for 10-bit and HDR10+ metadata in x265 Adding version check for dependencies Adding support for zip file extraction Adding libzimg support Adding librav1e support Adding AMF hardware encoder support Mentioning libzip-dev is needed on ubuntu for webp to not error --- README.md | 21 ++++- build-ffmpeg | 225 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 162 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index df2ecbf2..814e411b 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,9 @@ $ ./build-ffmpeg --build * `x264`: H.264 Video Codec (MPEG-4 AVC) * `x265`: H.265 Video Codec (HEVC) -* `libsvtav1`, SVT-AV1 Encoder and Decoder +* `libsvtav1`: SVT-AV1 Encoder and Decoder * `aom`: AV1 Video Codec (Experimental and very slow!) +* `librav1e`: rust based AV1 encoder (only available if [`cargo` is installed](https://doc.rust-lang.org/cargo/getting-started/installation.html)) * `fdk_aac`: Fraunhofer FDK AAC Codec * `xvidcore`: MPEG-4 video coding standard * `VP8/VP9/webm`: VP8 / VP9 Video Codec for the WebM video file format @@ -62,7 +63,6 @@ $ ./build-ffmpeg --build * `theora`: Free lossy video compression format * `opus`: Lossy audio coding format * `srt`: Secure Reliable Transport -* `srt`: Secure Reliable Transport * `webp`: Image format both lossless and lossy ### HardwareAccel @@ -93,6 +93,11 @@ $ ./build-ffmpeg --build * MPEG2 video `mpeg2_vaapi` * VP8 `vp8_vaapi` * VP9 `vp9_vaapi` +* `AMF`: [AMD's Advanced Media Framework](https://github.com/GPUOpen-LibrariesAndSDKs/AMF). These encoders will only + be available if `amdgpu` drivers are detected in use on the system with `lspci -v`. + * Encoders + * H264 `h264_amf` + ### Apple M1 (Apple Silicon) Support @@ -120,7 +125,7 @@ with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure eve ```bash # Debian and Ubuntu -$ sudo apt install build-essential curl +$ sudo apt install build-essential curl libzip-dev # Fedora $ sudo dnf install @development-tools curl @@ -235,6 +240,15 @@ $ sudo apt install libva-dev vainfo $ sudo dnf install libva-devel libva-intel-driver libva-utils ``` +## AMF installation + +To use the AMF encoder, you will need to be using the AMD GPU Pro drivers with OpenCL support. +Download the drivers from https://www.amd.com/en/support and install the appropriate opencl versions. + +```bash +./amdgpu-pro-install -y --opencl=rocr,legacy +``` + ## Usage ```bash @@ -244,6 +258,7 @@ Options: --version Display version information -b, --build Starts the build process --enable-gpl-and-non-free Enable non-free codecs - https://ffmpeg.org/legal.html + --latest Build latest version of dependencies if newer available -c, --cleanup Remove all working dirs --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux** Note: Because of the NSS (Name Service Switch), glibc does not recommend static links. diff --git a/build-ffmpeg b/build-ffmpeg index 4230a61d..2c365feb 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -15,6 +15,7 @@ EXTRALIBS="-ldl -lpthread -lm -lz" MACOS_M1=false CONFIGURE_OPTIONS=() NONFREE_AND_GPL=false +LATEST=false # Check for Apple Silicon if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then @@ -90,15 +91,22 @@ download() { make_dir "$DOWNLOAD_PATH/$TARGETDIR" - if [ -n "$3" ]; then - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE" - exit 1 + if [[ $DOWNLOAD_FILE == *.zip ]]; then + if ! unzip "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -d "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE"; + exit 1; fi else - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE" - exit 1 + if [ -n "$3" ]; then + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 + fi + else + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 + fi fi fi @@ -126,12 +134,20 @@ execute() { build() { echo "" - echo "building $1" + echo "building $1 - version $2" echo "=======================" if [ -f "$PACKAGES/$1.done" ]; then - echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it." - return 1 + if grep -Fx "$2" "$PACKAGES/$1.done"; then + echo "$1 version $2 already built. Remove $PACKAGES/$1.done lockfile to rebuild it." + return 1 + elif $LATEST; then + echo "$1 is outdated and will be rebuilt with latest version $2" + return 0 + else + echo "$1 is outdated, but will not be rebuilt. Pass in --latest to rebuild it or remove $PACKAGES/$1.done lockfile." + return 1 + fi fi return 0 @@ -154,7 +170,7 @@ library_exists() { } build_done() { - touch "$PACKAGES/$1.done" + echo "$2" > "$PACKAGES/$1.done" } verify_binary_type() { @@ -189,6 +205,7 @@ usage() { echo " -b, --build Starts the build process" echo " --enable-gpl-and-non-free Enable GPL and non-free codecs - https://ffmpeg.org/legal.html" echo " -c, --cleanup Remove all working dirs" + echo " --latest Build latest version of dependencies if newer available" echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." echo "" @@ -228,6 +245,9 @@ while (($# > 0)); do fi LDEXEFLAGS="-static" fi + if [[ "$1" == "--latest" ]]; then + LATEST=true + fi shift ;; *) @@ -278,6 +298,14 @@ if ! command_exists "curl"; then exit 1 fi +if ! command_exists "libtoolize"; then + echo "libtool not installed. libzimg (z.lib) will not be available." +fi + +if ! command_exists "cargo"; then + echo "cargo not installed. rav1e will not be available." +fi + if ! command_exists "python"; then echo "Python command not found. Lv2 filter will not be available." fi @@ -286,108 +314,108 @@ fi ## build tools ## -if build "pkg-config"; then +if build "pkg-config" "0.29.2"; then download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib execute make -j $MJOBS execute make install - build_done "pkg-config" + build_done "pkg-config" "0.29.2" fi if command_exists "python"; then - if build "lv2"; then + if build "lv2" "1.18.2"; then download "https://lv2plug.in/spec/lv2-1.18.2.tar.bz2" "lv2-1.18.2.tar.bz2" execute ./waf configure --prefix="${WORKSPACE}" --lv2-user execute ./waf execute ./waf install - build_done "lv2" + build_done "lv2" "1.18.2" fi - if build "waflib"; then + if build "waflib" "b600c92"; then download "https://gitlab.com/drobilla/autowaf/-/archive/b600c928b221a001faeab7bd92786d0b25714bc8/autowaf-b600c928b221a001faeab7bd92786d0b25714bc8.tar.gz" "autowaf.tar.gz" - build_done "waflib" + build_done "waflib" "b600c92" fi - if build "serd"; then + if build "serd" "0.30.10"; then download "https://gitlab.com/drobilla/serd/-/archive/v0.30.10/serd-v0.30.10.tar.gz" "serd-v0.30.10.tar.gz" execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.10/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix execute ./waf execute ./waf install - build_done "serd" + build_done "serd" "0.30.10" fi - if build "pcre"; then + if build "pcre" "8.44"; then download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "pcre" + build_done "pcre" "8.44" fi - if build "sord"; then + if build "sord" "0.16.8"; then download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.8/waflib/" execute ./waf configure --prefix="${WORKSPACE}" CFLAGS="${CFLAGS}" --static --no-shared --no-utils execute ./waf CFLAGS="${CFLAGS}" execute ./waf install - build_done "sord" + build_done "sord" "0.16.8" fi - if build "sratom"; then + if build "sratom" "0.6.8"; then download "https://gitlab.com/lv2/sratom/-/archive/v0.6.8/sratom-v0.6.8.tar.gz" "sratom-v0.6.8.tar.gz" execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.8/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared execute ./waf execute ./waf install - build_done "sratom" + build_done "sratom" "0.6.8" fi - if build "lilv"; then + if build "lilv" "0.24.12"; then download "https://gitlab.com/lv2/lilv/-/archive/v0.24.12/lilv-v0.24.12.tar.gz" "lilv-v0.24.12.tar.gz" execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.12/waflib/" execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils execute ./waf execute ./waf install CFLAGS+=" -I$WORKSPACE/include/lilv-0" - build_done "lilv" + build_done "lilv" "0.24.12" fi CONFIGURE_OPTIONS+=("--enable-lv2") fi -if build "yasm"; then +if build "yasm" "1.3.0"; then download "https://github.com/yasm/yasm/releases/download/v1.3.0/yasm-1.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install - build_done "yasm" + build_done "yasm" "1.3.0" fi -if build "nasm"; then +if build "nasm" "2.15.05"; then download "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "nasm" + build_done "nasm" "2.15.05" fi -if build "zlib"; then +if build "zlib" "1.2.11"; then download "https://www.zlib.net/zlib-1.2.11.tar.gz" execute ./configure --static --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install LDFLAGS+=" -L/zlib/lib" - build_done "zlib" + build_done "zlib" "1.2.11" fi if $NONFREE_AND_GPL; then - if build "openssl"; then + if build "openssl" "1.1.1l"; then download "https://www.openssl.org/source/openssl-1.1.1l.tar.gz" if $MACOS_M1; then sed -n 's/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf @@ -397,21 +425,21 @@ if $NONFREE_AND_GPL; then fi execute make -j $MJOBS execute make install_sw - build_done "openssl" + build_done "openssl" "1.1.1l" fi CONFIGURE_OPTIONS+=("--enable-openssl") fi -if build "cmake"; then +if build "cmake" "3.21.0"; then download "https://cmake.org/files/LatestRelease/cmake-3.21.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF execute make -j $MJOBS execute make install - build_done "cmake" + build_done "cmake" "3.21.0" fi if ! $MACOS_M1; then - if build "svtav1"; then + if build "svtav1" $(date -I); then download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/master/SVT-AV1-master.tar.gz" cd Build/linux || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release @@ -419,14 +447,24 @@ if ! $MACOS_M1; then execute make install execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" - build_done "svtav1" + build_done "svtav1" $(date -I) fi CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi +if command_exists "cargo"; then + if build "rav1e" "0.5.0-beta"; then + cargo install cargo-c + download "https://github.com/xiph/rav1e/archive/refs/tags/v0.5.0-beta.tar.gz" + execute cargo cinstall --prefix="${WORKSPACE}" --library-type=staticlib --crt-static --release + build_done "rav1e" "0.5.0-beta" + fi + CONFIGURE_OPTIONS+=("--enable-librav1e") +fi + if $NONFREE_AND_GPL; then - if build "x264"; then + if build "x264" "b684ebe"; then download "https://code.videolan.org/videolan/x264/-/archive/b684ebe04a6f80f8207a57940a1fa00e25274f81/x264-b684ebe04a6f80f8207a57940a1fa00e25274f81.tar.gz" "x264-b684eb.tar.gz" cd "${PACKAGES}"/x264-b684eb || exit @@ -440,17 +478,17 @@ if $NONFREE_AND_GPL; then execute make install execute make install-lib-static - build_done "x264" + build_done "x264" "b684ebe" fi CONFIGURE_OPTIONS+=("--enable-libx264") fi if $NONFREE_AND_GPL; then - if build "x265"; then + if build "x265" "3.5"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" cd build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source execute make -j $MJOBS execute make install @@ -458,12 +496,12 @@ if $NONFREE_AND_GPL; then sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux fi - build_done "x265" + build_done "x265" "3.5" fi CONFIGURE_OPTIONS+=("--enable-libx265") fi -if build "libvpx"; then +if build "libvpx" "1.10.0"; then download "https://github.com/webmproject/libvpx/archive/refs/tags/v1.10.0.tar.gz" "libvpx-1.10.0.tar.gz" if [[ "$OSTYPE" == "darwin"* ]]; then @@ -476,12 +514,12 @@ if build "libvpx"; then execute make -j $MJOBS execute make install - build_done "libvpx" + build_done "libvpx" "1.10.0" fi CONFIGURE_OPTIONS+=("--enable-libvpx") if $NONFREE_AND_GPL; then - if build "xvidcore"; then + if build "xvidcore" "1.3.7"; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static @@ -496,13 +534,13 @@ if $NONFREE_AND_GPL; then execute rm "${WORKSPACE}"/lib/libxvidcore.so* fi - build_done "xvidcore" + build_done "xvidcore" "1.3.7" fi CONFIGURE_OPTIONS+=("--enable-libxvid") fi if $NONFREE_AND_GPL; then - if build "vid_stab"; then + if build "vid_stab" "1.1.0"; then download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" if $MACOS_M1; then @@ -514,12 +552,12 @@ if $NONFREE_AND_GPL; then execute make execute make install - build_done "vid_stab" + build_done "vid_stab" "1.1.0" fi CONFIGURE_OPTIONS+=("--enable-libvidstab") fi -if build "av1"; then +if build "av1" "c0f1414"; then download "https://aomedia.googlesource.com/aom/+archive/c0f14141bd71414b004dccd66d48b27570299fa3.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit @@ -531,7 +569,7 @@ if build "av1"; then execute make -j $MJOBS execute make install - build_done "av1" + build_done "av1" "c0f1414" fi CONFIGURE_OPTIONS+=("--enable-libaom") @@ -539,55 +577,55 @@ CONFIGURE_OPTIONS+=("--enable-libaom") ## audio library ## -if build "opencore"; then +if build "opencore" "0.1.5"; then download "https://deac-riga.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "opencore" + build_done "opencore" "0.1.5" fi CONFIGURE_OPTIONS+=("--enable-libopencore_amrnb" "--enable-libopencore_amrwb") -if build "lame"; then +if build "lame" "3.100"; then download "https://netcologne.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "lame" + build_done "lame" "3.100" fi CONFIGURE_OPTIONS+=("--enable-libmp3lame") -if build "opus"; then +if build "opus" "1.3.1"; then download "https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "opus" + build_done "opus" "1.3.1" fi CONFIGURE_OPTIONS+=("--enable-libopus") -if build "libogg"; then +if build "libogg" "1.3.3"; then download "https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "libogg" + build_done "libogg" "1.3.3" fi -if build "libvorbis"; then +if build "libvorbis" "1.3.6"; then download "https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz" execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest execute make -j $MJOBS execute make install - build_done "libvorbis" + build_done "libvorbis" "1.3.6" fi CONFIGURE_OPTIONS+=("--enable-libvorbis") -if build "libtheora"; then +if build "libtheora" "1.1.1"; then download "https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-1.1.1.tar.gz" sed "s/-fforce-addr//g" configure >configure.patched chmod +x configure.patched @@ -596,45 +634,45 @@ if build "libtheora"; then execute make -j $MJOBS execute make install - build_done "libtheora" + build_done "libtheora" "1.1.1" fi CONFIGURE_OPTIONS+=("--enable-libtheora") if $NONFREE_AND_GPL; then - if build "fdk_aac"; then + if build "fdk_aac" "2.0.2"; then download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.2.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.2.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --enable-pic execute make -j $MJOBS execute make install - build_done "fdk_aac" + build_done "fdk_aac" "2.0.2" fi CONFIGURE_OPTIONS+=("--enable-libfdk-aac") fi -if build "libtiff"; then +if build "libtiff" "4.3.0"; then download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "libtiff" + build_done "libtiff" "4.3.0" fi -if build "libpng"; then +if build "libpng" "1.6.37"; then download "https://deac-riga.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz" export LDFLAGS="${LDFLAGS}" export CPPFLAGS="${CFLAGS}" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "libpng" + build_done "libpng" "1.6.37" fi ## ## image library ## -if build "libwebp"; then +if build "libwebp" "1.2.0"; then download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static make_dir build @@ -643,25 +681,37 @@ if build "libwebp"; then execute make -j $MJOBS execute make install - build_done "libwebp" + build_done "libwebp" "1.2.0" fi CONFIGURE_OPTIONS+=("--enable-libwebp") +if command_exists "libtoolize"; then + if build "zimg" "3.0.3"; then + download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.3.tar.gz" + execute ./autogen.sh + execute ./configure --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "zimg" "3.0.3" + fi + CONFIGURE_OPTIONS+=("--enable-libzimg") +fi + ## ## other library ## -if build "libsdl"; then +if build "libsdl" "2.0.14"; then download "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "libsdl" + build_done "libsdl" "2.0.14" fi if $NONFREE_AND_GPL; then - if build "srt"; then + if build "srt" "1.4.3"; then download "https://github.com/Haivision/srt/archive/v1.4.3.tar.gz" "srt-1.4.3.tar.gz" export OPENSSL_ROOT_DIR="${WORKSPACE}" export OPENSSL_LIB_DIR="${WORKSPACE}"/lib @@ -673,7 +723,7 @@ if $NONFREE_AND_GPL; then sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}"/lib/pkgconfig/srt.pc # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux fi - build_done "srt" + build_done "srt" "1.4.3" fi CONFIGURE_OPTIONS+=("--enable-libsrt") fi @@ -684,11 +734,11 @@ fi if [[ "$OSTYPE" == "linux-gnu" ]]; then if command_exists "nvcc"; then - if build "nv-codec"; then + if build "nv-codec" "11.0.10.1"; then download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.1/nv-codec-headers-11.0.10.1.tar.gz" execute make PREFIX="${WORKSPACE}" execute make install PREFIX="${WORKSPACE}" - build_done "nv-codec" + build_done "nv-codec" "11.0.10.1" fi CFLAGS+=" -I/usr/local/cuda/include" LDFLAGS+=" -L/usr/local/cuda/lib64" @@ -706,19 +756,32 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then if [ -z "$LDEXEFLAGS" ]; then # If the libva development SDK is installed, enable vaapi. if library_exists "libva"; then - if build "vaapi"; then - build_done "vaapi" + if build "vaapi" "1"; then + build_done "vaapi" "1" fi CONFIGURE_OPTIONS+=("--enable-vaapi") fi fi + + # Only build AMF support if the amdgpu drivers are in use on the system + lspci -v | grep "Kernel driver in use: amdgpu" > /dev/null + if [ $? -eq 0 ]; then + if build "amf" "1.4.21.0"; then + download "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/download/v.1.4.21/AMF_SDK_1.4.21.0-2021-07-20.zip" + execute rm -rf ${WORKSPACE}/include/AMF + execute mkdir -p ${WORKSPACE}/include/AMF + execute cp -r ${PACKAGES}/AMF_SDK_1.4.21.0-2021-07-20/AMF_SDK_1.4.21.0/amf/public/include/* ${WORKSPACE}/include/AMF/ + build_done "amf" "1.4.21.0" + fi + CONFIGURE_OPTIONS+=("--enable-amf") + fi fi ## ## FFmpeg ## -build "ffmpeg" +build "ffmpeg" "4.4" download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/4.4.tar.gz" "FFmpeg-release-4.4.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ From b52a1c8b510a1bbd5853da573b481f386b20786d Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Mon, 6 Sep 2021 19:02:58 -0500 Subject: [PATCH 038/111] Adding libtool requirement for Ubuntu in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 814e411b..46b1f564 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure eve ```bash # Debian and Ubuntu -$ sudo apt install build-essential curl libzip-dev +$ sudo apt install build-essential curl libzip-dev libtool # Fedora $ sudo dnf install @development-tools curl From 643aaca866f76adf4ab6fd2aaf64d671b4b1d096 Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Thu, 9 Sep 2021 17:17:59 -0500 Subject: [PATCH 039/111] CPPFLAGS being set by libping could break libwebp build Moving flags being set outside if blocks build libtoolize for zimg remove old svt-av1 master tar files as it is not versioned Fix errant sudo command in AUTOINSTALL adding autoconf requirement for automake add m4 and automake build tools for libtool and zimg change AMF to use tar.gz and remove extra zip handling --- README.md | 2 +- build-ffmpeg | 105 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 64 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 46b1f564..99c10395 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure eve ```bash # Debian and Ubuntu -$ sudo apt install build-essential curl libzip-dev libtool +$ sudo apt install build-essential curl # Fedora $ sudo dnf install @development-tools curl diff --git a/build-ffmpeg b/build-ffmpeg index 2c365feb..6ab67471 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -91,22 +91,15 @@ download() { make_dir "$DOWNLOAD_PATH/$TARGETDIR" - if [[ $DOWNLOAD_FILE == *.zip ]]; then - if ! unzip "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -d "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE"; - exit 1; + if [ -n "$3" ]; then + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 fi else - if [ -n "$3" ]; then - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE" - exit 1 - fi - else - if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then - echo "Failed to extract $DOWNLOAD_FILE" - exit 1 - fi + if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" --strip-components 1 2>/dev/null >/dev/null; then + echo "Failed to extract $DOWNLOAD_FILE" + exit 1 fi fi @@ -298,10 +291,6 @@ if ! command_exists "curl"; then exit 1 fi -if ! command_exists "libtoolize"; then - echo "libtool not installed. libzimg (z.lib) will not be available." -fi - if ! command_exists "cargo"; then echo "cargo not installed. rav1e will not be available." fi @@ -382,9 +371,9 @@ if command_exists "python"; then execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils execute ./waf execute ./waf install - CFLAGS+=" -I$WORKSPACE/include/lilv-0" build_done "lilv" "0.24.12" fi + CFLAGS+=" -I$WORKSPACE/include/lilv-0" CONFIGURE_OPTIONS+=("--enable-lv2") fi @@ -410,9 +399,41 @@ if build "zlib" "1.2.11"; then execute ./configure --static --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install - LDFLAGS+=" -L/zlib/lib" build_done "zlib" "1.2.11" fi +LDFLAGS+=" -L/zlib/lib" + +if build "m4" "1.4.19"; then + download "https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz" + execute ./configure --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "m4" "1.4.19" +fi + +if build "autoconf" "2.71"; then + download "https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.gz" + execute ./configure --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "autoconf" "2.71" +fi + +if build "automake" "1.16.4"; then + download "https://ftp.gnu.org/gnu/automake/automake-1.16.4.tar.gz" + execute ./configure --prefix="${WORKSPACE}" + execute make -j $MJOBS + execute make install + build_done "automake" "1.16.4" +fi + +if build "libtool" "2.4.6"; then + download "https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared + execute make -j $MJOBS + execute make install + build_done "libtool" "2.4.6" +fi if $NONFREE_AND_GPL; then if build "openssl" "1.1.1l"; then @@ -440,6 +461,7 @@ fi if ! $MACOS_M1; then if build "svtav1" $(date -I); then + execute rm -f "${PACKAGES}/SVT-AV1-master.tar.gz" download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/master/SVT-AV1-master.tar.gz" cd Build/linux || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release @@ -667,6 +689,8 @@ if build "libpng" "1.6.37"; then execute make install build_done "libpng" "1.6.37" fi +# libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS +CPPFLAGS= ## ## image library @@ -685,17 +709,18 @@ if build "libwebp" "1.2.0"; then fi CONFIGURE_OPTIONS+=("--enable-libwebp") -if command_exists "libtoolize"; then - if build "zimg" "3.0.3"; then - download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.3.tar.gz" - execute ./autogen.sh - execute ./configure --prefix="${WORKSPACE}" - execute make -j $MJOBS - execute make install - build_done "zimg" "3.0.3" - fi - CONFIGURE_OPTIONS+=("--enable-libzimg") +if build "zimg" "3.0.3"; then + download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.3.tar.gz" "zimg-3.0.3.tar.gz" "zimg" + cd zimg-release-3.0.3 || exit + execute ${WORKSPACE}/bin/libtoolize -i -f -q + execute ./autogen.sh --prefix="${WORKSPACE}" + execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared + execute make -j $MJOBS + execute make install + build_done "zimg" "3.0.3" fi +CONFIGURE_OPTIONS+=("--enable-libzimg") + ## ## other library @@ -763,18 +788,14 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then fi fi - # Only build AMF support if the amdgpu drivers are in use on the system - lspci -v | grep "Kernel driver in use: amdgpu" > /dev/null - if [ $? -eq 0 ]; then - if build "amf" "1.4.21.0"; then - download "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/download/v.1.4.21/AMF_SDK_1.4.21.0-2021-07-20.zip" - execute rm -rf ${WORKSPACE}/include/AMF - execute mkdir -p ${WORKSPACE}/include/AMF - execute cp -r ${PACKAGES}/AMF_SDK_1.4.21.0-2021-07-20/AMF_SDK_1.4.21.0/amf/public/include/* ${WORKSPACE}/include/AMF/ - build_done "amf" "1.4.21.0" - fi - CONFIGURE_OPTIONS+=("--enable-amf") + if build "amf" "1.4.21.0"; then + download "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/archive/refs/tags/v.1.4.21.tar.gz" "AMF-1.4.21.tar.gz" "AMF-1.4.21" + execute rm -rf ${WORKSPACE}/include/AMF + execute mkdir -p ${WORKSPACE}/include/AMF + execute cp -r ${PACKAGES}/AMF-1.4.21/AMF-v.1.4.21/amf/public/include/* ${WORKSPACE}/include/AMF/ + build_done "amf" "1.4.21.0" fi + CONFIGURE_OPTIONS+=("--enable-amf") fi ## @@ -827,7 +848,7 @@ if [[ "$AUTOINSTALL" == "yes" ]]; then else cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg" cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe" - sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" echo "Done. FFmpeg is now installed to your system." fi elif [[ ! "$SKIPINSTALL" == "yes" ]]; then From 10ae6e917bf0b61df04222461789c9ad8cf42b12 Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Fri, 10 Sep 2021 13:33:29 -0500 Subject: [PATCH 040/111] Adding 8, 10, and 12 bit pixel formats for x265 --- build-ffmpeg | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 6ab67471..83926021 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -34,6 +34,7 @@ elif [[ -f /proc/cpuinfo ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then MJOBS=$(sysctl -n machdep.cpu.thread_count) CONFIGURE_OPTIONS=("--enable-videotoolbox") + MACOS_LIBTOOL="$(which libtool)" # gnu libtool is installed in this script and need to avoid name conflict else MJOBS=4 fi @@ -460,7 +461,7 @@ if build "cmake" "3.21.0"; then fi if ! $MACOS_M1; then - if build "svtav1" $(date -I); then + if build "svtav1" "$(date)"; then execute rm -f "${PACKAGES}/SVT-AV1-master.tar.gz" download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/master/SVT-AV1-master.tar.gz" cd Build/linux || exit @@ -469,7 +470,7 @@ if ! $MACOS_M1; then execute make install execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" - build_done "svtav1" $(date -I) + build_done "svtav1" "$(date)"; fi CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi @@ -507,11 +508,37 @@ fi if $NONFREE_AND_GPL; then if build "x265" "3.5"; then - download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" + download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt cd build/linux || exit - - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source + rm -rf 8bit 10bit 12bit + mkdir 8bit 10bit 12bit + cd 12bit || exit + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON + execute make -j $MJOBS + cd ../10bit || exit + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF execute make -j $MJOBS + cd ../8bit || exit + ln -sf ../10bit/libx265.a libx265_main10.a + ln -sf ../12bit/libx265.a libx265_main12.a + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON + execute make -j $MJOBS + + mv libx265.a libx265_main.a + + if [[ "$OSTYPE" == "darwin"* ]]; then + execute "${MACOS_LIBTOOL}" -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null + else + execute ar -M < Date: Mon, 13 Sep 2021 08:53:21 +0200 Subject: [PATCH 041/111] Version interference with build script variable --- build-ffmpeg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 4230a61d..a4a003b8 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.28 +SCRIPT_VERSION=1.28 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -194,7 +194,7 @@ usage() { echo "" } -echo "ffmpeg-build-script v$VERSION" +echo "ffmpeg-build-script v$SCRIPT_VERSION" echo "=========================" echo "" @@ -205,7 +205,7 @@ while (($# > 0)); do exit 0 ;; --version) - echo "$VERSION" + echo "$SCRIPT_VERSION" exit 0 ;; -*) From 7116d6c44dc1fc94cbd9a36161036f0679c73865 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:35:41 +0200 Subject: [PATCH 042/111] version display fix --- build-ffmpeg | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 879172e9..f7708c2f 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,8 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -SCRIPT_VERSION=1.28 +SCRIPT_VERSION=1.30 +FFMPEG_VERSION=4.4 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -132,7 +133,7 @@ build() { echo "=======================" if [ -f "$PACKAGES/$1.done" ]; then - if grep -Fx "$2" "$PACKAGES/$1.done"; then + if grep -Fx "$2" "$PACKAGES/$1.done" >/dev/null; then echo "$1 version $2 already built. Remove $PACKAGES/$1.done lockfile to rebuild it." return 1 elif $LATEST; then @@ -829,8 +830,8 @@ fi ## FFmpeg ## -build "ffmpeg" "4.4" -download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/4.4.tar.gz" "FFmpeg-release-4.4.tar.gz" +build "ffmpeg" "$FFMPEG_VERSION" +download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VERSION.tar.gz" "FFmpeg-release-$FFMPEG_VERSION.tar.gz" # shellcheck disable=SC2086 ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ @@ -846,7 +847,8 @@ download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/4.4.tar.gz --extra-libs="${EXTRALIBS}" \ --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ --pkg-config-flags="--static" \ - --prefix="${WORKSPACE}" + --prefix="${WORKSPACE}" \ + --extra-version="${FFMPEG_VERSION}" execute make -j $MJOBS execute make install From e24c341b97d93c1e6653cfbb4ed774633828062c Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 13 Sep 2021 10:38:38 +0200 Subject: [PATCH 043/111] version display fix --- build-ffmpeg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index f7708c2f..5fba285d 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -830,6 +830,11 @@ fi ## FFmpeg ## +EXTRA_VERSION="" +if [[ "$OSTYPE" == "darwin"* ]]; then + EXTRA_VERSION="${FFMPEG_VERSION}" +fi + build "ffmpeg" "$FFMPEG_VERSION" download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VERSION.tar.gz" "FFmpeg-release-$FFMPEG_VERSION.tar.gz" # shellcheck disable=SC2086 @@ -848,7 +853,7 @@ download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VE --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ --pkg-config-flags="--static" \ --prefix="${WORKSPACE}" \ - --extra-version="${FFMPEG_VERSION}" + --extra-version="${EXTRA_VERSION}" execute make -j $MJOBS execute make install From bc89c8320d3a74b98654b7364663a7f02baf28b0 Mon Sep 17 00:00:00 2001 From: Rokib Hasan Sagar <10854164+rokibhasansagar@users.noreply.github.com> Date: Mon, 13 Sep 2021 21:13:04 +0600 Subject: [PATCH 044/111] Codec: Add libdav1d --- build-ffmpeg | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 5fba285d..96ed871e 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -294,11 +294,14 @@ if ! command_exists "curl"; then fi if ! command_exists "cargo"; then - echo "cargo not installed. rav1e will not be available." + echo "cargo not installed. rav1e encoder will not be available." fi if ! command_exists "python"; then - echo "Python command not found. Lv2 filter will not be available." + echo "python command not found. Lv2 filter will not be available." +fi +if ! command_exists "python3"; then + echo "python3 command not found. dav1d decoder will not be available." fi ## @@ -378,6 +381,7 @@ if command_exists "python"; then CFLAGS+=" -I$WORKSPACE/include/lilv-0" CONFIGURE_OPTIONS+=("--enable-lv2") + fi if build "yasm" "1.3.0"; then @@ -461,6 +465,20 @@ if build "cmake" "3.21.0"; then build_done "cmake" "3.21.0" fi +if command_exists "python3"; then + if build "dav1d" "0.9.2"; then + # dav1d needs meson and ninja with nasm to be built + execute python3 -m pip install meson ninja --quiet --no-cache-dir --disable-pip-version-check + download "https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz" + make_dir build + execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib + execute ninja -C build + execute ninja -C build install + build_done "dav1d" "0.9.2" + fi + CONFIGURE_OPTIONS+=("--enable-libdav1d") +fi + if ! $MACOS_M1; then if build "svtav1" "$(date)"; then execute rm -f "${PACKAGES}/SVT-AV1-master.tar.gz" @@ -478,7 +496,7 @@ fi if command_exists "cargo"; then if build "rav1e" "0.5.0-beta"; then - cargo install cargo-c + execute cargo install cargo-c download "https://github.com/xiph/rav1e/archive/refs/tags/v0.5.0-beta.tar.gz" execute cargo cinstall --prefix="${WORKSPACE}" --library-type=staticlib --crt-static --release build_done "rav1e" "0.5.0-beta" From a49eec465de183544aaf731e8d1329be3f024743 Mon Sep 17 00:00:00 2001 From: markus-perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 16 Sep 2021 14:48:46 +0200 Subject: [PATCH 045/111] Update build-ffmpeg --- build-ffmpeg | 1 - 1 file changed, 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 96ed871e..4d927bd4 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -888,7 +888,6 @@ echo "Building done. The following binaries can be found here:" echo "- ffmpeg: $WORKSPACE/bin/ffmpeg" echo "- ffprobe: $WORKSPACE/bin/ffprobe" echo "- ffplay: $WORKSPACE/bin/ffplay" - echo "" if [[ "$AUTOINSTALL" == "yes" ]]; then From fed2a788a8935748424ecbb2793c52c696171f33 Mon Sep 17 00:00:00 2001 From: Rokib Hasan Sagar <10854164+rokibhasansagar@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:48:26 +0600 Subject: [PATCH 046/111] Update Dockerfiles with more improvements - CUDA Images updated to 11.4.2-devel - Docker as-well-as build script upgraded to use `python3` - `ninja-build` and `meson` packages are pre-installed either via system package manager or via `pip3` in favor of building `dav1d` codec - `cmake` updated to v3.21.2 - `svtav1` updated to last-known commit `1a3e32b` which successfully passed pipeline - `x264` updated to commit `5db6aa6` - `aom` updated to v3.1.2, commit `ae2be80` - Occasional sourceforge.net download fail due to downtime of mirror location is tried to bypass - `nv-codec-headers` updated to v11.1.5.0 - Script slightly re-arranged to differentiate codec types Signed-off-by: rokibhasansagar <10854164+rokibhasansagar@users.noreply.github.com> --- .github/workflows/build.yml | 12 +- Dockerfile | 5 +- README.md | 1 + build-ffmpeg | 233 ++++++++++++++++++------------------ cuda-centos.dockerfile | 20 ++-- cuda-ubuntu.dockerfile | 14 +-- full-static.dockerfile | 4 +- 7 files changed, 148 insertions(+), 141 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09332739..179da221 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,12 +89,12 @@ jobs: - name: pull base image id: cuda_ubuntu_pull run: | - docker pull nvidia/cuda:11.1-devel-ubuntu20.04 + docker pull nvidia/cuda:11.4.2-devel-ubuntu20.04 docker pull ubuntu:20.04 - name: run if cuda_ubuntu_pull failed if: failure() && steps.cuda_ubuntu_pull.outcome == 'failure' run: | - docker pull nvidia/cuda:11.1-devel-ubuntu20.04 + docker pull nvidia/cuda:11.4.2-devel-ubuntu20.04 docker pull ubuntu:20.04 - name: build ffmpeg run: | @@ -113,12 +113,12 @@ jobs: - name: pull base image id: cuda_centos_pull run: | - docker pull nvidia/cuda:11.1-devel-centos8 + docker pull nvidia/cuda:11.4.2-devel-centos8 docker pull centos:8 - name: run if cuda_centos_pull failed if: failure() && steps.cuda_centos_pull.outcome == 'failure' run: | - docker pull nvidia/cuda:11.1-devel-centos8 + docker pull nvidia/cuda:11.4.2-devel-centos8 docker pull centos:8 - name: build ffmpeg run: | @@ -137,11 +137,11 @@ jobs: - name: pull base image id: cuda_ubuntu_pull run: | - docker pull nvidia/cuda:11.1-devel-ubuntu20.04 + docker pull nvidia/cuda:11.4.2-devel-ubuntu20.04 - name: run if cuda_ubuntu_pull failed if: failure() && steps.cuda_ubuntu_pull.outcome == 'failure' run: | - docker pull nvidia/cuda:11.1-devel-ubuntu20.04 + docker pull nvidia/cuda:11.4.2-devel-ubuntu20.04 - name: build ffmpeg run: | docker build -t ffmpeg:cuda-static -f full-static.dockerfile . diff --git a/Dockerfile b/Dockerfile index 428a828b..96c67b6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM ubuntu:20.04 AS build ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev python \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev \ + python3 python-is-python3 ninja-build meson \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates @@ -32,4 +33,4 @@ RUN ldd /usr/bin/ffprobe RUN ldd /usr/bin/ffplay CMD ["--help"] -ENTRYPOINT ["/usr/bin/ffmpeg"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/ffmpeg"] diff --git a/README.md b/README.md index 99c10395..5871b4d2 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ $ ./build-ffmpeg --build * `libsvtav1`: SVT-AV1 Encoder and Decoder * `aom`: AV1 Video Codec (Experimental and very slow!) * `librav1e`: rust based AV1 encoder (only available if [`cargo` is installed](https://doc.rust-lang.org/cargo/getting-started/installation.html)) +* `libdav1d`: Fastest AV1 decoder developed by the VideoLAN and FFmpeg communities and sponsored by the AOMedia (only available if `meson` and `ninja` are installed) * `fdk_aac`: Fraunhofer FDK AAC Codec * `xvidcore`: MPEG-4 video coding standard * `VP8/VP9/webm`: VP8 / VP9 Video Codec for the WebM video file format diff --git a/build-ffmpeg b/build-ffmpeg index 4d927bd4..13e1daa1 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -297,11 +297,8 @@ if ! command_exists "cargo"; then echo "cargo not installed. rav1e encoder will not be available." fi -if ! command_exists "python"; then - echo "python command not found. Lv2 filter will not be available." -fi if ! command_exists "python3"; then - echo "python3 command not found. dav1d decoder will not be available." + echo "python3 command not found. Lv2 filter and dav1d decoder will not be available." fi ## @@ -316,74 +313,6 @@ if build "pkg-config" "0.29.2"; then build_done "pkg-config" "0.29.2" fi -if command_exists "python"; then - - if build "lv2" "1.18.2"; then - download "https://lv2plug.in/spec/lv2-1.18.2.tar.bz2" "lv2-1.18.2.tar.bz2" - execute ./waf configure --prefix="${WORKSPACE}" --lv2-user - execute ./waf - execute ./waf install - - build_done "lv2" "1.18.2" - fi - - if build "waflib" "b600c92"; then - download "https://gitlab.com/drobilla/autowaf/-/archive/b600c928b221a001faeab7bd92786d0b25714bc8/autowaf-b600c928b221a001faeab7bd92786d0b25714bc8.tar.gz" "autowaf.tar.gz" - build_done "waflib" "b600c92" - fi - - if build "serd" "0.30.10"; then - download "https://gitlab.com/drobilla/serd/-/archive/v0.30.10/serd-v0.30.10.tar.gz" "serd-v0.30.10.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.10/waflib/" - execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix - execute ./waf - execute ./waf install - build_done "serd" "0.30.10" - fi - - if build "pcre" "8.44"; then - download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install - - build_done "pcre" "8.44" - fi - - if build "sord" "0.16.8"; then - download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.8/waflib/" - execute ./waf configure --prefix="${WORKSPACE}" CFLAGS="${CFLAGS}" --static --no-shared --no-utils - execute ./waf CFLAGS="${CFLAGS}" - execute ./waf install - - build_done "sord" "0.16.8" - fi - - if build "sratom" "0.6.8"; then - download "https://gitlab.com/lv2/sratom/-/archive/v0.6.8/sratom-v0.6.8.tar.gz" "sratom-v0.6.8.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.8/waflib/" - execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared - execute ./waf - execute ./waf install - - build_done "sratom" "0.6.8" - fi - - if build "lilv" "0.24.12"; then - download "https://gitlab.com/lv2/lilv/-/archive/v0.24.12/lilv-v0.24.12.tar.gz" "lilv-v0.24.12.tar.gz" - execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.12/waflib/" - execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils - execute ./waf - execute ./waf install - build_done "lilv" "0.24.12" - fi - CFLAGS+=" -I$WORKSPACE/include/lilv-0" - - CONFIGURE_OPTIONS+=("--enable-lv2") - -fi - if build "yasm" "1.3.0"; then download "https://github.com/yasm/yasm/releases/download/v1.3.0/yasm-1.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" @@ -457,18 +386,30 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-openssl") fi -if build "cmake" "3.21.0"; then - download "https://cmake.org/files/LatestRelease/cmake-3.21.0.tar.gz" +if build "cmake" "3.21.2"; then + download "https://cmake.org/files/LatestRelease/cmake-3.21.2.tar.gz" execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF execute make -j $MJOBS execute make install - build_done "cmake" "3.21.0" + build_done "cmake" "3.21.2" fi +## +## video library +## + if command_exists "python3"; then + # dav1d needs meson and ninja along with nasm to be built + if command_exists "pip3"; then + # meson and ninja can be installed via pip3 + execute pip3 install pip setuptools --quiet --upgrade --no-cache-dir --disable-pip-version-check + for r in meson ninja; do + if ! command_exists ${r}; then + execute pip3 install ${r} --quiet --upgrade --no-cache-dir --disable-pip-version-check + fi + done + fi if build "dav1d" "0.9.2"; then - # dav1d needs meson and ninja with nasm to be built - execute python3 -m pip install meson ninja --quiet --no-cache-dir --disable-pip-version-check download "https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz" make_dir build execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib @@ -480,16 +421,17 @@ if command_exists "python3"; then fi if ! $MACOS_M1; then - if build "svtav1" "$(date)"; then - execute rm -f "${PACKAGES}/SVT-AV1-master.tar.gz" - download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/master/SVT-AV1-master.tar.gz" - cd Build/linux || exit + if build "svtav1" "1a3e32b"; then + execute rm -f "${PACKAGES}/SVT-AV1-master.tar.gz" "${PACKAGES}/svtav1-1a3e32b.tar.gz" + # Last known working commit which passed CI Tests from HEAD branch + download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4/SVT-AV1-1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4.tar.gz" "svtav1-1a3e32b.tar.gz" + cd "${PACKAGES}"/svtav1-1a3e32b/Build/linux || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release execute make -j $MJOBS execute make install execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/" - build_done "svtav1" "$(date)"; + build_done "svtav1" "1a3e32b"; fi CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi @@ -506,9 +448,9 @@ fi if $NONFREE_AND_GPL; then - if build "x264" "b684ebe"; then - download "https://code.videolan.org/videolan/x264/-/archive/b684ebe04a6f80f8207a57940a1fa00e25274f81/x264-b684ebe04a6f80f8207a57940a1fa00e25274f81.tar.gz" "x264-b684eb.tar.gz" - cd "${PACKAGES}"/x264-b684eb || exit + if build "x264" "5db6aa6"; then + download "https://code.videolan.org/videolan/x264/-/archive/5db6aa6cab1b146e07b60cc1736a01f21da01154/x264-5db6aa6cab1b146e07b60cc1736a01f21da01154.tar.gz" "x264-5db6aa6.tar.gz" + cd "${PACKAGES}"/x264-5db6aa6 || exit if [[ "$OSTYPE" == "linux-gnu" ]]; then execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" @@ -520,7 +462,7 @@ if $NONFREE_AND_GPL; then execute make install execute make install-lib-static - build_done "x264" "b684ebe" + build_done "x264" "5db6aa6" fi CONFIGURE_OPTIONS+=("--enable-libx264") fi @@ -529,8 +471,8 @@ if $NONFREE_AND_GPL; then if build "x265" "3.5"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt cd build/linux || exit - rm -rf 8bit 10bit 12bit - mkdir 8bit 10bit 12bit + rm -rf 8bit 10bit 12bit 2>/dev/null + mkdir -p 8bit 10bit 12bit cd 12bit || exit execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON execute make -j $MJOBS @@ -625,8 +567,9 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libvidstab") fi -if build "av1" "c0f1414"; then - download "https://aomedia.googlesource.com/aom/+archive/c0f14141bd71414b004dccd66d48b27570299fa3.tar.gz" "av1.tar.gz" "av1" +if build "av1" "ae2be80"; then + # libaom ae2be80 == v3.1.2 + download "https://aomedia.googlesource.com/aom/+archive/ae2be8030200925895fa6e98bd274ffdb595cbf6.tar.gz" "av1.tar.gz" "av1" make_dir "$PACKAGES"/aom_build cd "$PACKAGES"/aom_build || exit if $MACOS_M1; then @@ -637,16 +580,90 @@ if build "av1" "c0f1414"; then execute make -j $MJOBS execute make install - build_done "av1" "c0f1414" + build_done "av1" "ae2be80" fi CONFIGURE_OPTIONS+=("--enable-libaom") +if build "zimg" "3.0.3"; then + download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.3.tar.gz" "zimg-3.0.3.tar.gz" "zimg" + cd zimg-release-3.0.3 || exit + execute "${WORKSPACE}/bin/libtoolize" -i -f -q + execute ./autogen.sh --prefix="${WORKSPACE}" + execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared + execute make -j $MJOBS + execute make install + build_done "zimg" "3.0.3" +fi +CONFIGURE_OPTIONS+=("--enable-libzimg") + ## ## audio library ## +if command_exists "python3"; then + + if build "lv2" "1.18.2"; then + download "https://lv2plug.in/spec/lv2-1.18.2.tar.bz2" "lv2-1.18.2.tar.bz2" + execute ./waf configure --prefix="${WORKSPACE}" --lv2-user + execute ./waf + execute ./waf install + + build_done "lv2" "1.18.2" + fi + if build "waflib" "b600c92"; then + download "https://gitlab.com/drobilla/autowaf/-/archive/b600c928b221a001faeab7bd92786d0b25714bc8/autowaf-b600c928b221a001faeab7bd92786d0b25714bc8.tar.gz" "autowaf.tar.gz" + build_done "waflib" "b600c92" + fi + if build "serd" "0.30.10"; then + download "https://gitlab.com/drobilla/serd/-/archive/v0.30.10/serd-v0.30.10.tar.gz" "serd-v0.30.10.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/serd-v0.30.10/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-posix + execute ./waf + execute ./waf install + build_done "serd" "0.30.10" + fi + if build "pcre" "8.44"; then + download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + + build_done "pcre" "8.44" + fi + if build "sord" "0.16.8"; then + download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.8/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" CFLAGS="${CFLAGS}" --static --no-shared --no-utils + execute ./waf CFLAGS="${CFLAGS}" + execute ./waf install + + build_done "sord" "0.16.8" + fi + if build "sratom" "0.6.8"; then + download "https://gitlab.com/lv2/sratom/-/archive/v0.6.8/sratom-v0.6.8.tar.gz" "sratom-v0.6.8.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sratom-v0.6.8/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared + execute ./waf + execute ./waf install + + build_done "sratom" "0.6.8" + fi + if build "lilv" "0.24.12"; then + download "https://gitlab.com/lv2/lilv/-/archive/v0.24.12/lilv-v0.24.12.tar.gz" "lilv-v0.24.12.tar.gz" + execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/lilv-v0.24.12/waflib/" + execute ./waf configure --prefix="${WORKSPACE}" --static --no-shared --no-utils + execute ./waf + execute ./waf install + build_done "lilv" "0.24.12" + fi + CFLAGS+=" -I$WORKSPACE/include/lilv-0" + + CONFIGURE_OPTIONS+=("--enable-lv2") + +fi + if build "opencore" "0.1.5"; then - download "https://deac-riga.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz" + download "https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.5.tar.gz/download?use_mirror=gigenet" "opencore-amr-0.1.5.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install @@ -656,7 +673,7 @@ fi CONFIGURE_OPTIONS+=("--enable-libopencore_amrnb" "--enable-libopencore_amrwb") if build "lame" "3.100"; then - download "https://netcologne.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" + download "https://sourceforge.net/projects/lame/files/lame/3.100/lame-3.100.tar.gz/download?use_mirror=gigenet" "lame-3.100.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install @@ -718,6 +735,10 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libfdk-aac") fi +## +## image library +## + if build "libtiff" "4.3.0"; then download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static @@ -725,9 +746,8 @@ if build "libtiff" "4.3.0"; then execute make install build_done "libtiff" "4.3.0" fi - if build "libpng" "1.6.37"; then - download "https://deac-riga.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz" + download "https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.gz/download?use_mirror=gigenet" "libpng-1.6.37.tar.gz" export LDFLAGS="${LDFLAGS}" export CPPFLAGS="${CFLAGS}" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static @@ -738,10 +758,6 @@ fi # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS CPPFLAGS= -## -## image library -## - if build "libwebp" "1.2.0"; then download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static @@ -755,19 +771,6 @@ if build "libwebp" "1.2.0"; then fi CONFIGURE_OPTIONS+=("--enable-libwebp") -if build "zimg" "3.0.3"; then - download "https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.3.tar.gz" "zimg-3.0.3.tar.gz" "zimg" - cd zimg-release-3.0.3 || exit - execute "${WORKSPACE}/bin/libtoolize" -i -f -q - execute ./autogen.sh --prefix="${WORKSPACE}" - execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared - execute make -j $MJOBS - execute make install - build_done "zimg" "3.0.3" -fi -CONFIGURE_OPTIONS+=("--enable-libzimg") - - ## ## other library ## @@ -805,11 +808,11 @@ fi if [[ "$OSTYPE" == "linux-gnu" ]]; then if command_exists "nvcc"; then - if build "nv-codec" "11.0.10.1"; then - download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.1/nv-codec-headers-11.0.10.1.tar.gz" + if build "nv-codec" "11.1.5.0"; then + download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.1.5.0/nv-codec-headers-11.1.5.0.tar.gz" execute make PREFIX="${WORKSPACE}" execute make install PREFIX="${WORKSPACE}" - build_done "nv-codec" "11.0.10.1" + build_done "nv-codec" "11.1.5.0" fi CFLAGS+=" -I/usr/local/cuda/include" LDFLAGS+=" -L/usr/local/cuda/lib64" diff --git a/cuda-centos.dockerfile b/cuda-centos.dockerfile index fa62218a..9fab5edb 100644 --- a/cuda-centos.dockerfile +++ b/cuda-centos.dockerfile @@ -1,14 +1,16 @@ ARG VER=8 -FROM nvidia/cuda:11.1-devel-centos${VER} AS build +FROM nvidia/cuda:11.4.2-devel-centos${VER} AS build ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN yum group install -y "Development Tools" \ - && yum install -y curl libva-devel python2 \ - && rm -rf /var/cache/yum/* \ - && yum clean all + && yum install -y curl libva-devel python3 \ + && yum install -y meson ninja-build --enablerepo=powertools \ + && rm -rf /var/cache/yum/* /var/cache/dnf/* \ + && yum clean all \ + && alternatives --set python /usr/bin/python3 WORKDIR /app COPY ./build-ffmpeg /app/build-ffmpeg @@ -27,10 +29,10 @@ RUN yum install -y libva \ && yum clean all # Copy libnpp -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppc.so.11 /lib64/libnppc.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppig.so.11 /lib64/libnppig.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppicc.so.11 /lib64/libnppicc.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppidei.so.11 /lib64/libnppidei.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppc.so.11 /lib64/libnppc.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppig.so.11 /lib64/libnppig.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppicc.so.11 /lib64/libnppicc.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppidei.so.11 /lib64/libnppidei.so.11 # Copy ffmpeg COPY --from=build /app/workspace/bin/ffmpeg /usr/bin/ffmpeg @@ -43,4 +45,4 @@ RUN ldd /usr/bin/ffprobe RUN ldd /usr/bin/ffplay CMD ["--help"] -ENTRYPOINT ["/usr/bin/ffmpeg"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/ffmpeg"] diff --git a/cuda-ubuntu.dockerfile b/cuda-ubuntu.dockerfile index a43a587e..b370fdd6 100644 --- a/cuda-ubuntu.dockerfile +++ b/cuda-ubuntu.dockerfile @@ -1,13 +1,13 @@ ARG VER=20.04 -FROM nvidia/cuda:11.1-devel-ubuntu${VER} AS build +FROM nvidia/cuda:11.4.2-devel-ubuntu${VER} AS build ENV DEBIAN_FRONTEND noninteractive ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev python \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates libva-dev python3 python-is-python3 ninja-build meson \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates @@ -29,10 +29,10 @@ RUN apt-get update \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* # Copy libnpp -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppc.so.11 /lib/x86_64-linux-gnu/libnppc.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppig.so.11 /lib/x86_64-linux-gnu/libnppig.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppicc.so.11 /lib/x86_64-linux-gnu/libnppicc.so.11 -COPY --from=build /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnppidei.so.11 /lib/x86_64-linux-gnu/libnppidei.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppc.so.11 /lib/x86_64-linux-gnu/libnppc.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppig.so.11 /lib/x86_64-linux-gnu/libnppig.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppicc.so.11 /lib/x86_64-linux-gnu/libnppicc.so.11 +COPY --from=build /usr/local/cuda-11.4/targets/x86_64-linux/lib/libnppidei.so.11 /lib/x86_64-linux-gnu/libnppidei.so.11 # Copy ffmpeg COPY --from=build /app/workspace/bin/ffmpeg /usr/bin/ffmpeg @@ -45,4 +45,4 @@ RUN ldd /usr/bin/ffprobe RUN ldd /usr/bin/ffplay CMD ["--help"] -ENTRYPOINT ["/usr/bin/ffmpeg"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/ffmpeg"] diff --git a/full-static.dockerfile b/full-static.dockerfile index 03eee7ee..7f334e3c 100644 --- a/full-static.dockerfile +++ b/full-static.dockerfile @@ -5,7 +5,7 @@ ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video RUN apt-get update \ - && apt-get -y --no-install-recommends install build-essential curl ca-certificates python \ + && apt-get -y --no-install-recommends install build-essential curl ca-certificates python3 python-is-python3 ninja-build meson \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ && update-ca-certificates @@ -30,4 +30,4 @@ COPY --from=build /app/workspace/bin/ffprobe /ffprobe COPY --from=build /app/workspace/bin/ffplay /ffplay CMD ["--help"] -ENTRYPOINT ["/ffmpeg"] \ No newline at end of file +ENTRYPOINT ["/ffmpeg"] From 29637edbb03214c7b07ba740ca49347ec75aecd8 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 20 Sep 2021 13:27:06 +0200 Subject: [PATCH 047/111] Version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 13e1daa1..fae5ddfa 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -SCRIPT_VERSION=1.30 +SCRIPT_VERSION=1.31 FFMPEG_VERSION=4.4 CWD=$(pwd) PACKAGES="$CWD/packages" From a5cab969d60231a634e2431775fed46e6b0b53b9 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:52:40 +0200 Subject: [PATCH 048/111] optimization flag '-fstrength-reduce' is not supported --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index fae5ddfa..cf20cb7f 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -533,7 +533,7 @@ if $NONFREE_AND_GPL; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS + execute make -j $MJOBS -Wno-ignored-optimization-argument execute make install if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then From ce01ac8bc9b43bf012e0151b5fb94ed072720403 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:11:56 +0200 Subject: [PATCH 049/111] Removed build flag --- build-ffmpeg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index cf20cb7f..af8875d0 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,8 +4,8 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -SCRIPT_VERSION=1.31 FFMPEG_VERSION=4.4 +SCRIPT_VERSION=1.31 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -533,7 +533,7 @@ if $NONFREE_AND_GPL; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS -Wno-ignored-optimization-argument + execute make -j $MJOBS execute make install if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then From 262520fe86838e8a32cec027ff27216152c574c2 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 2 Nov 2021 16:38:40 -0500 Subject: [PATCH 050/111] Workaround Issue 115 to compile dav1d on arm64 https://github.com/markus-perl/ffmpeg-build-script/issues/115 --- build-ffmpeg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build-ffmpeg b/build-ffmpeg index af8875d0..1b6ab16d 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -412,9 +412,20 @@ if command_exists "python3"; then if build "dav1d" "0.9.2"; then download "https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz" make_dir build + # [ Descript - cvanwink ] + # Set extra CFLAGS for arm64 + # https://github.com/markus-perl/ffmpeg-build-script/issues/115 + if $MACOS_M1; then + export CFLAGS="-arch arm64" + fi execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib execute ninja -C build execute ninja -C build install + # [ Descript - cvanwink ] + # Restore default CFLAGS from line 12 + if $MACOS_M1; then + CFLAGS="-I$WORKSPACE/include" + fi build_done "dav1d" "0.9.2" fi CONFIGURE_OPTIONS+=("--enable-libdav1d") From d9e77be1518520eaea619805c741f933c90aab41 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 2 Nov 2021 16:44:57 -0500 Subject: [PATCH 051/111] Disable libtiff on arm64 --- build-ffmpeg | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 1b6ab16d..6f3ea96f 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -750,12 +750,19 @@ fi ## image library ## -if build "libtiff" "4.3.0"; then - download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - execute make -j $MJOBS - execute make install - build_done "libtiff" "4.3.0" +# [ Descript - cvanwink ] +# Disable libtiff on arm64 as it doesn't compile +# ../version:1:1: error: expected unqualified-id +# 4.3.0 +# ^ +if ! $MACOS_M1; then + if build "libtiff" "4.3.0"; then + download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute make -j $MJOBS + execute make install + build_done "libtiff" "4.3.0" + fi fi if build "libpng" "1.6.37"; then download "https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.gz/download?use_mirror=gigenet" "libpng-1.6.37.tar.gz" From cce3de268d43ba63777ee775179c7d4cff549ab0 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 2 Nov 2021 20:45:46 -0500 Subject: [PATCH 052/111] Disable libtiff on x86_64 as it also doesn't compile with the same error --- build-ffmpeg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 6f3ea96f..4148cc72 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -751,11 +751,11 @@ fi ## # [ Descript - cvanwink ] -# Disable libtiff on arm64 as it doesn't compile +# Disable libtiff on arm64 and x86_64 as it doesn't compile # ../version:1:1: error: expected unqualified-id # 4.3.0 # ^ -if ! $MACOS_M1; then +if false; then if build "libtiff" "4.3.0"; then download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static From 00d6dfa5a7fc6dc159b6aac2790dc1db3c02a89c Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 2 Nov 2021 20:46:25 -0500 Subject: [PATCH 053/111] Disable libwebp as it doesn't compile on x86_64 --- build-ffmpeg | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 4148cc72..f752ec68 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -776,18 +776,25 @@ fi # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS CPPFLAGS= -if build "libwebp" "1.2.0"; then - download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - make_dir build - cd build || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ - execute make -j $MJOBS - execute make install +# [ Descript - cvanwink ] +# Disable libwebp on arm64 and x86_64 as it doesn't compile on x86_64 +# Undefined symbols for architecture x86_64: +# "_PrintGifError", referenced from: +# _GIFDisplayError in gifdec.c.o +if false; then + if build "libwebp" "1.2.0"; then + download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + make_dir build + cd build || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ + execute make -j $MJOBS + execute make install - build_done "libwebp" "1.2.0" + build_done "libwebp" "1.2.0" + fi + CONFIGURE_OPTIONS+=("--enable-libwebp") fi -CONFIGURE_OPTIONS+=("--enable-libwebp") ## ## other library From 7540cf479a832840416ef79de9acc2a7c40cccee Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 2 Nov 2021 20:50:09 -0500 Subject: [PATCH 054/111] Add DS_Store to gitignore Cherry Pick 8b606fa7e7f168571bd55d87a1f5f0ed16ee4b57 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4725dcff..e2053e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ workspace .idea linux .artifacts +.DS_Store From d2ab2832722786ce6e4b981092bf0466f45c751a Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 3 Nov 2021 08:02:57 -0500 Subject: [PATCH 055/111] Add optional --full-shared argument to build-ffmpeg to build shared libraries --- build-ffmpeg | 245 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 210 insertions(+), 35 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index f752ec68..217ab3aa 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -17,6 +17,7 @@ MACOS_M1=false CONFIGURE_OPTIONS=() NONFREE_AND_GPL=false LATEST=false +SHARED_LIBRARIES=false # Check for Apple Silicon if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then @@ -203,6 +204,7 @@ usage() { echo " --latest Build latest version of dependencies if newer available" echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." + echo " --full-shared Build all shared libraries. Cannot be used with --full-static" echo "" } @@ -243,6 +245,9 @@ while (($# > 0)); do if [[ "$1" == "--latest" ]]; then LATEST=true fi + if [[ "$1" == "--full-shared" ]]; then + SHARED_LIBRARIES=true + fi shift ;; *) @@ -260,6 +265,11 @@ if [ -z "$bflag" ]; then exit 0 fi +if [[ ($SHARED_LIBRARIES == true) && ($LDEXEFLAGS == true) ]]; then + usage + exit 1 +fi + echo "Using $MJOBS make jobs simultaneously." if $NONFREE_AND_GPL; then @@ -270,6 +280,10 @@ if [ -n "$LDEXEFLAGS" ]; then echo "Start the build in full static mode." fi +if $SHARED_LIBRARIES; then + echo "Building shared libraries." +fi + mkdir -p "$PACKAGES" mkdir -p "$WORKSPACE" @@ -323,7 +337,11 @@ fi if build "nasm" "2.15.05"; then download "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install build_done "nasm" "2.15.05" @@ -331,7 +349,11 @@ fi if build "zlib" "1.2.11"; then download "https://www.zlib.net/zlib-1.2.11.tar.gz" - execute ./configure --static --prefix="${WORKSPACE}" + if $SHARED_LIBRARIES; then + execute ./configure --shared --prefix="${WORKSPACE}" + else + execute ./configure --static --prefix="${WORKSPACE}" + fi execute make -j $MJOBS execute make install build_done "zlib" "1.2.11" @@ -364,7 +386,11 @@ fi if build "libtool" "2.4.6"; then download "https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --disable-static --enable-shared + else + execute ./configure --prefix="${WORKSPACE}" --enable-static --disable-shared + fi execute make -j $MJOBS execute make install build_done "libtool" "2.4.6" @@ -418,7 +444,11 @@ if command_exists "python3"; then if $MACOS_M1; then export CFLAGS="-arch arm64" fi - execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib + if $SHARED_LIBRARIES; then + execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=shared --libdir="${WORKSPACE}"/lib + else + execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib + fi execute ninja -C build execute ninja -C build install # [ Descript - cvanwink ] @@ -437,7 +467,11 @@ if ! $MACOS_M1; then # Last known working commit which passed CI Tests from HEAD branch download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4/SVT-AV1-1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4.tar.gz" "svtav1-1a3e32b.tar.gz" cd "${PACKAGES}"/svtav1-1a3e32b/Build/linux || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + if $SHARED_LIBRARIES; then + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=ON ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + else + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + fi execute make -j $MJOBS execute make install execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/" @@ -464,14 +498,26 @@ if $NONFREE_AND_GPL; then cd "${PACKAGES}"/x264-5db6aa6 || exit if [[ "$OSTYPE" == "linux-gnu" ]]; then - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --enable-pic CXXFLAGS="-fPIC" + else + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" + fi else - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --enable-pic + else + execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic + fi fi execute make -j $MJOBS execute make install - execute make install-lib-static + if $SHARED_LIBRARIES; then + execute make install-lib-shared + else + execute make install-lib-static + fi build_done "x264" "5db6aa6" fi @@ -485,15 +531,27 @@ if $NONFREE_AND_GPL; then rm -rf 8bit 10bit 12bit 2>/dev/null mkdir -p 8bit 10bit 12bit cd 12bit || exit - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON + if $SHARED_LIBRARIES; then + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON + else + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON + fi execute make -j $MJOBS cd ../10bit || exit - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF + if $SHARED_LIBRARIES; then + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF + else + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF + fi execute make -j $MJOBS cd ../8bit || exit ln -sf ../10bit/libx265.a libx265_main10.a ln -sf ../12bit/libx265.a libx265_main12.a - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON + if $SHARED_LIBRARIES; then + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON + else + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON + fi execute make -j $MJOBS mv libx265.a libx265_main.a @@ -531,7 +589,11 @@ if build "libvpx" "1.10.0"; then sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile fi - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm --enable-vp9-highbitdepth + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --enable-shared --disable-static --as=yasm --enable-vp9-highbitdepth + else + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm --enable-vp9-highbitdepth + fi execute make -j $MJOBS execute make install @@ -543,7 +605,11 @@ if $NONFREE_AND_GPL; then if build "xvidcore" "1.3.7"; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install @@ -569,7 +635,11 @@ if $NONFREE_AND_GPL; then patch -p1 include/libmp3lame.sym.patched + mv include/libmp3lame.sym.patched include/libmp3lame.sym + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install @@ -695,7 +807,11 @@ CONFIGURE_OPTIONS+=("--enable-libmp3lame") if build "opus" "1.3.1"; then download "https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install @@ -705,7 +821,11 @@ CONFIGURE_OPTIONS+=("--enable-libopus") if build "libogg" "1.3.3"; then download "https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install build_done "libogg" "1.3.3" @@ -713,7 +833,11 @@ fi if build "libvorbis" "1.3.6"; then download "https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --disable-static --enable-shared --disable-oggtest + else + execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest + fi execute make -j $MJOBS execute make install @@ -726,7 +850,11 @@ if build "libtheora" "1.1.1"; then sed "s/-fforce-addr//g" configure >configure.patched chmod +x configure.patched mv configure.patched configure - execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --disable-static --enable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec + else + execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec + fi execute make -j $MJOBS execute make install @@ -737,7 +865,11 @@ CONFIGURE_OPTIONS+=("--enable-libtheora") if $NONFREE_AND_GPL; then if build "fdk_aac" "2.0.2"; then download "https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.2.tar.gz/download?use_mirror=gigenet" "fdk-aac-2.0.2.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --enable-pic + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static --enable-pic + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --enable-pic + fi execute make -j $MJOBS execute make install @@ -758,7 +890,11 @@ fi if false; then if build "libtiff" "4.3.0"; then download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install build_done "libtiff" "4.3.0" @@ -768,7 +904,11 @@ if build "libpng" "1.6.37"; then download "https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.gz/download?use_mirror=gigenet" "libpng-1.6.37.tar.gz" export LDFLAGS="${LDFLAGS}" export CPPFLAGS="${CFLAGS}" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install build_done "libpng" "1.6.37" @@ -784,10 +924,18 @@ CPPFLAGS= if false; then if build "libwebp" "1.2.0"; then download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi make_dir build cd build || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ + if $SHARED_LIBRARIES; then + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=ON -DENABLE_STATIC=OFF ../ + else + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ + fi execute make -j $MJOBS execute make install @@ -802,7 +950,11 @@ fi if build "libsdl" "2.0.14"; then download "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi execute make -j $MJOBS execute make install @@ -815,7 +967,11 @@ if $NONFREE_AND_GPL; then export OPENSSL_ROOT_DIR="${WORKSPACE}" export OPENSSL_LIB_DIR="${WORKSPACE}"/lib export OPENSSL_INCLUDE_DIR="${WORKSPACE}"/include/ - execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON + if $SHARED_LIBRARIES; then + execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=ON -DENABLE_STATIC=OFF -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON + else + execute cmake . -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON + fi execute make install if [ -n "$LDEXEFLAGS" ]; then @@ -884,6 +1040,24 @@ fi build "ffmpeg" "$FFMPEG_VERSION" download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VERSION.tar.gz" "FFmpeg-release-$FFMPEG_VERSION.tar.gz" # shellcheck disable=SC2086 +if $SHARED_LIBRARIES; then +./configure "${CONFIGURE_OPTIONS[@]}" \ + --disable-debug \ + --disable-doc \ + --disable-static \ + --enable-pthreads \ + --enable-shared\ + --enable-small \ + --enable-version3 \ + --extra-cflags="${CFLAGS}" \ + --extra-ldexeflags="${LDEXEFLAGS}" \ + --extra-ldflags="${LDFLAGS}" \ + --extra-libs="${EXTRALIBS}" \ + --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ + --pkg-config-flags="--static" \ + --prefix="${WORKSPACE}" \ + --extra-version="${EXTRA_VERSION}" +else ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ --disable-doc \ @@ -900,6 +1074,7 @@ download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VE --pkg-config-flags="--static" \ --prefix="${WORKSPACE}" \ --extra-version="${EXTRA_VERSION}" +fi execute make -j $MJOBS execute make install From 44da9e84c7dca79b51b04d52f93c539090a72913 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Wed, 3 Nov 2021 21:00:09 -0500 Subject: [PATCH 056/111] Fix libtheora for arm64 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63610 https://trac.macports.org/ticket/61096 --- build-ffmpeg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build-ffmpeg b/build-ffmpeg index 217ab3aa..e80138ee 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -851,6 +851,10 @@ if build "libtheora" "1.1.1"; then chmod +x configure.patched mv configure.patched configure if $SHARED_LIBRARIES; then + if $MACOSX_M1; then + # fix Libtool bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63610 + export MACOSX_DEPLOYMENT_TARGET=10.11 + fi execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --disable-static --enable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec else execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --with-vorbis-libraries="${WORKSPACE}"/lib --with-vorbis-includes="${WORKSPACE}"/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm --disable-spec @@ -858,6 +862,13 @@ if build "libtheora" "1.1.1"; then execute make -j $MJOBS execute make install + if $SHARED_LIBRARIES; then + if $MACOSX_M1; then + # restore from Line 26 + export MACOSX_DEPLOYMENT_TARGET=11.0 + fi + fi + build_done "libtheora" "1.1.1" fi CONFIGURE_OPTIONS+=("--enable-libtheora") From bd55b01efb22129a855e3d784813898b0c773e6a Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Mon, 8 Nov 2021 23:12:30 -0600 Subject: [PATCH 057/111] Add initial python runner --- build-ffmpeg-descript.py | 292 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100755 build-ffmpeg-descript.py diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py new file mode 100755 index 00000000..9749d43d --- /dev/null +++ b/build-ffmpeg-descript.py @@ -0,0 +1,292 @@ +#!/usr/bin/env python3 + +''' +This file is created by Descript to document and augment +the FFmpeg building process, for use in Descript's environment. + +(1) Call build-ffmpeg with the build command +(2) Copy or generate dSYM symbol files to the output folder +''' + +import glob +import os +import pathlib +import platform +import re +import shutil +import subprocess + + +cwd = os.path.dirname(os.path.realpath(__file__)) +packages_dir = os.path.join(cwd, 'packages') +workspace_dir = os.path.join(cwd, 'workspace') +workspace_bin_dir = os.path.join(workspace_dir, 'bin') +workspace_lib_dir = os.path.join(workspace_dir, 'lib') + +skipped_libs = set() +copied_libs = set() +missing_libs = set() +names_without_version = set() + +# +# builds FFmpeg and logs output to build-ffmpeg.log.txt +# +def buildFFmpeg(cwd, workspace_dir): + # create a log file for the build-ffmpeg command for build archival purposes + build_ffmpeg_log_filename = os.path.join(workspace_dir, 'build-ffmpeg.log.txt') + os.makedirs(os.path.dirname(build_ffmpeg_log_filename), exist_ok=True) + build_ffmpeg_log_file = open('./workspace/build-ffmpeg.log.txt', 'w') + + # set environment variables + env = os.environ + env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc + env['VERBOSE'] = 'yes' + + # call main build script + build_ffmpeg_path = os.path.join(cwd, 'build-ffmpeg') + subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=build_ffmpeg_log_file) + + # close log file + build_ffmpeg_log_file.close() + +# +# Copies symbol file to the workspace destination +# skips symlinks to avoid duplication +# Copies entire dSYM packages for dylib files already within .dSYM packages +# +def copyOrGenerateSymbolFile(file, dest): + fileref = pathlib.Path(file) + if not fileref.is_symlink(): + symbolFileName = fileref.name + '.dSYM' + destPath = os.path.join(dest, symbolFileName) + + # See if there's a matching pre-existing symbol file. + # If so, copy it, replacing the destination + # example: + # ./packages/libtheora-1.1.1/lib/.libs/libtheoraenc.1.dylib.dSYM/Contents/Resources/DWARF/libtheoraenc.1.dylib + try: + + allParts = fileref.parts + symbolDirIndex = allParts.index(symbolFileName) # throws ValueError if not in allParts + symbolDirParts = allParts[:symbolDirIndex + 1] + symbolDir = os.path.join(*symbolDirParts) + if os.path.exists(destPath): + shutil.rmtree(destPath) + shutil.copytree(symbolDir, destPath) + + # Otherwise, generate a symbol file and place it at the destination + # example: + # ./packages/libtheora-1.1.1/lib/.libs/libtheora.dylib + except ValueError as e: + subprocess.call(['/usr/bin/dsymutil', str(fileref), '-o', destPath]) + +# +# Copies symbol files to the workspace destination +# skips symlinks to avoid duplication +# Copies entire dSYM packages for dylib files already within .dSYM packages +# +def copyOrGenerateSymbolFiles(source, dest): + for fileref in pathlib.Path(source + '/').glob('**/*.dylib'): + copyOrGenerateSymbolFile(str(fileref), dest) + +''' +const { resolve, basename } = require('path'); +const { mkdirSync, readlinkSync, readdirSync } = require('fs'); +const { execSync } = require('child_process'); + +function logAndExec(cmd) { + console.log(`EXEC ${cmd}`); + execSync(cmd); +} + +const baseIncludesDir = resolve(__dirname, 'workspace/include'); +const baseBinDir = resolve(__dirname, 'workspace/bin'); +const baseLibDir = resolve(__dirname, 'workspace/lib'); +const destDir = resolve(__dirname, 'workspace/mac'); + +try { + logAndExec(`rm -r -f ${destDir}`); +} catch (err) { + // +} +logAndExec(`mkdir -p ${destDir}`); + +const skippedLibs = new Set(); +const copiedLibs = new Set(); +const missingLibs = new Set(); +const namesWithoutVersion = new Set(); + +function copyDylibs(binaryName, base = baseBinDir) { + const origPath = resolve(base, binaryName); + const binaryPath = resolve(destDir, binaryName); + + logAndExec(`cp -a ${origPath} ${binaryPath}`); + + const lines = execSync(`otool -L ${binaryPath}`).toString('utf8').split('\n'); + const libsToRewrite = []; + for (const line of lines) { + const match = /[^\s:]+/.exec(line); + if (!match) { + continue; + } + const [path] = match; + if (path.startsWith('/usr/local')) { + missingLibs.add(path); + } else if (path.startsWith('/Users')) { + const filename = basename(path); + const newFilename = resolve(destDir, filename); + if (!copiedLibs.has(path)) { + copiedLibs.add(path); + copiedLibs.add(newFilename); + if (path !== newFilename) { + // copy sym-linked libraries as well + let nameWithoutVersion = filename.split('.')[0]; + // libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) + if (filename.includes('libSDL2')) { + nameWithoutVersion = 'libSDL2'; + } + namesWithoutVersion.add(nameWithoutVersion); + const nameWithoutVersionLib = `${nameWithoutVersion}.dylib`; + logAndExec(`cp -a ${resolve(baseLibDir, nameWithoutVersion)}*.dylib ${destDir}/.`); + + copyDylibs(filename, baseLibDir); + } + } + libsToRewrite.push({path, filename}); + } else { + skippedLibs.add(path); + } + } + + // find the non-sym-linked version of this library + let actualBinaryPath = binaryPath; + try { + const actualBinaryName = readlinkSync(binaryPath); + actualBinaryPath = resolve(destDir, actualBinaryName); + } catch (err) { + // + } + + if (libsToRewrite.length > 0) { + logAndExec(`install_name_tool -id @loader_path/${binaryName} ${libsToRewrite.map(({path, filename}) => `-change ${path} @loader_path/${filename}`).join(' ')} ${actualBinaryPath}`); + } +} + +copyDylibs('ffmpeg'); +copyDylibs('ffprobe'); + +console.log('Copying includes'); +logAndExec(`cp -r ${baseIncludesDir} ${destDir}/.`); + +for (const lib of Array.from(skippedLibs).sort()) { + console.log(`[NOTE] skipped ${lib}`); +} +for (const lib of Array.from(copiedLibs).sort()) { + if (!lib.startsWith(destDir)) { + console.log(`Copied ${lib}`); + } +} +for (const lib of Array.from(missingLibs).sort()) { + console.log(`[WARNING] missing ${lib}`); +} +''' + + + + +# +# +# +def copyLibraryAndDependencies(src_file, dest): + + dest_file = os.path.join(dest, os.path.basename(src_file)) + + # copy file + if os.path.exists(dest_file): + os.remove(dest_file) + shutil.copy2(src_file, dest_file) + + # copy symbol file + src_symbol_package = src_file + '.dSYM' + if os.path.exists(src_symbol_package): + dest_symbol_package = os.path.join(dest, os.path.basename(src_symbol_package)) + if os.path.exists(dest_symbol_package): + shutil.rmtree(dest_symbol_package) + shutil.copytree(src_symbol_package, dest_symbol_package) + + # recursively copy dependencies + otool_proc = subprocess.Popen(['/usr/bin/otool', '-L', src_file], stdout=subprocess.PIPE) + libs_to_rewrite = [] + for line in otool_proc.stdout: + ln = line.decode('utf-8').strip() + match = re.match('[^\s:]+', ln) + if not match: + continue + match_path = match[0] #ln[match.start(0):match.end(0)] + if match_path.startswith('/usr/local'): + missing_libs.add(match_path) + elif match_path.startswith(cwd): + filename = os.path.basename(match_path) + new_filename = os.path.realpath(os.path.join(dest, filename)) + if not match_path in copied_libs: + copied_libs.add(match_path) + copied_libs.add(new_filename) + if match_path != new_filename: + # copy sym-linked libraries as well + name_without_version = filename.split('.')[0] + # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) + if 'libSDL2' in filename: + name_without_version = 'libSDL2' + names_without_version.add(name_without_version) + + dependency_file = os.path.join(workspace_lib_dir, name_without_version) + + for file in glob.glob(r'' + dependency_file + '*.dylib'): + shutil.copy2(os.path.realpath(file), os.path.join(dest, os.path.basename(file))) + dependency_symbol_file = file + '.dSYM' + dest_dependency_symbol_file = os.path.join(dest, os.path.basename(dependency_symbol_file)) + if os.path.exists(dependency_symbol_file) and not os.path.exists(dest_dependency_symbol_file): + shutil.copytree(dependency_symbol_file, dest_dependency_symbol_file) + + if (os.path.exists(dependency_file + '.dylib')): + # RECURSION + copyLibraryAndDependencies(dependency_file + '.dylib', dest) + + libs_to_rewrite.append({'path': match_path, 'filename': filename}) + else: + skipped_libs.add(match_path) + + # find the non-sym-linked version of this library + actual_binary_path = os.path.realpath(dest_file) + + if len(libs_to_rewrite) > 0: + for lib in libs_to_rewrite: + print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['path'], '@loader_path/' + os.path.basename(lib['filename']), actual_binary_path])) + install_name_tool_proc = subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['path'], '@loader_path/' + os.path.basename(lib['filename']), actual_binary_path]) + +# +# +# +def main(): + output_dir = os.path.join(cwd, 'mac', platform.machine()) + if os.path.exists(output_dir): + shutil.rmtree(output_dir) + os.makedirs(output_dir) + + #buildFFmpeg(cwd, workspace_dir) + + # Generate dSYM files for each built library + #copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) + + # Generate dSYM files for each executable + executables = ['ffmpeg', 'ffprobe'] + for executable in executables: + executable_path = os.path.join(workspace_bin_dir, executable) + copyOrGenerateSymbolFile(executable_path, workspace_bin_dir) + copyLibraryAndDependencies(executable_path, output_dir) + +# +# entry +# +if __name__ == '__main__': + main() From 83e50db235a2ea88700a2d5ec162d229561d6970 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 08:03:47 -0600 Subject: [PATCH 058/111] Script cleanup --- build-ffmpeg-descript.py | 100 +++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 9749d43d..4bb5f3ae 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -31,7 +31,7 @@ # # builds FFmpeg and logs output to build-ffmpeg.log.txt # -def buildFFmpeg(cwd, workspace_dir): +def buildFFmpeg(script_dir, workspace_dir): # create a log file for the build-ffmpeg command for build archival purposes build_ffmpeg_log_filename = os.path.join(workspace_dir, 'build-ffmpeg.log.txt') os.makedirs(os.path.dirname(build_ffmpeg_log_filename), exist_ok=True) @@ -43,7 +43,7 @@ def buildFFmpeg(cwd, workspace_dir): env['VERBOSE'] = 'yes' # call main build script - build_ffmpeg_path = os.path.join(cwd, 'build-ffmpeg') + build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=build_ffmpeg_log_file) # close log file @@ -191,84 +191,90 @@ def copyOrGenerateSymbolFiles(source, dest): } ''' - - - # # # -def copyLibraryAndDependencies(src_file, dest): +def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): + dest_file = os.path.join(dest_folder, os.path.basename(src_file)) - dest_file = os.path.join(dest, os.path.basename(src_file)) - # copy file - if os.path.exists(dest_file): + if overwrite and os.path.exists(dest_file): os.remove(dest_file) shutil.copy2(src_file, dest_file) # copy symbol file src_symbol_package = src_file + '.dSYM' if os.path.exists(src_symbol_package): - dest_symbol_package = os.path.join(dest, os.path.basename(src_symbol_package)) - if os.path.exists(dest_symbol_package): - shutil.rmtree(dest_symbol_package) - shutil.copytree(src_symbol_package, dest_symbol_package) + dest_symbol_package = os.path.join(dest_folder, os.path.basename(src_symbol_package)) + if overwrite and os.path.exists(dest_symbol_package): + shutil.rmtree(dest_symbol_package) + if not os.path.exists(dest_symbol_package): + shutil.copytree(src_symbol_package, dest_symbol_package) + + +# +# Recursive function to copy a library and its (non-system) dependencies +# also fixes loader paths for each library +# +def copyLibraryAndDependencies(src_file, dest_folder): + + dest_file = os.path.join(dest_folder, os.path.basename(src_file)) + + # copy file + copyLibraryAndSymbolPackage(src_file, dest_folder, True) # recursively copy dependencies otool_proc = subprocess.Popen(['/usr/bin/otool', '-L', src_file], stdout=subprocess.PIPE) - libs_to_rewrite = [] + loader_paths_to_rewrite = [] for line in otool_proc.stdout: ln = line.decode('utf-8').strip() match = re.match('[^\s:]+', ln) if not match: continue - match_path = match[0] #ln[match.start(0):match.end(0)] - if match_path.startswith('/usr/local'): - missing_libs.add(match_path) - elif match_path.startswith(cwd): - filename = os.path.basename(match_path) - new_filename = os.path.realpath(os.path.join(dest, filename)) - if not match_path in copied_libs: - copied_libs.add(match_path) - copied_libs.add(new_filename) - if match_path != new_filename: + src_dependency_file = match[0] + if src_dependency_file.startswith('/usr/local'): + missing_libs.add(src_dependency_file) + elif src_dependency_file.startswith(workspace_dir): + dependency_name = os.path.basename(src_dependency_file) + dest_dependency_path = os.path.join(dest_folder, dependency_name) + if not src_dependency_file in copied_libs: + copied_libs.add(src_dependency_file) + copied_libs.add(dest_dependency_path) + if src_dependency_file != dest_dependency_path: # copy sym-linked libraries as well - name_without_version = filename.split('.')[0] + dependency_name_without_version = dependency_name.split('.')[0] # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) - if 'libSDL2' in filename: - name_without_version = 'libSDL2' - names_without_version.add(name_without_version) + if 'libSDL2' in dependency_name: + dependency_name_without_version = 'libSDL2' + names_without_version.add(dependency_name_without_version) - dependency_file = os.path.join(workspace_lib_dir, name_without_version) - - for file in glob.glob(r'' + dependency_file + '*.dylib'): - shutil.copy2(os.path.realpath(file), os.path.join(dest, os.path.basename(file))) - dependency_symbol_file = file + '.dSYM' - dest_dependency_symbol_file = os.path.join(dest, os.path.basename(dependency_symbol_file)) - if os.path.exists(dependency_symbol_file) and not os.path.exists(dest_dependency_symbol_file): - shutil.copytree(dependency_symbol_file, dest_dependency_symbol_file) - - if (os.path.exists(dependency_file + '.dylib')): - # RECURSION - copyLibraryAndDependencies(dependency_file + '.dylib', dest) + unversioned_dependency_base_name = os.path.join(workspace_lib_dir, dependency_name_without_version) + + # Copy each version variant file + for variant_file in glob.glob(unversioned_dependency_base_name + r'*.dylib'): + copyLibraryAndSymbolPackage(variant_file, dest_folder, False) + + # RECURSIVELY copy dependencies + if (os.path.exists(unversioned_dependency_base_name + '.dylib')): + copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder) - libs_to_rewrite.append({'path': match_path, 'filename': filename}) + loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) else: - skipped_libs.add(match_path) + skipped_libs.add(src_dependency_file) # find the non-sym-linked version of this library actual_binary_path = os.path.realpath(dest_file) - if len(libs_to_rewrite) > 0: - for lib in libs_to_rewrite: - print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['path'], '@loader_path/' + os.path.basename(lib['filename']), actual_binary_path])) - install_name_tool_proc = subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['path'], '@loader_path/' + os.path.basename(lib['filename']), actual_binary_path]) + if len(loader_paths_to_rewrite) > 0: + for lib in loader_paths_to_rewrite: + print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['old_path'], '@loader_path/' + os.path.basename(lib['new_path']), actual_binary_path])) + install_name_tool_proc = subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['old_path'], '@loader_path/' + os.path.basename(lib['new_path']), actual_binary_path]) # # # def main(): - output_dir = os.path.join(cwd, 'mac', platform.machine()) + output_dir = os.path.join(workspace_dir, 'mac', platform.machine()) if os.path.exists(output_dir): shutil.rmtree(output_dir) os.makedirs(output_dir) From 1a438ab6eaa715265a8a1ed0eb717f735dec931a Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 11:24:23 -0600 Subject: [PATCH 059/111] Fix loader path issues --- build-ffmpeg-descript.py | 54 +++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 4bb5f3ae..d66c9c85 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -26,7 +26,6 @@ skipped_libs = set() copied_libs = set() missing_libs = set() -names_without_version = set() # # builds FFmpeg and logs output to build-ffmpeg.log.txt @@ -200,7 +199,7 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): # copy file if overwrite and os.path.exists(dest_file): os.remove(dest_file) - shutil.copy2(src_file, dest_file) + shutil.copy2(src_file, dest_file, follow_symlinks=False) # copy symbol file src_symbol_package = src_file + '.dSYM' @@ -211,17 +210,32 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): if not os.path.exists(dest_symbol_package): shutil.copytree(src_symbol_package, dest_symbol_package) +# +# +# +def getFilenameWithoutVersion(file_name) -> str: + result = file_name.split('.')[0] + # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) + if 'libSDL2' in result: + result = 'libSDL2' + return result # # Recursive function to copy a library and its (non-system) dependencies # also fixes loader paths for each library # def copyLibraryAndDependencies(src_file, dest_folder): - + dest_file = os.path.join(dest_folder, os.path.basename(src_file)) + print(dest_file) + # copy file copyLibraryAndSymbolPackage(src_file, dest_folder, True) + copied_libs.add(src_file) + copied_libs.add(dest_file) + + this_id = '' # recursively copy dependencies otool_proc = subprocess.Popen(['/usr/bin/otool', '-L', src_file], stdout=subprocess.PIPE) @@ -236,23 +250,19 @@ def copyLibraryAndDependencies(src_file, dest_folder): missing_libs.add(src_dependency_file) elif src_dependency_file.startswith(workspace_dir): dependency_name = os.path.basename(src_dependency_file) + if not len(this_id): + this_id = dependency_name dest_dependency_path = os.path.join(dest_folder, dependency_name) if not src_dependency_file in copied_libs: - copied_libs.add(src_dependency_file) - copied_libs.add(dest_dependency_path) if src_dependency_file != dest_dependency_path: - # copy sym-linked libraries as well - dependency_name_without_version = dependency_name.split('.')[0] - # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) - if 'libSDL2' in dependency_name: - dependency_name_without_version = 'libSDL2' - names_without_version.add(dependency_name_without_version) - - unversioned_dependency_base_name = os.path.join(workspace_lib_dir, dependency_name_without_version) - - # Copy each version variant file - for variant_file in glob.glob(unversioned_dependency_base_name + r'*.dylib'): - copyLibraryAndSymbolPackage(variant_file, dest_folder, False) + # Copy each version variant file (often symlinks) + dependency_name_without_version = getFilenameWithoutVersion(src_dependency_file) + unversioned_dependency_base_name = os.path.join(os.path.dirname(src_dependency_file), dependency_name_without_version) + for variant_src_file in glob.glob(unversioned_dependency_base_name + r'*.dylib'): + copyLibraryAndSymbolPackage(variant_src_file, dest_folder, False) + variant_dest_file = os.path.join(dest_folder, os.path.basename(variant_src_file)) + copied_libs.add(variant_src_file) + copied_libs.add(variant_dest_file) # RECURSIVELY copy dependencies if (os.path.exists(unversioned_dependency_base_name + '.dylib')): @@ -265,10 +275,14 @@ def copyLibraryAndDependencies(src_file, dest_folder): # find the non-sym-linked version of this library actual_binary_path = os.path.realpath(dest_file) + if len(this_id): + print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path])) + subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) + if len(loader_paths_to_rewrite) > 0: - for lib in loader_paths_to_rewrite: - print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['old_path'], '@loader_path/' + os.path.basename(lib['new_path']), actual_binary_path])) - install_name_tool_proc = subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + dest_file, '-change', lib['old_path'], '@loader_path/' + os.path.basename(lib['new_path']), actual_binary_path]) + for loader_path in loader_paths_to_rewrite: + print(' '.join(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path])) + subprocess.call(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) # # From 7c5d588cfcb2b4d5b2eb1f29eef9ae295ecd4649 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 11:26:02 -0600 Subject: [PATCH 060/111] remove some debugging traces --- build-ffmpeg-descript.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index d66c9c85..566f6dab 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -228,8 +228,6 @@ def copyLibraryAndDependencies(src_file, dest_folder): dest_file = os.path.join(dest_folder, os.path.basename(src_file)) - print(dest_file) - # copy file copyLibraryAndSymbolPackage(src_file, dest_folder, True) copied_libs.add(src_file) @@ -276,12 +274,10 @@ def copyLibraryAndDependencies(src_file, dest_folder): actual_binary_path = os.path.realpath(dest_file) if len(this_id): - print(' '.join(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path])) subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) if len(loader_paths_to_rewrite) > 0: for loader_path in loader_paths_to_rewrite: - print(' '.join(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path])) subprocess.call(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) # From b948a2def3e9956d9370267c060f94dc5f1e5ef8 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 11:46:18 -0600 Subject: [PATCH 061/111] more cleanup from node script --- build-ffmpeg-descript.py | 120 ++++++--------------------------------- 1 file changed, 17 insertions(+), 103 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 566f6dab..6fb4fe82 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -88,108 +88,6 @@ def copyOrGenerateSymbolFiles(source, dest): for fileref in pathlib.Path(source + '/').glob('**/*.dylib'): copyOrGenerateSymbolFile(str(fileref), dest) -''' -const { resolve, basename } = require('path'); -const { mkdirSync, readlinkSync, readdirSync } = require('fs'); -const { execSync } = require('child_process'); - -function logAndExec(cmd) { - console.log(`EXEC ${cmd}`); - execSync(cmd); -} - -const baseIncludesDir = resolve(__dirname, 'workspace/include'); -const baseBinDir = resolve(__dirname, 'workspace/bin'); -const baseLibDir = resolve(__dirname, 'workspace/lib'); -const destDir = resolve(__dirname, 'workspace/mac'); - -try { - logAndExec(`rm -r -f ${destDir}`); -} catch (err) { - // -} -logAndExec(`mkdir -p ${destDir}`); - -const skippedLibs = new Set(); -const copiedLibs = new Set(); -const missingLibs = new Set(); -const namesWithoutVersion = new Set(); - -function copyDylibs(binaryName, base = baseBinDir) { - const origPath = resolve(base, binaryName); - const binaryPath = resolve(destDir, binaryName); - - logAndExec(`cp -a ${origPath} ${binaryPath}`); - - const lines = execSync(`otool -L ${binaryPath}`).toString('utf8').split('\n'); - const libsToRewrite = []; - for (const line of lines) { - const match = /[^\s:]+/.exec(line); - if (!match) { - continue; - } - const [path] = match; - if (path.startsWith('/usr/local')) { - missingLibs.add(path); - } else if (path.startsWith('/Users')) { - const filename = basename(path); - const newFilename = resolve(destDir, filename); - if (!copiedLibs.has(path)) { - copiedLibs.add(path); - copiedLibs.add(newFilename); - if (path !== newFilename) { - // copy sym-linked libraries as well - let nameWithoutVersion = filename.split('.')[0]; - // libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) - if (filename.includes('libSDL2')) { - nameWithoutVersion = 'libSDL2'; - } - namesWithoutVersion.add(nameWithoutVersion); - const nameWithoutVersionLib = `${nameWithoutVersion}.dylib`; - logAndExec(`cp -a ${resolve(baseLibDir, nameWithoutVersion)}*.dylib ${destDir}/.`); - - copyDylibs(filename, baseLibDir); - } - } - libsToRewrite.push({path, filename}); - } else { - skippedLibs.add(path); - } - } - - // find the non-sym-linked version of this library - let actualBinaryPath = binaryPath; - try { - const actualBinaryName = readlinkSync(binaryPath); - actualBinaryPath = resolve(destDir, actualBinaryName); - } catch (err) { - // - } - - if (libsToRewrite.length > 0) { - logAndExec(`install_name_tool -id @loader_path/${binaryName} ${libsToRewrite.map(({path, filename}) => `-change ${path} @loader_path/${filename}`).join(' ')} ${actualBinaryPath}`); - } -} - -copyDylibs('ffmpeg'); -copyDylibs('ffprobe'); - -console.log('Copying includes'); -logAndExec(`cp -r ${baseIncludesDir} ${destDir}/.`); - -for (const lib of Array.from(skippedLibs).sort()) { - console.log(`[NOTE] skipped ${lib}`); -} -for (const lib of Array.from(copiedLibs).sort()) { - if (!lib.startsWith(destDir)) { - console.log(`Copied ${lib}`); - } -} -for (const lib of Array.from(missingLibs).sort()) { - console.log(`[WARNING] missing ${lib}`); -} -''' - # # # @@ -244,6 +142,8 @@ def copyLibraryAndDependencies(src_file, dest_folder): if not match: continue src_dependency_file = match[0] + if (src_dependency_file == 'libvpx.so.6'): + breakpoint; if src_dependency_file.startswith('/usr/local'): missing_libs.add(src_dependency_file) elif src_dependency_file.startswith(workspace_dir): @@ -292,7 +192,7 @@ def main(): #buildFFmpeg(cwd, workspace_dir) # Generate dSYM files for each built library - #copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) + copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) # Generate dSYM files for each executable executables = ['ffmpeg', 'ffprobe'] @@ -301,6 +201,20 @@ def main(): copyOrGenerateSymbolFile(executable_path, workspace_bin_dir) copyLibraryAndDependencies(executable_path, output_dir) + # Copy Includes + shutil.copytree( + os.path.join(workspace_dir, 'include'), + os.path.join(output_dir, 'include')) + + for lib in sorted(skipped_libs): + print ('[NOTE] skipped ' + lib) + + for lib in sorted(copied_libs): + print ('Copied ' + lib) + + for lib in sorted(missing_libs): + print ('[WARNING] missing ' + lib) + # # entry # From 04f8245347caace89fa482293be33036041343ca Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 11:46:31 -0600 Subject: [PATCH 062/111] remove --static flag for pkg-config when using shared --- build-ffmpeg | 1 - 1 file changed, 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index e80138ee..660cd99b 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -1065,7 +1065,6 @@ if $SHARED_LIBRARIES; then --extra-ldflags="${LDFLAGS}" \ --extra-libs="${EXTRALIBS}" \ --pkgconfigdir="$WORKSPACE/lib/pkgconfig" \ - --pkg-config-flags="--static" \ --prefix="${WORKSPACE}" \ --extra-version="${EXTRA_VERSION}" else From d7856657fb9dc40604054e1b6ee9c524f0dcba63 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 11:56:38 -0600 Subject: [PATCH 063/111] partial fix for .so files --- build-ffmpeg-descript.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 6fb4fe82..066fcd16 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -64,7 +64,6 @@ def copyOrGenerateSymbolFile(file, dest): # example: # ./packages/libtheora-1.1.1/lib/.libs/libtheoraenc.1.dylib.dSYM/Contents/Resources/DWARF/libtheoraenc.1.dylib try: - allParts = fileref.parts symbolDirIndex = allParts.index(symbolFileName) # throws ValueError if not in allParts symbolDirParts = allParts[:symbolDirIndex + 1] @@ -86,7 +85,9 @@ def copyOrGenerateSymbolFile(file, dest): # def copyOrGenerateSymbolFiles(source, dest): for fileref in pathlib.Path(source + '/').glob('**/*.dylib'): - copyOrGenerateSymbolFile(str(fileref), dest) + copyOrGenerateSymbolFile(str(fileref), dest) + for fileref in pathlib.Path(source + '/').glob('**/*.so*'): + copyOrGenerateSymbolFile(str(fileref), dest) # # @@ -142,8 +143,6 @@ def copyLibraryAndDependencies(src_file, dest_folder): if not match: continue src_dependency_file = match[0] - if (src_dependency_file == 'libvpx.so.6'): - breakpoint; if src_dependency_file.startswith('/usr/local'): missing_libs.add(src_dependency_file) elif src_dependency_file.startswith(workspace_dir): @@ -167,6 +166,8 @@ def copyLibraryAndDependencies(src_file, dest_folder): copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) + elif not src_dependency_file.startswith('/'): + breakpoint else: skipped_libs.add(src_dependency_file) From 35c78a51391b8c1c662b2dc4ff497264d1162f55 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 14:36:28 -0600 Subject: [PATCH 064/111] disable libvpx until linking issues are resolved --- build-ffmpeg | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 660cd99b..a9e1dfc2 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -580,26 +580,31 @@ EOF CONFIGURE_OPTIONS+=("--enable-libx265") fi -if build "libvpx" "1.10.0"; then - download "https://github.com/webmproject/libvpx/archive/refs/tags/v1.10.0.tar.gz" "libvpx-1.10.0.tar.gz" +# [ Descript - cvanwink ] +# Disable libvpx on arm64 and x86_64 as it doesn't link properly +# with the .so files - will revisit after end-to-end is working +if false; then + if build "libvpx" "1.10.0"; then + download "https://github.com/webmproject/libvpx/archive/refs/tags/v1.10.0.tar.gz" "libvpx-1.10.0.tar.gz" - if [[ "$OSTYPE" == "darwin"* ]]; then - echo "Applying Darwin patch" - sed "s/,--version-script//g" build/make/Makefile >build/make/Makefile.patched - sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile - fi + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Applying Darwin patch" + sed "s/,--version-script//g" build/make/Makefile >build/make/Makefile.patched + sed "s/-Wl,--no-undefined -Wl,-soname/-Wl,-undefined,error -Wl,-install_name/g" build/make/Makefile.patched >build/make/Makefile + fi - if $SHARED_LIBRARIES; then - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --enable-shared --disable-static --as=yasm --enable-vp9-highbitdepth - else - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm --enable-vp9-highbitdepth - fi - execute make -j $MJOBS - execute make install + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --enable-shared --disable-static --as=yasm --enable-vp9-highbitdepth + else + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm --enable-vp9-highbitdepth + fi + execute make -j $MJOBS + execute make install - build_done "libvpx" "1.10.0" + build_done "libvpx" "1.10.0" + fi + CONFIGURE_OPTIONS+=("--enable-libvpx") fi -CONFIGURE_OPTIONS+=("--enable-libvpx") if $NONFREE_AND_GPL; then if build "xvidcore" "1.3.7"; then From 9b1eeb63e07997469cdfb112c9bdaf91fa16d596 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 14:49:11 -0600 Subject: [PATCH 065/111] Check that binary is runnable --- build-ffmpeg-descript.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 066fcd16..da4b47b7 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -196,12 +196,22 @@ def main(): copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) # Generate dSYM files for each executable + # and copy their dependencies executables = ['ffmpeg', 'ffprobe'] for executable in executables: executable_path = os.path.join(workspace_bin_dir, executable) + + # check that the build library is runnable + subprocess.check_output([executable_path, '-version']) + copyOrGenerateSymbolFile(executable_path, workspace_bin_dir) copyLibraryAndDependencies(executable_path, output_dir) + # check that the copied file is runnable + print(subprocess.check_output([os.path.join(output_dir, executable), '-version']).decode('utf-8')) + + + # Copy Includes shutil.copytree( os.path.join(workspace_dir, 'include'), From 13267292a42ef160f52555c2d48aad7b60ca60aa Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 15:22:21 -0600 Subject: [PATCH 066/111] add more safety --- build-ffmpeg-descript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index da4b47b7..a26828f0 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -175,11 +175,11 @@ def copyLibraryAndDependencies(src_file, dest_folder): actual_binary_path = os.path.realpath(dest_file) if len(this_id): - subprocess.call(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) + subprocess.check_output(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) if len(loader_paths_to_rewrite) > 0: for loader_path in loader_paths_to_rewrite: - subprocess.call(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) + subprocess.check_output(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) # # From 1912a6c7e7aaa2b20d31ee5c343993b95fafc950 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 16:14:19 -0600 Subject: [PATCH 067/111] Workaround for libraries with @rpath --> @loader_path --- build-ffmpeg | 2 +- build-ffmpeg-descript.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index a9e1dfc2..3a33ed45 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -468,7 +468,7 @@ if ! $MACOS_M1; then download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4/SVT-AV1-1a3e32b8fdc4abf5c093ee01dfa82803afc75fb4.tar.gz" "svtav1-1a3e32b.tar.gz" cd "${PACKAGES}"/svtav1-1a3e32b/Build/linux || exit if $SHARED_LIBRARIES; then - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=ON ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=on -DBUILD_SHARED_LIBS=ON ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release else execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release fi diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index a26828f0..50962a96 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -143,6 +143,13 @@ def copyLibraryAndDependencies(src_file, dest_folder): if not match: continue src_dependency_file = match[0] + + # fix incorrect usage of @rpath + if src_dependency_file.startswith('@rpath/'): + fixed_path = os.path.join(workspace_lib_dir, src_dependency_file[7:]) + loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': fixed_path}) + src_dependency_file = fixed_path + if src_dependency_file.startswith('/usr/local'): missing_libs.add(src_dependency_file) elif src_dependency_file.startswith(workspace_dir): @@ -190,7 +197,7 @@ def main(): shutil.rmtree(output_dir) os.makedirs(output_dir) - #buildFFmpeg(cwd, workspace_dir) + buildFFmpeg(cwd, workspace_dir) # Generate dSYM files for each built library copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) @@ -200,10 +207,6 @@ def main(): executables = ['ffmpeg', 'ffprobe'] for executable in executables: executable_path = os.path.join(workspace_bin_dir, executable) - - # check that the build library is runnable - subprocess.check_output([executable_path, '-version']) - copyOrGenerateSymbolFile(executable_path, workspace_bin_dir) copyLibraryAndDependencies(executable_path, output_dir) From fc7b7916453af998d8da7664b3aaa71c1161fafb Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 16:24:05 -0600 Subject: [PATCH 068/111] comments and cleanup --- build-ffmpeg-descript.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 50962a96..e1971d17 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -5,7 +5,9 @@ the FFmpeg building process, for use in Descript's environment. (1) Call build-ffmpeg with the build command -(2) Copy or generate dSYM symbol files to the output folder +(2) Copy or generate dSYM symbol files to the workspace folder +(3) Copy executables from the workspace folder and all built dependencies to platform outputfolder +(4) Fix dyld ids and loader paths for all built libraries ''' import glob @@ -16,7 +18,6 @@ import shutil import subprocess - cwd = os.path.dirname(os.path.realpath(__file__)) packages_dir = os.path.join(cwd, 'packages') workspace_dir = os.path.join(cwd, 'workspace') @@ -213,8 +214,6 @@ def main(): # check that the copied file is runnable print(subprocess.check_output([os.path.join(output_dir, executable), '-version']).decode('utf-8')) - - # Copy Includes shutil.copytree( os.path.join(workspace_dir, 'include'), From 8c621427c12f1659a389ba29434589a43e7dda30 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 20:17:21 -0600 Subject: [PATCH 069/111] clean up and comments --- build-ffmpeg-descript.py | 47 +++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index e1971d17..cc0025b9 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -8,6 +8,7 @@ (2) Copy or generate dSYM symbol files to the workspace folder (3) Copy executables from the workspace folder and all built dependencies to platform outputfolder (4) Fix dyld ids and loader paths for all built libraries +(5) Zip up the build artifacts ''' import glob @@ -17,13 +18,20 @@ import re import shutil import subprocess +import sys +# +# Constants +# cwd = os.path.dirname(os.path.realpath(__file__)) packages_dir = os.path.join(cwd, 'packages') workspace_dir = os.path.join(cwd, 'workspace') workspace_bin_dir = os.path.join(workspace_dir, 'bin') workspace_lib_dir = os.path.join(workspace_dir, 'lib') +# +# Keep track of which libraries are copied, skipped, or missing +# skipped_libs = set() copied_libs = set() missing_libs = set() @@ -31,9 +39,9 @@ # # builds FFmpeg and logs output to build-ffmpeg.log.txt # -def buildFFmpeg(script_dir, workspace_dir): +def buildFFmpeg(script_dir, log_dir): # create a log file for the build-ffmpeg command for build archival purposes - build_ffmpeg_log_filename = os.path.join(workspace_dir, 'build-ffmpeg.log.txt') + build_ffmpeg_log_filename = os.path.join(log_dir, 'build-ffmpeg.log.txt') os.makedirs(os.path.dirname(build_ffmpeg_log_filename), exist_ok=True) build_ffmpeg_log_file = open('./workspace/build-ffmpeg.log.txt', 'w') @@ -91,7 +99,8 @@ def copyOrGenerateSymbolFiles(source, dest): copyOrGenerateSymbolFile(str(fileref), dest) # -# +# Copies a library and its corresponding .dSYM bundle +# (if present) # def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): dest_file = os.path.join(dest_folder, os.path.basename(src_file)) @@ -111,7 +120,8 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): shutil.copytree(src_symbol_package, dest_symbol_package) # -# +# Helper function to get a base name of a library +# without version numbers # def getFilenameWithoutVersion(file_name) -> str: result = file_name.split('.')[0] @@ -133,6 +143,7 @@ def copyLibraryAndDependencies(src_file, dest_folder): copied_libs.add(src_file) copied_libs.add(dest_file) + # identifier for _this_ library this_id = '' # recursively copy dependencies @@ -152,11 +163,14 @@ def copyLibraryAndDependencies(src_file, dest_folder): src_dependency_file = fixed_path if src_dependency_file.startswith('/usr/local'): + # the build grabbed libraries installed on this machine + # which might not be available on other machines missing_libs.add(src_dependency_file) elif src_dependency_file.startswith(workspace_dir): dependency_name = os.path.basename(src_dependency_file) if not len(this_id): - this_id = dependency_name + # first dependency is the identifier for this library + this_id = dependency_name dest_dependency_path = os.path.join(dest_folder, dependency_name) if not src_dependency_file in copied_libs: if src_dependency_file != dest_dependency_path: @@ -174,21 +188,34 @@ def copyLibraryAndDependencies(src_file, dest_folder): copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) - elif not src_dependency_file.startswith('/'): - breakpoint else: skipped_libs.add(src_dependency_file) # find the non-sym-linked version of this library actual_binary_path = os.path.realpath(dest_file) + # correct the loader path for this library if len(this_id): subprocess.check_output(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) + # correct the loader paths for all dependencies if len(loader_paths_to_rewrite) > 0: for loader_path in loader_paths_to_rewrite: subprocess.check_output(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) +# +# Read the version string from ./build-ffmpeg +# +def readVersion() -> str: + result = '' + with open(os.path.join(cwd, 'build-ffmpeg')) as f: + lines = f.readlines() + for line in lines: + if line.startswith('SCRIPT_VERSION='): + result = line[15:].strip() + return result + + # # # @@ -198,7 +225,7 @@ def main(): shutil.rmtree(output_dir) os.makedirs(output_dir) - buildFFmpeg(cwd, workspace_dir) + buildFFmpeg(cwd, output_dir) # Generate dSYM files for each built library copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) @@ -228,6 +255,10 @@ def main(): for lib in sorted(missing_libs): print ('[WARNING] missing ' + lib) + # bundle up the build artifacts + os.chdir(output_dir) + subprocess.check_output(['/usr/bin/zip', '--symlinks', '-r', '../ffmpeg-ffprobe-shared-' + sys.platform + '-' + platform.machine() + '.' + readVersion() + '.zip', '.']) + # # entry # From aae01db25959a4bb28bbf73e44b595103af7feff Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 20:17:40 -0600 Subject: [PATCH 070/111] bump version number --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 3a33ed45..6a156086 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.31 +SCRIPT_VERSION=1.31rc1 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From e23b1ee2f7e50e7b98435704a5048618157e8d3d Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 20:23:42 -0600 Subject: [PATCH 071/111] fix log folder path --- build-ffmpeg-descript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index cc0025b9..44114a51 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -43,7 +43,7 @@ def buildFFmpeg(script_dir, log_dir): # create a log file for the build-ffmpeg command for build archival purposes build_ffmpeg_log_filename = os.path.join(log_dir, 'build-ffmpeg.log.txt') os.makedirs(os.path.dirname(build_ffmpeg_log_filename), exist_ok=True) - build_ffmpeg_log_file = open('./workspace/build-ffmpeg.log.txt', 'w') + build_ffmpeg_log_file = open(build_ffmpeg_log_filename, 'w') # set environment variables env = os.environ From cff8ef09d89306f874907a44c1d4aab86e2097f7 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 9 Nov 2021 21:03:58 -0600 Subject: [PATCH 072/111] Use consistent logging --- build-ffmpeg-descript.py | 76 +++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 44114a51..4e31f3bc 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -39,12 +39,7 @@ # # builds FFmpeg and logs output to build-ffmpeg.log.txt # -def buildFFmpeg(script_dir, log_dir): - # create a log file for the build-ffmpeg command for build archival purposes - build_ffmpeg_log_filename = os.path.join(log_dir, 'build-ffmpeg.log.txt') - os.makedirs(os.path.dirname(build_ffmpeg_log_filename), exist_ok=True) - build_ffmpeg_log_file = open(build_ffmpeg_log_filename, 'w') - +def buildFFmpeg(script_dir, log_file): # set environment variables env = os.environ env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc @@ -52,17 +47,14 @@ def buildFFmpeg(script_dir, log_dir): # call main build script build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') - subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=build_ffmpeg_log_file) - - # close log file - build_ffmpeg_log_file.close() + subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=log_file) # # Copies symbol file to the workspace destination # skips symlinks to avoid duplication # Copies entire dSYM packages for dylib files already within .dSYM packages # -def copyOrGenerateSymbolFile(file, dest): +def copyOrGenerateSymbolFile(file, dest, log_file): fileref = pathlib.Path(file) if not fileref.is_symlink(): symbolFileName = fileref.name + '.dSYM' @@ -85,18 +77,20 @@ def copyOrGenerateSymbolFile(file, dest): # example: # ./packages/libtheora-1.1.1/lib/.libs/libtheora.dylib except ValueError as e: - subprocess.call(['/usr/bin/dsymutil', str(fileref), '-o', destPath]) + args = ['/usr/bin/dsymutil', str(fileref), '-o', destPath] + log_file.write(' '.join(args) + '\n') + subprocess.call(args, stdout=log_file) # # Copies symbol files to the workspace destination # skips symlinks to avoid duplication # Copies entire dSYM packages for dylib files already within .dSYM packages # -def copyOrGenerateSymbolFiles(source, dest): +def copyOrGenerateSymbolFiles(source, dest, log_file): for fileref in pathlib.Path(source + '/').glob('**/*.dylib'): - copyOrGenerateSymbolFile(str(fileref), dest) + copyOrGenerateSymbolFile(str(fileref), dest, log_file) for fileref in pathlib.Path(source + '/').glob('**/*.so*'): - copyOrGenerateSymbolFile(str(fileref), dest) + copyOrGenerateSymbolFile(str(fileref), dest, log_file) # # Copies a library and its corresponding .dSYM bundle @@ -134,7 +128,7 @@ def getFilenameWithoutVersion(file_name) -> str: # Recursive function to copy a library and its (non-system) dependencies # also fixes loader paths for each library # -def copyLibraryAndDependencies(src_file, dest_folder): +def copyLibraryAndDependencies(src_file, dest_folder, log_file): dest_file = os.path.join(dest_folder, os.path.basename(src_file)) @@ -147,7 +141,8 @@ def copyLibraryAndDependencies(src_file, dest_folder): this_id = '' # recursively copy dependencies - otool_proc = subprocess.Popen(['/usr/bin/otool', '-L', src_file], stdout=subprocess.PIPE) + args = ['/usr/bin/otool', '-L', src_file] + otool_proc = subprocess.Popen(args, stdout=subprocess.PIPE) loader_paths_to_rewrite = [] for line in otool_proc.stdout: ln = line.decode('utf-8').strip() @@ -185,7 +180,7 @@ def copyLibraryAndDependencies(src_file, dest_folder): # RECURSIVELY copy dependencies if (os.path.exists(unversioned_dependency_base_name + '.dylib')): - copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder) + copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder, log_file) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) else: @@ -196,12 +191,16 @@ def copyLibraryAndDependencies(src_file, dest_folder): # correct the loader path for this library if len(this_id): - subprocess.check_output(['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path]) + args = ['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path] + log_file.write(' '.join(args) + '\n') + subprocess.check_output(args) # correct the loader paths for all dependencies if len(loader_paths_to_rewrite) > 0: for loader_path in loader_paths_to_rewrite: - subprocess.check_output(['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path]) + args = ['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path] + log_file.write(' '.join(args) + '\n') + subprocess.check_output(args) # # Read the version string from ./build-ffmpeg @@ -225,35 +224,54 @@ def main(): shutil.rmtree(output_dir) os.makedirs(output_dir) - buildFFmpeg(cwd, output_dir) + # create a log file for the build-ffmpeg command for build archival purposes + build_ffmpeg_log_file_path = os.path.join(output_dir, 'build-ffmpeg.log.txt') + build_ffmpeg_log_file = open(build_ffmpeg_log_file_path, 'w') + + # Run the script + buildFFmpeg(cwd, build_ffmpeg_log_file) # Generate dSYM files for each built library - copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir) + build_ffmpeg_log_file.write('\nGenerating Symbols\n') + build_ffmpeg_log_file.write('=======================\n') + copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir, build_ffmpeg_log_file) # Generate dSYM files for each executable # and copy their dependencies executables = ['ffmpeg', 'ffprobe'] for executable in executables: + build_ffmpeg_log_file.write('\nCopying & Linking ' + executable + '\n') + build_ffmpeg_log_file.write('=======================\n') executable_path = os.path.join(workspace_bin_dir, executable) - copyOrGenerateSymbolFile(executable_path, workspace_bin_dir) - copyLibraryAndDependencies(executable_path, output_dir) + copyOrGenerateSymbolFile(executable_path, workspace_bin_dir, build_ffmpeg_log_file) + copyLibraryAndDependencies(executable_path, output_dir, build_ffmpeg_log_file) # check that the copied file is runnable - print(subprocess.check_output([os.path.join(output_dir, executable), '-version']).decode('utf-8')) + build_ffmpeg_log_file.write('\nChecking ' + executable + '\n') + build_ffmpeg_log_file.write('=======================\n') + args = [os.path.join(output_dir, executable), '-version'] + build_ffmpeg_log_file.write(' '.join(args) + '\n') + output = subprocess.check_output(args) + build_ffmpeg_log_file.write(output.decode('utf-8')) # Copy Includes shutil.copytree( os.path.join(workspace_dir, 'include'), os.path.join(output_dir, 'include')) + build_ffmpeg_log_file.write('\nLibrary Info\n') + build_ffmpeg_log_file.write('=======================\n') + + for lib in sorted(missing_libs): + build_ffmpeg_log_file.write('[WARNING] missing ' + lib + '\n') + for lib in sorted(skipped_libs): - print ('[NOTE] skipped ' + lib) + build_ffmpeg_log_file.write('[NOTE] skipped ' + lib + '\n') for lib in sorted(copied_libs): - print ('Copied ' + lib) + build_ffmpeg_log_file.write('Copied ' + lib + '\n') - for lib in sorted(missing_libs): - print ('[WARNING] missing ' + lib) + build_ffmpeg_log_file.close() # bundle up the build artifacts os.chdir(output_dir) From d588fc088f39f9acef0aad63bfb8cbd919efa696 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Tue, 9 Nov 2021 21:42:06 -0600 Subject: [PATCH 073/111] disable pcre - ftp is offline --- build-ffmpeg | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 6a156086..8ed60008 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -724,18 +724,24 @@ if command_exists "python3"; then execute ./waf install build_done "serd" "0.30.10" fi - if build "pcre" "8.44"; then - download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" - if $SHARED_LIBRARIES; then - execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static - else - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static - fi - execute make -j $MJOBS - execute make install - build_done "pcre" "8.44" + # [ Descript - cvanwink ] + # FTP for pcre looks to be down + if false; then + if build "pcre" "8.44"; then + download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" + if $SHARED_LIBRARIES; then + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + else + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + fi + execute make -j $MJOBS + execute make install + + build_done "pcre" "8.44" + fi fi + if build "sord" "0.16.8"; then download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" execute cp -r "${PACKAGES}"/autowaf/* "${PACKAGES}/sord-v0.16.8/waflib/" From 358b3ddf89720ee1adf4978fc79342e1fe6e99fc Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 10 Nov 2021 12:29:40 -0600 Subject: [PATCH 074/111] Add GPL-only option and includes some libraries beamcoder needs libpostproc --- build-ffmpeg | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 8ed60008..b046c32a 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -18,6 +18,7 @@ CONFIGURE_OPTIONS=() NONFREE_AND_GPL=false LATEST=false SHARED_LIBRARIES=false +FREE_AND_GPL=false # Check for Apple Silicon if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then @@ -205,6 +206,7 @@ usage() { echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." echo " --full-shared Build all shared libraries. Cannot be used with --full-static" + echo " --enable-gpl-and-free Enable GPL but not non-free codecs. Cannot be used with --enable-gpl-and-non-free - https://ffmpeg.org/legal.html" echo "" } @@ -248,6 +250,10 @@ while (($# > 0)); do if [[ "$1" == "--full-shared" ]]; then SHARED_LIBRARIES=true fi + if [[ "$1" == "--enable-gpl-and-free" ]]; then + CONFIGURE_OPTIONS+=("--enable-gpl") + FREE_AND_GPL=true + fi shift ;; *) @@ -270,6 +276,11 @@ if [[ ($SHARED_LIBRARIES == true) && ($LDEXEFLAGS == true) ]]; then exit 1 fi +if [[ ($NONFREE_AND_GPL == true) && ($FREE_AND_GPL == true) ]]; then + usage + exit 1 +fi + echo "Using $MJOBS make jobs simultaneously." if $NONFREE_AND_GPL; then @@ -284,6 +295,10 @@ if $SHARED_LIBRARIES; then echo "Building shared libraries." fi +if $FREE_AND_GPL; then + echo "GPL and free codecs" +fi + mkdir -p "$PACKAGES" mkdir -p "$WORKSPACE" @@ -491,7 +506,7 @@ if command_exists "cargo"; then CONFIGURE_OPTIONS+=("--enable-librav1e") fi -if $NONFREE_AND_GPL; then +if $NONFREE_AND_GPL || $FREE_AND_GPL; then if build "x264" "5db6aa6"; then download "https://code.videolan.org/videolan/x264/-/archive/5db6aa6cab1b146e07b60cc1736a01f21da01154/x264-5db6aa6cab1b146e07b60cc1736a01f21da01154.tar.gz" "x264-5db6aa6.tar.gz" @@ -524,7 +539,7 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libx264") fi -if $NONFREE_AND_GPL; then +if $NONFREE_AND_GPL || $FREE_AND_GPL; then if build "x265" "3.5"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt cd build/linux || exit @@ -606,7 +621,7 @@ if false; then CONFIGURE_OPTIONS+=("--enable-libvpx") fi -if $NONFREE_AND_GPL; then +if $NONFREE_AND_GPL || $FREE_AND_GPL; then if build "xvidcore" "1.3.7"; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit From 7554b2df528fb4e06c638322e62283ea42cec12c Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 10 Nov 2021 12:30:15 -0600 Subject: [PATCH 075/111] Archive Source and keep separate --- build-ffmpeg-descript.py | 44 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 4e31f3bc..8f5a465e 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -19,6 +19,7 @@ import shutil import subprocess import sys +from zipfile import ZipFile # # Constants @@ -47,7 +48,13 @@ def buildFFmpeg(script_dir, log_file): # call main build script build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') - subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=log_file) + args = [ + build_ffmpeg_path, + '-b', # build + '--full-shared', # custom Descript shim to build shared libraries instead of static + '--enable-gpl-and-free'] # custom Descript shim to build GPL but not non-free (libpostproc is needed by Beamcoder and requires GPL) + log_file.write(' '.join(args) + '\n\n') + subprocess.call(args, env=env, stdout=log_file) # # Copies symbol file to the workspace destination @@ -214,6 +221,11 @@ def readVersion() -> str: result = line[15:].strip() return result +# +# Returns a string like darwin-x86_64.1.31rc2 +# +def getPlatformMachineVersion() -> str: + return sys.platform + '-' + platform.machine() + '.' + readVersion() # # @@ -225,9 +237,13 @@ def main(): os.makedirs(output_dir) # create a log file for the build-ffmpeg command for build archival purposes - build_ffmpeg_log_file_path = os.path.join(output_dir, 'build-ffmpeg.log.txt') + log_file_name = 'build-ffmpeg-' + getPlatformMachineVersion() + '.log.txt' + build_ffmpeg_log_file_path = os.path.join(os.path.dirname(output_dir), log_file_name) build_ffmpeg_log_file = open(build_ffmpeg_log_file_path, 'w') + build_ffmpeg_log_file.write('Begin build-ffmpeg-descript.py\n') + build_ffmpeg_log_file.write('=======================\n') + # Run the script buildFFmpeg(cwd, build_ffmpeg_log_file) @@ -271,11 +287,31 @@ def main(): for lib in sorted(copied_libs): build_ffmpeg_log_file.write('Copied ' + lib + '\n') - build_ffmpeg_log_file.close() + build_ffmpeg_log_file.write('\nArchiving third-party source\n') + build_ffmpeg_log_file.write('=======================\n') + + # bundle up the third-party source + # grab each .tar.* from the packages folder + packages_zip_name = '-'.join(executables) + '-packages-' + getPlatformMachineVersion() + '.zip' + with ZipFile(os.path.join(os.path.dirname(output_dir), packages_zip_name), 'w') as myzip: + archives = pathlib.Path(packages_dir + '/').glob('*.tar.*') + for archive in sorted(archives, key=lambda s: str(s).lower()): + build_ffmpeg_log_file.write(os.path.join('packages', archive.name) + '\n') + myzip.write(str(archive.absolute()), archive.name) + + build_ffmpeg_log_file.write('\nArchiving libraries\n') + build_ffmpeg_log_file.write('=======================\n') # bundle up the build artifacts os.chdir(output_dir) - subprocess.check_output(['/usr/bin/zip', '--symlinks', '-r', '../ffmpeg-ffprobe-shared-' + sys.platform + '-' + platform.machine() + '.' + readVersion() + '.zip', '.']) + shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip' + args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.'] + build_ffmpeg_log_file.write(' '.join(args)) + subprocess.check_output(args) + + build_ffmpeg_log_file.write('\nEnd of build-ffmpeg-descript.py\n') + build_ffmpeg_log_file.write('=======================\n') + build_ffmpeg_log_file.close() # # entry From e6d6923b40aa8dfd307df02d0edfba9604a34a94 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 10 Nov 2021 13:58:49 -0600 Subject: [PATCH 076/111] Revert changes to x265, no known way to link these as a shared library --- build-ffmpeg | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index b046c32a..b0994794 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -539,34 +539,22 @@ if $NONFREE_AND_GPL || $FREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libx264") fi -if $NONFREE_AND_GPL || $FREE_AND_GPL; then +if $NONFREE_AND_GPL && !SHARED_LIBRARIES; then if build "x265" "3.5"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt cd build/linux || exit rm -rf 8bit 10bit 12bit 2>/dev/null mkdir -p 8bit 10bit 12bit cd 12bit || exit - if $SHARED_LIBRARIES; then - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON - else - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON - fi + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON execute make -j $MJOBS cd ../10bit || exit - if $SHARED_LIBRARIES; then - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF - else - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF - fi + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF execute make -j $MJOBS cd ../8bit || exit ln -sf ../10bit/libx265.a libx265_main10.a ln -sf ../12bit/libx265.a libx265_main12.a - if $SHARED_LIBRARIES; then - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=ON -DBUILD_SHARED_LIBS=ON -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON - else - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON - fi + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON execute make -j $MJOBS mv libx265.a libx265_main.a From d13a52476a6f320929c440d81fb6b3d9b05bc92d Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Wed, 10 Nov 2021 14:34:19 -0600 Subject: [PATCH 077/111] add one more newline --- build-ffmpeg-descript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 8f5a465e..ebbb9d4b 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -306,7 +306,7 @@ def main(): os.chdir(output_dir) shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip' args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.'] - build_ffmpeg_log_file.write(' '.join(args)) + build_ffmpeg_log_file.write(' '.join(args) + '\n') subprocess.check_output(args) build_ffmpeg_log_file.write('\nEnd of build-ffmpeg-descript.py\n') From a307443f63f99bcdc6d8fcac7a490be9c32326a8 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 10 Nov 2021 14:42:21 -0600 Subject: [PATCH 078/111] cherry-pick fix for x265 shared --- build-ffmpeg | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index b0994794..33548668 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -539,30 +539,34 @@ if $NONFREE_AND_GPL || $FREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-libx264") fi -if $NONFREE_AND_GPL && !SHARED_LIBRARIES; then +if $NONFREE_AND_GPL || $FREE_AND_GPL; then if build "x265" "3.5"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt cd build/linux || exit - rm -rf 8bit 10bit 12bit 2>/dev/null - mkdir -p 8bit 10bit 12bit - cd 12bit || exit - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON - execute make -j $MJOBS - cd ../10bit || exit - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF - execute make -j $MJOBS - cd ../8bit || exit - ln -sf ../10bit/libx265.a libx265_main10.a - ln -sf ../12bit/libx265.a libx265_main12.a - execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON - execute make -j $MJOBS + if $SHARED_LIBRARIES; then + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=on -DBUILD_SHARED_LIBS=on ../../source + execute make -j $MJOBS + else + rm -rf 8bit 10bit 12bit 2>/dev/null + mkdir -p 8bit 10bit 12bit + cd 12bit || exit + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF -DMAIN12=ON + execute make -j $MJOBS + cd ../10bit || exit + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DHIGH_BIT_DEPTH=ON -DENABLE_HDR10_PLUS=ON -DEXPORT_C_API=OFF -DENABLE_CLI=OFF + execute make -j $MJOBS + cd ../8bit || exit + ln -sf ../10bit/libx265.a libx265_main10.a + ln -sf ../12bit/libx265.a libx265_main12.a + execute cmake ../../../source -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=OFF -DBUILD_SHARED_LIBS=OFF -DEXTRA_LIB="x265_main10.a;x265_main12.a;-ldl" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON + execute make -j $MJOBS - mv libx265.a libx265_main.a + mv libx265.a libx265_main.a - if [[ "$OSTYPE" == "darwin"* ]]; then - execute "${MACOS_LIBTOOL}" -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null - else - execute ar -M </dev/null + else + execute ar -M < Date: Fri, 12 Nov 2021 09:55:43 -0600 Subject: [PATCH 079/111] Set 10.11 deployment target --- build-ffmpeg-descript.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index ebbb9d4b..2ad34988 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -45,6 +45,7 @@ def buildFFmpeg(script_dir, log_file): env = os.environ env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc env['VERBOSE'] = 'yes' + env['MACOSX_DEPLOYMENT_TARGET'] = '10.11' # call main build script build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') From 5af67732eed781b88c37819c14d2e19b7c1b8813 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 12 Nov 2021 11:11:23 -0600 Subject: [PATCH 080/111] conditionalize 10.11 target to x86_64 --- build-ffmpeg-descript.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 2ad34988..05fdeb81 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -45,7 +45,8 @@ def buildFFmpeg(script_dir, log_file): env = os.environ env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc env['VERBOSE'] = 'yes' - env['MACOSX_DEPLOYMENT_TARGET'] = '10.11' + if platform.machine() == 'x86_64': + env['MACOSX_DEPLOYMENT_TARGET'] = '10.11' # call main build script build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') From 75562a1e83afd4d9e36be54de8256f9c47e67b61 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Sat, 13 Nov 2021 10:28:48 +0100 Subject: [PATCH 081/111] PCRE Mirror fix --- build-ffmpeg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index af8875d0..e8001b5f 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.31 +SCRIPT_VERSION=1.32 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -622,13 +622,13 @@ if command_exists "python3"; then execute ./waf install build_done "serd" "0.30.10" fi - if build "pcre" "8.44"; then - download "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz" "pcre-8.44.tar.gz" + if build "pcre" "8.45"; then + download "https://altushost-swe.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz" "pcre-8.45.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static execute make -j $MJOBS execute make install - build_done "pcre" "8.44" + build_done "pcre" "8.45" fi if build "sord" "0.16.8"; then download "https://gitlab.com/drobilla/sord/-/archive/v0.16.8/sord-v0.16.8.tar.gz" "sord-v0.16.8.tar.gz" From 7ae21ff585f5264934710f1c6deeb19707b4bab0 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Sat, 13 Nov 2021 13:39:38 +0100 Subject: [PATCH 082/111] webp new version 1.2.1 --- build-ffmpeg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index e8001b5f..4ccd46cb 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -758,8 +758,8 @@ fi # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS CPPFLAGS= -if build "libwebp" "1.2.0"; then - download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.0.tar.gz" "libwebp-1.2.0.tar.gz" +if build "libwebp" "1.2.1"; then + download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz" "libwebp-1.2.1.tar.gz" execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static make_dir build cd build || exit @@ -767,7 +767,7 @@ if build "libwebp" "1.2.0"; then execute make -j $MJOBS execute make install - build_done "libwebp" "1.2.0" + build_done "libwebp" "1.2.1" fi CONFIGURE_OPTIONS+=("--enable-libwebp") From 5210332bda02988e05779f6afad8337750d49b56 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Sun, 14 Nov 2021 22:11:47 -0600 Subject: [PATCH 083/111] Fix deployment target --- build-ffmpeg | 4 ++-- build-ffmpeg-descript.py | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 33548668..ced284fb 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -869,7 +869,7 @@ if build "libtheora" "1.1.1"; then chmod +x configure.patched mv configure.patched configure if $SHARED_LIBRARIES; then - if $MACOSX_M1; then + if $MACOS_M1; then # fix Libtool bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63610 export MACOSX_DEPLOYMENT_TARGET=10.11 fi @@ -881,7 +881,7 @@ if build "libtheora" "1.1.1"; then execute make install if $SHARED_LIBRARIES; then - if $MACOSX_M1; then + if $MACOS_M1; then # restore from Line 26 export MACOSX_DEPLOYMENT_TARGET=11.0 fi diff --git a/build-ffmpeg-descript.py b/build-ffmpeg-descript.py index 05fdeb81..42d20616 100755 --- a/build-ffmpeg-descript.py +++ b/build-ffmpeg-descript.py @@ -29,6 +29,7 @@ workspace_dir = os.path.join(cwd, 'workspace') workspace_bin_dir = os.path.join(workspace_dir, 'bin') workspace_lib_dir = os.path.join(workspace_dir, 'lib') +deployment_target = '11.0' if platform.machine() == 'arm64' else '10.11' # # Keep track of which libraries are copied, skipped, or missing @@ -45,8 +46,7 @@ def buildFFmpeg(script_dir, log_file): env = os.environ env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc env['VERBOSE'] = 'yes' - if platform.machine() == 'x86_64': - env['MACOSX_DEPLOYMENT_TARGET'] = '10.11' + env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target # call main build script build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg') @@ -101,11 +101,31 @@ def copyOrGenerateSymbolFiles(source, dest, log_file): for fileref in pathlib.Path(source + '/').glob('**/*.so*'): copyOrGenerateSymbolFile(str(fileref), dest, log_file) +def readDeploymentTarget(src_file) -> str: + args = ['/usr/bin/otool', '-l', src_file] + otool_proc = subprocess.Popen(args, stdout=subprocess.PIPE) + inLoaderCommand = False + for line in otool_proc.stdout: + ln = line.decode('utf-8').strip() + if inLoaderCommand: + if ln.startswith('minos') or ln.startswith('version'): + return ln.split(' ')[1] + if ln.startswith('sdk'): + continue + elif 'LC_VERSION_MIN_MACOSX' in ln or 'LC_BUILD_VERSION' in ln: + inLoaderCommand = True + + return '' + + # # Copies a library and its corresponding .dSYM bundle # (if present) # def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): + this_deployment_target = readDeploymentTarget(src_file) + assert this_deployment_target == deployment_target, '{0} wrong deployment target {1}'.format(src_file, this_deployment_target) + dest_file = os.path.join(dest_folder, os.path.basename(src_file)) # copy file From d3e9e48b06c5821031b26c5033253bcd80638559 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 15 Nov 2021 08:40:57 +0100 Subject: [PATCH 084/111] Try to fix MacOS build --- build-ffmpeg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index 4ccd46cb..def0d0d6 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -755,12 +755,12 @@ if build "libpng" "1.6.37"; then execute make install build_done "libpng" "1.6.37" fi -# libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS -CPPFLAGS= if build "libwebp" "1.2.1"; then + # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS + CPPFLAGS= download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz" "libwebp-1.2.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib make_dir build cd build || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ From 349870c9545b9ca4434735b0fcf1af0560d49c35 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:53:33 +0100 Subject: [PATCH 085/111] MacOs fix --- build-ffmpeg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index def0d0d6..7117dfc4 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.32 +SCRIPT_VERSION=1.33 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -336,7 +336,6 @@ if build "zlib" "1.2.11"; then execute make install build_done "zlib" "1.2.11" fi -LDFLAGS+=" -L/zlib/lib" if build "m4" "1.4.19"; then download "https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz" From 1ac69a4d8087267101d614c0dd20fe2de474a3f1 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Mon, 15 Nov 2021 14:15:14 +0100 Subject: [PATCH 086/111] MacOs fix --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 7117dfc4..d1317fb9 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -759,7 +759,7 @@ if build "libwebp" "1.2.1"; then # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS CPPFLAGS= download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz" "libwebp-1.2.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-gif --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib make_dir build cd build || exit execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ From a78f120b07db63d2a0330e759c858b88ec6c7318 Mon Sep 17 00:00:00 2001 From: Markus Perl <1220081+markus-perl@users.noreply.github.com> Date: Tue, 30 Nov 2021 09:59:16 +0100 Subject: [PATCH 087/111] Mac fix --- build-ffmpeg | 75 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index d1317fb9..1839e4c0 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -93,6 +93,10 @@ download() { make_dir "$DOWNLOAD_PATH/$TARGETDIR" + if [[ "$DOWNLOAD_FILE" == *"patch"* ]]; then + return + fi + if [ -n "$3" ]; then if ! tar -xvf "$DOWNLOAD_PATH/$DOWNLOAD_FILE" -C "$DOWNLOAD_PATH/$TARGETDIR" 2>/dev/null >/dev/null; then echo "Failed to extract $DOWNLOAD_FILE" @@ -305,6 +309,17 @@ fi ## build tools ## +if build "giflib" "5.2.1"; then + download "https://sourceforge.net/projects/giflib/files/giflib-5.2.1.tar.gz" + if [[ "$OSTYPE" == "darwin"* ]]; then + download "https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/c323/attachment/Makefile.patch" + execute patch "${PACKAGES}/giflib-5.2.1/Makefile" ${PACKAGES}/Makefile.patch"" + fi + execute make -j $MJOBS + execute make PREFIX="${WORKSPACE}" install + build_done "giflib" "5.2.1" +fi + if build "pkg-config" "0.29.2"; then download "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz" execute ./configure --silent --prefix="${WORKSPACE}" --with-pc-path="${WORKSPACE}"/lib/pkgconfig --with-internal-glib @@ -385,12 +400,12 @@ if $NONFREE_AND_GPL; then CONFIGURE_OPTIONS+=("--enable-openssl") fi -if build "cmake" "3.21.2"; then - download "https://cmake.org/files/LatestRelease/cmake-3.21.2.tar.gz" +if build "cmake" "3.22.0"; then + download "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0.tar.gz" execute ./configure --prefix="${WORKSPACE}" --parallel="${MJOBS}" -- -DCMAKE_USE_OPENSSL=OFF execute make -j $MJOBS execute make install - build_done "cmake" "3.21.2" + build_done "cmake" "3.22.0" fi ## @@ -408,15 +423,17 @@ if command_exists "python3"; then fi done fi - if build "dav1d" "0.9.2"; then - download "https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz" - make_dir build - execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib - execute ninja -C build - execute ninja -C build install - build_done "dav1d" "0.9.2" + if command_exists "meson"; then + if build "dav1d" "0.9.2"; then + download "https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz" + make_dir build + execute meson build --prefix="${WORKSPACE}" --buildtype=release --default-library=static --libdir="${WORKSPACE}"/lib + execute ninja -C build + execute ninja -C build install + build_done "dav1d" "0.9.2" + fi + CONFIGURE_OPTIONS+=("--enable-libdav1d") fi - CONFIGURE_OPTIONS+=("--enable-libdav1d") fi if ! $MACOS_M1; then @@ -738,12 +755,12 @@ fi ## image library ## -if build "libtiff" "4.3.0"; then - download "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static +if build "libtiff" "4.2.0"; then + download "https://download.osgeo.org/libtiff/tiff-4.2.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-dependency-tracking --disable-lzma --disable-webp --disable-zstd --without-x execute make -j $MJOBS execute make install - build_done "libtiff" "4.3.0" + build_done "libtiff" "4.2.0" fi if build "libpng" "1.6.37"; then download "https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.gz/download?use_mirror=gigenet" "libpng-1.6.37.tar.gz" @@ -755,21 +772,23 @@ if build "libpng" "1.6.37"; then build_done "libpng" "1.6.37" fi -if build "libwebp" "1.2.1"; then - # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS - CPPFLAGS= - download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz" "libwebp-1.2.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-gif --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib - make_dir build - cd build || exit - execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ - execute make -j $MJOBS - execute make install +## does not compile on monterey -> _PrintGifError +if [[ "$OSTYPE" != "darwin"* ]]; then + if build "libwebp" "1.2.1"; then + # libwebp can fail to compile on Ubuntu if these flags were left set to CFLAGS + CPPFLAGS= + download "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz" "libwebp-1.2.1.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static --disable-dependency-tracking --disable-gl --with-zlib-include="${WORKSPACE}"/include/ --with-zlib-lib="${WORKSPACE}"/lib + make_dir build + cd build || exit + execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=OFF -DENABLE_STATIC=ON ../ + execute make -j $MJOBS + execute make install - build_done "libwebp" "1.2.1" + build_done "libwebp" "1.2.1" + fi + CONFIGURE_OPTIONS+=("--enable-libwebp") fi -CONFIGURE_OPTIONS+=("--enable-libwebp") - ## ## other library ## From a0be4b6d9afcac87093fadaebd370563d3045965 Mon Sep 17 00:00:00 2001 From: markus-perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 2 Dec 2021 08:07:09 +0100 Subject: [PATCH 088/111] Version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 1839e4c0..4601ab6e 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.33 +SCRIPT_VERSION=1.34 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From 6728e84e078b7cd5228d49ec1f6de4770be6f3a6 Mon Sep 17 00:00:00 2001 From: markus-perl <1220081+markus-perl@users.noreply.github.com> Date: Thu, 2 Dec 2021 08:07:38 +0100 Subject: [PATCH 089/111] Version update --- build-ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 4601ab6e..1839e4c0 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.34 +SCRIPT_VERSION=1.33 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" From e7a117a2ca31999b3cbe65d96dd388ef55060214 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Thu, 2 Dec 2021 23:05:58 -0600 Subject: [PATCH 090/111] Move `build-ffmpeg-descript.py` to a `descript` subfolder --- descript/.gitignore | 1 + .../build-ffmpeg-descript.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 descript/.gitignore rename build-ffmpeg-descript.py => descript/build-ffmpeg-descript.py (97%) diff --git a/descript/.gitignore b/descript/.gitignore new file mode 100644 index 00000000..28757cf4 --- /dev/null +++ b/descript/.gitignore @@ -0,0 +1 @@ +mac \ No newline at end of file diff --git a/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py similarity index 97% rename from build-ffmpeg-descript.py rename to descript/build-ffmpeg-descript.py index 42d20616..f70ca163 100755 --- a/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -25,8 +25,9 @@ # Constants # cwd = os.path.dirname(os.path.realpath(__file__)) -packages_dir = os.path.join(cwd, 'packages') -workspace_dir = os.path.join(cwd, 'workspace') +base_dir = pathlib.Path(cwd).parent.absolute() +packages_dir = os.path.join(base_dir, 'packages') +workspace_dir = os.path.join(base_dir, 'workspace') workspace_bin_dir = os.path.join(workspace_dir, 'bin') workspace_lib_dir = os.path.join(workspace_dir, 'lib') deployment_target = '11.0' if platform.machine() == 'arm64' else '10.11' @@ -236,7 +237,7 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): # def readVersion() -> str: result = '' - with open(os.path.join(cwd, 'build-ffmpeg')) as f: + with open(os.path.join(base_dir, 'build-ffmpeg')) as f: lines = f.readlines() for line in lines: if line.startswith('SCRIPT_VERSION='): @@ -253,7 +254,7 @@ def getPlatformMachineVersion() -> str: # # def main(): - output_dir = os.path.join(workspace_dir, 'mac', platform.machine()) + output_dir = os.path.join(cwd, 'mac', platform.machine()) if os.path.exists(output_dir): shutil.rmtree(output_dir) os.makedirs(output_dir) @@ -267,7 +268,7 @@ def main(): build_ffmpeg_log_file.write('=======================\n') # Run the script - buildFFmpeg(cwd, build_ffmpeg_log_file) + buildFFmpeg(base_dir, build_ffmpeg_log_file) # Generate dSYM files for each built library build_ffmpeg_log_file.write('\nGenerating Symbols\n') From 1d395f8957bfc97927df35964b42ba5d5dc688ec Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Thu, 2 Dec 2021 23:45:44 -0600 Subject: [PATCH 091/111] Improve bundling to match new features from Descript electron build script --- descript/build-ffmpeg-descript.py | 69 +++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index f70ca163..96bc634c 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -19,7 +19,7 @@ import shutil import subprocess import sys -from zipfile import ZipFile +import zipfile # # Constants @@ -250,25 +250,58 @@ def readVersion() -> str: def getPlatformMachineVersion() -> str: return sys.platform + '-' + platform.machine() + '.' + readVersion() + +# +# +# +def generateChecksum(output_folder): + """ + Calculates checksums for every file in `output_folder` + """ + + checksums = set() + + # calculate checksums for all files + for (dirpath, dirnames, filenames) in os.walk(output_folder): + for file in filenames: + args = ['shasum', '-a', '256', os.path.join(dirpath, file)] + output = subprocess.check_output(args) + checksum = output.decode('utf-8').strip() + + # replace absolute path to just filename + # From: '0a88d3f97f356c6a42449fd548f9b586f565899144849019014e36c7683b745e /Users/cvanwink/Source/git/electron/src/out/Testing/dist.zip' + # To: '0a88d3f97f356c6a42449fd548f9b586f565899144849019014e36c7683b745e *electron-v13.1.6-darwin-x64.zip' + checksum = checksum.replace(os.path.join(dirpath, ''), '*') + checksums.add(checksum) + break + + # Write Checksums to file + checksum_file_path = os.path.join(output_folder, 'SHAMSUM256.txt') + checksum_file = open(checksum_file_path, 'w') + for checksum in checksums: + checksum_file.write(f'{checksum}\n') + checksum_file.close() + # # # def main(): - output_dir = os.path.join(cwd, 'mac', platform.machine()) + output_dir = os.path.join(cwd, 'mac') if os.path.exists(output_dir): shutil.rmtree(output_dir) - os.makedirs(output_dir) + temp_dir = os.path.join(output_dir, platform.machine()) + os.makedirs(temp_dir) # create a log file for the build-ffmpeg command for build archival purposes log_file_name = 'build-ffmpeg-' + getPlatformMachineVersion() + '.log.txt' - build_ffmpeg_log_file_path = os.path.join(os.path.dirname(output_dir), log_file_name) - build_ffmpeg_log_file = open(build_ffmpeg_log_file_path, 'w') + log_file_path = os.path.join(output_dir, log_file_name) + build_ffmpeg_log_file = open(log_file_path, 'w') build_ffmpeg_log_file.write('Begin build-ffmpeg-descript.py\n') build_ffmpeg_log_file.write('=======================\n') # Run the script - buildFFmpeg(base_dir, build_ffmpeg_log_file) + #buildFFmpeg(base_dir, build_ffmpeg_log_file) # Generate dSYM files for each built library build_ffmpeg_log_file.write('\nGenerating Symbols\n') @@ -283,12 +316,12 @@ def main(): build_ffmpeg_log_file.write('=======================\n') executable_path = os.path.join(workspace_bin_dir, executable) copyOrGenerateSymbolFile(executable_path, workspace_bin_dir, build_ffmpeg_log_file) - copyLibraryAndDependencies(executable_path, output_dir, build_ffmpeg_log_file) + copyLibraryAndDependencies(executable_path, temp_dir, build_ffmpeg_log_file) # check that the copied file is runnable build_ffmpeg_log_file.write('\nChecking ' + executable + '\n') build_ffmpeg_log_file.write('=======================\n') - args = [os.path.join(output_dir, executable), '-version'] + args = [os.path.join(temp_dir, executable), '-version'] build_ffmpeg_log_file.write(' '.join(args) + '\n') output = subprocess.check_output(args) build_ffmpeg_log_file.write(output.decode('utf-8')) @@ -296,7 +329,7 @@ def main(): # Copy Includes shutil.copytree( os.path.join(workspace_dir, 'include'), - os.path.join(output_dir, 'include')) + os.path.join(temp_dir, 'include')) build_ffmpeg_log_file.write('\nLibrary Info\n') build_ffmpeg_log_file.write('=======================\n') @@ -315,8 +348,9 @@ def main(): # bundle up the third-party source # grab each .tar.* from the packages folder - packages_zip_name = '-'.join(executables) + '-packages-' + getPlatformMachineVersion() + '.zip' - with ZipFile(os.path.join(os.path.dirname(output_dir), packages_zip_name), 'w') as myzip: + shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip' + packages_zip_name = f'{pathlib.Path(shared_zip_name).stem}-packages.zip' + with zipfile.ZipFile(os.path.join(output_dir, packages_zip_name), 'w', zipfile.ZIP_DEFLATED) as myzip: archives = pathlib.Path(packages_dir + '/').glob('*.tar.*') for archive in sorted(archives, key=lambda s: str(s).lower()): build_ffmpeg_log_file.write(os.path.join('packages', archive.name) + '\n') @@ -326,16 +360,25 @@ def main(): build_ffmpeg_log_file.write('=======================\n') # bundle up the build artifacts - os.chdir(output_dir) - shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip' + os.chdir(temp_dir) + dest_file = os.path.join(output_dir, shared_zip_name) args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.'] build_ffmpeg_log_file.write(' '.join(args) + '\n') subprocess.check_output(args) + + shutil.rmtree(temp_dir) build_ffmpeg_log_file.write('\nEnd of build-ffmpeg-descript.py\n') build_ffmpeg_log_file.write('=======================\n') build_ffmpeg_log_file.close() + # zip up log file + with zipfile.ZipFile(os.path.splitext(log_file_path)[0] + '.zip', 'w', zipfile.ZIP_DEFLATED) as myzip: + myzip.write(log_file_path, os.path.basename(log_file_path)) + os.remove(log_file_path) + + generateChecksum(output_dir) + # # entry # From 13ee124567252a9b98f21207e82346ce8440e20c Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Thu, 2 Dec 2021 23:48:24 -0600 Subject: [PATCH 092/111] Remove change which was mistakenly staged and committed --- descript/build-ffmpeg-descript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 96bc634c..669b9858 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -6,7 +6,7 @@ (1) Call build-ffmpeg with the build command (2) Copy or generate dSYM symbol files to the workspace folder -(3) Copy executables from the workspace folder and all built dependencies to platform outputfolder +(3) Copy executables from the workspace folder and all built dependencies to platform output folder (4) Fix dyld ids and loader paths for all built libraries (5) Zip up the build artifacts ''' @@ -301,7 +301,7 @@ def main(): build_ffmpeg_log_file.write('=======================\n') # Run the script - #buildFFmpeg(base_dir, build_ffmpeg_log_file) + buildFFmpeg(base_dir, build_ffmpeg_log_file) # Generate dSYM files for each built library build_ffmpeg_log_file.write('\nGenerating Symbols\n') From f2bc24f77b4b8f3b0cdfde5019daf8a5d388dbae Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 3 Dec 2021 10:31:18 -0600 Subject: [PATCH 093/111] Separate symbols into their own zip file --- descript/build-ffmpeg-descript.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 669b9858..f59df371 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -291,9 +291,13 @@ def main(): shutil.rmtree(output_dir) temp_dir = os.path.join(output_dir, platform.machine()) os.makedirs(temp_dir) + symbol_temp_dir = os.path.join(output_dir, platform.machine() + '-symbols') + + executables = ['ffmpeg', 'ffprobe'] + base_artifact_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() # create a log file for the build-ffmpeg command for build archival purposes - log_file_name = 'build-ffmpeg-' + getPlatformMachineVersion() + '.log.txt' + log_file_name = base_artifact_name + '-log.txt' log_file_path = os.path.join(output_dir, log_file_name) build_ffmpeg_log_file = open(log_file_path, 'w') @@ -306,11 +310,13 @@ def main(): # Generate dSYM files for each built library build_ffmpeg_log_file.write('\nGenerating Symbols\n') build_ffmpeg_log_file.write('=======================\n') - copyOrGenerateSymbolFiles(packages_dir, workspace_lib_dir, build_ffmpeg_log_file) + copyOrGenerateSymbolFiles(packages_dir, symbol_temp_dir, build_ffmpeg_log_file) + symbol_file_name = base_artifact_name + '-symbols' + shutil.make_archive(os.path.join(output_dir, symbol_file_name), 'zip', symbol_temp_dir) + shutil.rmtree(symbol_temp_dir) # Generate dSYM files for each executable # and copy their dependencies - executables = ['ffmpeg', 'ffprobe'] for executable in executables: build_ffmpeg_log_file.write('\nCopying & Linking ' + executable + '\n') build_ffmpeg_log_file.write('=======================\n') @@ -348,8 +354,7 @@ def main(): # bundle up the third-party source # grab each .tar.* from the packages folder - shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip' - packages_zip_name = f'{pathlib.Path(shared_zip_name).stem}-packages.zip' + packages_zip_name = base_artifact_name + '-packages.zip' with zipfile.ZipFile(os.path.join(output_dir, packages_zip_name), 'w', zipfile.ZIP_DEFLATED) as myzip: archives = pathlib.Path(packages_dir + '/').glob('*.tar.*') for archive in sorted(archives, key=lambda s: str(s).lower()): @@ -361,6 +366,7 @@ def main(): # bundle up the build artifacts os.chdir(temp_dir) + shared_zip_name = base_artifact_name + '.zip' dest_file = os.path.join(output_dir, shared_zip_name) args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.'] build_ffmpeg_log_file.write(' '.join(args) + '\n') From 606d18db1d65f1fd5bd05044b93c4e6e49b17baa Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 3 Dec 2021 10:41:20 -0600 Subject: [PATCH 094/111] Add basic README file for Descript folder --- descript/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 descript/README.md diff --git a/descript/README.md b/descript/README.md new file mode 100644 index 00000000..70c884e1 --- /dev/null +++ b/descript/README.md @@ -0,0 +1,30 @@ +# Build FFmpeg for Descript + +## Author / Contact: + - [Charles Van Winkle](https://github.com/cvanwinkle) + - [Steve Rubin](https://github.com/srubin) + +## Instructions +- Run `build-ffmpeg-descript.py` + + +## Build Overview +The build script automates the following basic operations. +- Creates a log file to archive the compiler/linker and packaging steps +- Runs the modified `buildFFmpeg` shell script, outputs to log file +- Recursively generates or copies `.dSYM` symbol files for each dependency into a `.zip` file + - Also fixes `dlyd` loader paths for each dependency +- Checks that each executable (i.e. `ffmpeg` & `ffprobe`) are runnable +- Copies `includes` header folder +- Checks for any linked dependencies which are linked to locations on the build machine and not present in the archive bundle +- Archives the upstream tar bundles for each `ffmpeg` component + - This is important in case upstream FTP or source servers go offline in the future +- Generates checksum for each created artifact (build, symbols, packages, log) + +## Development +Known issues: +- . + +## Patches + + From 58238849b64d90807946eee4db96700d435c446e Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 3 Dec 2021 10:54:05 -0600 Subject: [PATCH 095/111] Switch comments style to match docstring format --- descript/build-ffmpeg-descript.py | 73 ++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index f59df371..48daab1e 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -40,9 +40,12 @@ missing_libs = set() # -# builds FFmpeg and logs output to build-ffmpeg.log.txt +# # def buildFFmpeg(script_dir, log_file): + """ + builds FFmpeg and logs output to `log_file` + """ # set environment variables env = os.environ env['SKIPINSTALL'] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc @@ -60,11 +63,14 @@ def buildFFmpeg(script_dir, log_file): subprocess.call(args, env=env, stdout=log_file) # -# Copies symbol file to the workspace destination -# skips symlinks to avoid duplication -# Copies entire dSYM packages for dylib files already within .dSYM packages +# # def copyOrGenerateSymbolFile(file, dest, log_file): + """ + Copies a single symbol file to the workspace destination + skips symlinks to avoid duplication + Copies entire `dSYM` packages for `dylib` files already within `.dSYM` packages + """ fileref = pathlib.Path(file) if not fileref.is_symlink(): symbolFileName = fileref.name + '.dSYM' @@ -92,17 +98,27 @@ def copyOrGenerateSymbolFile(file, dest, log_file): subprocess.call(args, stdout=log_file) # -# Copies symbol files to the workspace destination -# skips symlinks to avoid duplication -# Copies entire dSYM packages for dylib files already within .dSYM packages +# # def copyOrGenerateSymbolFiles(source, dest, log_file): + """ + Recursively copies symbol files to the workspace destination + skips symlinks to avoid duplication + Copies entire `dSYM` packages for `dylib` files already within `.dSYM` packages + """ for fileref in pathlib.Path(source + '/').glob('**/*.dylib'): copyOrGenerateSymbolFile(str(fileref), dest, log_file) for fileref in pathlib.Path(source + '/').glob('**/*.so*'): copyOrGenerateSymbolFile(str(fileref), dest, log_file) +# +# +# def readDeploymentTarget(src_file) -> str: + """ + Reads the deployment target of a binary + :return: something like `'10.11'` or an empty string + """ args = ['/usr/bin/otool', '-l', src_file] otool_proc = subprocess.Popen(args, stdout=subprocess.PIPE) inLoaderCommand = False @@ -120,10 +136,13 @@ def readDeploymentTarget(src_file) -> str: # -# Copies a library and its corresponding .dSYM bundle -# (if present) +# # def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): + """ + Copies a library and its corresponding `.dSYM` bundle + (if present) + """ this_deployment_target = readDeploymentTarget(src_file) assert this_deployment_target == deployment_target, '{0} wrong deployment target {1}'.format(src_file, this_deployment_target) @@ -144,21 +163,26 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): shutil.copytree(src_symbol_package, dest_symbol_package) # -# Helper function to get a base name of a library -# without version numbers +# # def getFilenameWithoutVersion(file_name) -> str: - result = file_name.split('.')[0] - # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) - if 'libSDL2' in result: - result = 'libSDL2' - return result + """ + :return: `'libSDL2'` for something like `'libSDL2-2.0.0.dylib'` + """ + result = file_name.split('.')[0] + # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) + if 'libSDL2' in result: + result = 'libSDL2' + return result # -# Recursive function to copy a library and its (non-system) dependencies -# also fixes loader paths for each library +# # def copyLibraryAndDependencies(src_file, dest_folder, log_file): + """ + Recursive function to copy a library and its (non-system) dependencies + also fixes loader paths for each library to be `@loader_path` + """ dest_file = os.path.join(dest_folder, os.path.basename(src_file)) @@ -233,9 +257,13 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): subprocess.check_output(args) # -# Read the version string from ./build-ffmpeg +# # def readVersion() -> str: + """ + Reads the version string from ../build-ffmpeg + :return: something like `'1.31rc1'` + """ result = '' with open(os.path.join(base_dir, 'build-ffmpeg')) as f: lines = f.readlines() @@ -245,9 +273,12 @@ def readVersion() -> str: return result # -# Returns a string like darwin-x86_64.1.31rc2 +# # def getPlatformMachineVersion() -> str: + """ + :return: a string like `'darwin-x86_64.1.31rc2'` + """ return sys.platform + '-' + platform.machine() + '.' + readVersion() @@ -257,8 +288,8 @@ def getPlatformMachineVersion() -> str: def generateChecksum(output_folder): """ Calculates checksums for every file in `output_folder` + and puts it in a `SHAMSUM256.txt` file """ - checksums = set() # calculate checksums for all files From ccfaa1652ce21e0d65b6fed4d0e0302c6338279e Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 3 Dec 2021 20:34:58 -0600 Subject: [PATCH 096/111] More copy fixes --- descript/build-ffmpeg-descript.py | 60 ++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 48daab1e..80bd0118 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -165,15 +165,42 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite): # # # -def getFilenameWithoutVersion(file_name) -> str: +def getFileBaseNameWithoutVersion(file_path) -> str: """ - :return: `'libSDL2'` for something like `'libSDL2-2.0.0.dylib'` + :return: `'libpostproc'` for something like `'/foo/bar/libpostproc.55.9.100.dylib'` """ - result = file_name.split('.')[0] + base_name = os.path.basename(file_path) + base_name = base_name.split('.')[0] # keep everything before first '.' # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib) - if 'libSDL2' in result: - result = 'libSDL2' - return result + if base_name.startswith('libSDL2'): + base_name = 'libSDL2' + return base_name + +# +# +# +def getVersionVariantsForFile(file_path) -> list[str]: + """ + Returns the following three files for any one of the file paths provided: + `'.../ffmpeg-build-script/workspace/lib/libavcodec.58.134.100.dylib'` + `'.../ffmpeg-build-script/workspace/lib/libavcodec.58.dylib'` + `'.../ffmpeg-build-script/workspace/lib/libavcodec.dylib'` + + """ + result = set() + result.add(file_path) + if (pathlib.Path(file_path).is_symlink()): + result.add(os.path.realpath(file_path)) + + dependency_name_without_version = getFileBaseNameWithoutVersion(file_path) + unversioned_dependency_base_name = os.path.join( + os.path.dirname(file_path), + dependency_name_without_version) + + for variant in glob.glob(unversioned_dependency_base_name + r'.*dylib'): + result.add(variant) + + return list(result) # # @@ -206,8 +233,9 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): src_dependency_file = match[0] # fix incorrect usage of @rpath - if src_dependency_file.startswith('@rpath/'): - fixed_path = os.path.join(workspace_lib_dir, src_dependency_file[7:]) + rpath_token = '@rpath/' + if src_dependency_file.startswith(rpath_token): + fixed_path = os.path.join(workspace_lib_dir, src_dependency_file[len(rpath_token):]) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': fixed_path}) src_dependency_file = fixed_path @@ -224,17 +252,14 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): if not src_dependency_file in copied_libs: if src_dependency_file != dest_dependency_path: # Copy each version variant file (often symlinks) - dependency_name_without_version = getFilenameWithoutVersion(src_dependency_file) - unversioned_dependency_base_name = os.path.join(os.path.dirname(src_dependency_file), dependency_name_without_version) - for variant_src_file in glob.glob(unversioned_dependency_base_name + r'*.dylib'): + for variant_src_file in getVersionVariantsForFile(src_dependency_file): copyLibraryAndSymbolPackage(variant_src_file, dest_folder, False) variant_dest_file = os.path.join(dest_folder, os.path.basename(variant_src_file)) copied_libs.add(variant_src_file) copied_libs.add(variant_dest_file) # RECURSIVELY copy dependencies - if (os.path.exists(unversioned_dependency_base_name + '.dylib')): - copyLibraryAndDependencies(unversioned_dependency_base_name + '.dylib', dest_folder, log_file) + copyLibraryAndDependencies(os.path.relpath(src_dependency_file), dest_folder, log_file) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) else: @@ -342,9 +367,6 @@ def main(): build_ffmpeg_log_file.write('\nGenerating Symbols\n') build_ffmpeg_log_file.write('=======================\n') copyOrGenerateSymbolFiles(packages_dir, symbol_temp_dir, build_ffmpeg_log_file) - symbol_file_name = base_artifact_name + '-symbols' - shutil.make_archive(os.path.join(output_dir, symbol_file_name), 'zip', symbol_temp_dir) - shutil.rmtree(symbol_temp_dir) # Generate dSYM files for each executable # and copy their dependencies @@ -352,7 +374,7 @@ def main(): build_ffmpeg_log_file.write('\nCopying & Linking ' + executable + '\n') build_ffmpeg_log_file.write('=======================\n') executable_path = os.path.join(workspace_bin_dir, executable) - copyOrGenerateSymbolFile(executable_path, workspace_bin_dir, build_ffmpeg_log_file) + copyOrGenerateSymbolFile(executable_path, symbol_temp_dir, build_ffmpeg_log_file) copyLibraryAndDependencies(executable_path, temp_dir, build_ffmpeg_log_file) # check that the copied file is runnable @@ -363,6 +385,10 @@ def main(): output = subprocess.check_output(args) build_ffmpeg_log_file.write(output.decode('utf-8')) + symbol_file_name = base_artifact_name + '-symbols' + shutil.make_archive(os.path.join(output_dir, symbol_file_name), 'zip', symbol_temp_dir) + shutil.rmtree(symbol_temp_dir) + # Copy Includes shutil.copytree( os.path.join(workspace_dir, 'include'), From 95ae6378fdaeedc85a9b8ab1c404e3daeb0bd954 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Fri, 3 Dec 2021 22:11:39 -0600 Subject: [PATCH 097/111] Remove `--enable_small` for beamcoder --- build-ffmpeg | 1 - 1 file changed, 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index ced284fb..77903aee 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -1076,7 +1076,6 @@ if $SHARED_LIBRARIES; then --disable-static \ --enable-pthreads \ --enable-shared\ - --enable-small \ --enable-version3 \ --extra-cflags="${CFLAGS}" \ --extra-ldexeflags="${LDEXEFLAGS}" \ From c48d8e0b52fd452acfb3cfe92d19bebe4c00577b Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 7 Dec 2021 15:16:42 -0600 Subject: [PATCH 098/111] Don't compile giflib in parallel It fails with too many cores --- build-ffmpeg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index 86ad1b3e..045c7e45 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -344,7 +344,10 @@ if build "giflib" "5.2.1"; then download "https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/c323/attachment/Makefile.patch" execute patch "${PACKAGES}/giflib-5.2.1/Makefile" ${PACKAGES}/Makefile.patch"" fi - execute make -j $MJOBS + # Descript: compilation will fail with more than 8 jobs, so + # force to not run in parallel + #execute make -j $MJOBS + execute make execute make PREFIX="${WORKSPACE}" install build_done "giflib" "5.2.1" fi From ba0110e8a4fa90cad9d27d6d0176d0e65b33f50a Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 7 Dec 2021 15:17:15 -0600 Subject: [PATCH 099/111] fail if build-ffmpeg fails --- descript/build-ffmpeg-descript.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 80bd0118..9a42c5da 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -59,8 +59,9 @@ def buildFFmpeg(script_dir, log_file): '-b', # build '--full-shared', # custom Descript shim to build shared libraries instead of static '--enable-gpl-and-free'] # custom Descript shim to build GPL but not non-free (libpostproc is needed by Beamcoder and requires GPL) - log_file.write(' '.join(args) + '\n\n') - subprocess.call(args, env=env, stdout=log_file) + log_file.write(' '.join(args) + '\n\n') + log_file.flush() + subprocess.run(args, env=env, stdout=log_file, stderr=log_file, check=True) # # From 797fbe7470d92d2d5b0aa894a8cd6f4aaa60657f Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 7 Dec 2021 15:44:20 -0600 Subject: [PATCH 100/111] Fix relpath -> realpath typo --- descript/build-ffmpeg-descript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 9a42c5da..62fd3251 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -260,7 +260,7 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): copied_libs.add(variant_dest_file) # RECURSIVELY copy dependencies - copyLibraryAndDependencies(os.path.relpath(src_dependency_file), dest_folder, log_file) + copyLibraryAndDependencies(os.path.realpath(src_dependency_file), dest_folder, log_file) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) else: From 499a002de8e8773d065d96e2943f9000bf0fb67c Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Tue, 7 Dec 2021 17:00:53 -0600 Subject: [PATCH 101/111] Fix python 3.8 usage and better logging for missing libs --- descript/build-ffmpeg-descript.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 62fd3251..29770960 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -180,7 +180,7 @@ def getFileBaseNameWithoutVersion(file_path) -> str: # # # -def getVersionVariantsForFile(file_path) -> list[str]: +def getVersionVariantsForFile(file_path): """ Returns the following three files for any one of the file paths provided: `'.../ffmpeg-build-script/workspace/lib/libavcodec.58.134.100.dylib'` @@ -206,10 +206,11 @@ def getVersionVariantsForFile(file_path) -> list[str]: # # # -def copyLibraryAndDependencies(src_file, dest_folder, log_file): +def copyLibraryAndDependencies(src_file, dest_folder, log_file, parent_path = ''): """ Recursive function to copy a library and its (non-system) dependencies also fixes loader paths for each library to be `@loader_path` + :param: `parent_path` - optional argument to show which parent is linking against `src_file` """ dest_file = os.path.join(dest_folder, os.path.basename(src_file)) @@ -243,7 +244,7 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): if src_dependency_file.startswith('/usr/local'): # the build grabbed libraries installed on this machine # which might not be available on other machines - missing_libs.add(src_dependency_file) + missing_libs.add(f'{src_dependency_file} (dependency of {os.path.basename(parent_path)})') elif src_dependency_file.startswith(workspace_dir): dependency_name = os.path.basename(src_dependency_file) if not len(this_id): @@ -260,7 +261,11 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file): copied_libs.add(variant_dest_file) # RECURSIVELY copy dependencies - copyLibraryAndDependencies(os.path.realpath(src_dependency_file), dest_folder, log_file) + copyLibraryAndDependencies( + os.path.realpath(src_dependency_file), + dest_folder, + log_file, + src_file) loader_paths_to_rewrite.append({'old_path': src_dependency_file, 'new_path': dest_dependency_path}) else: @@ -376,7 +381,7 @@ def main(): build_ffmpeg_log_file.write('=======================\n') executable_path = os.path.join(workspace_bin_dir, executable) copyOrGenerateSymbolFile(executable_path, symbol_temp_dir, build_ffmpeg_log_file) - copyLibraryAndDependencies(executable_path, temp_dir, build_ffmpeg_log_file) + copyLibraryAndDependencies(executable_path, temp_dir, build_ffmpeg_log_file, executable_path) # check that the copied file is runnable build_ffmpeg_log_file.write('\nChecking ' + executable + '\n') From c160d3688088584e98e988474811ac6d4113f48c Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 12:22:26 -0600 Subject: [PATCH 102/111] Try to add CI for build-ffmpeg-descript.py Need to log to STDOUT as well as log file --- .github/workflows/descript-build.yml | 22 +++++++ build-ffmpeg | 2 +- descript/build-ffmpeg-descript.py | 88 ++++++++++++++++------------ 3 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/descript-build.yml diff --git a/.github/workflows/descript-build.yml b/.github/workflows/descript-build.yml new file mode 100644 index 00000000..4c1f3611 --- /dev/null +++ b/.github/workflows/descript-build.yml @@ -0,0 +1,22 @@ +name: descript build test + +on: + push: + paths-ignore: + - '*.md' + pull_request: + branches: [ charles/arm64 ] + +jobs: + build-macos-shared: + name: build in native macOS + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: build-ffmpeg-descript.py + run: | + while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & + python3 ./descript/build-ffmpeg-descript.py + kill %1 \ No newline at end of file diff --git a/build-ffmpeg b/build-ffmpeg index 045c7e45..e4231498 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.33rc1 +SCRIPT_VERSION=1.33rc2 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 29770960..1ea491cb 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -39,6 +39,21 @@ copied_libs = set() missing_libs = set() +# +# Global Logging File +# +log_file = None + +# +# +# +def log(str): + """ + Logs to stdout and to log_file + """ + log_file.write(str + '\n') + print(str) + # # # @@ -59,9 +74,9 @@ def buildFFmpeg(script_dir, log_file): '-b', # build '--full-shared', # custom Descript shim to build shared libraries instead of static '--enable-gpl-and-free'] # custom Descript shim to build GPL but not non-free (libpostproc is needed by Beamcoder and requires GPL) - log_file.write(' '.join(args) + '\n\n') - log_file.flush() - subprocess.run(args, env=env, stdout=log_file, stderr=log_file, check=True) + log(' '.join(args) + '\n') + process_result = subprocess.run(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True) + log(process_result.stdout.decode('utf-8')) # # @@ -95,8 +110,9 @@ def copyOrGenerateSymbolFile(file, dest, log_file): # ./packages/libtheora-1.1.1/lib/.libs/libtheora.dylib except ValueError as e: args = ['/usr/bin/dsymutil', str(fileref), '-o', destPath] - log_file.write(' '.join(args) + '\n') - subprocess.call(args, stdout=log_file) + log(' '.join(args) + '\n') + process_result = subprocess.run(args, stdout=subprocess.PIPE) + log(process_result.stdout.decode('utf-8')) # # @@ -277,14 +293,14 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file, parent_path = '' # correct the loader path for this library if len(this_id): args = ['/usr/bin/install_name_tool', '-id', '@loader_path/' + this_id, actual_binary_path] - log_file.write(' '.join(args) + '\n') + log(' '.join(args)) subprocess.check_output(args) # correct the loader paths for all dependencies if len(loader_paths_to_rewrite) > 0: for loader_path in loader_paths_to_rewrite: args = ['/usr/bin/install_name_tool', '-change', loader_path['old_path'], '@loader_path/' + os.path.basename(loader_path['new_path']), actual_binary_path] - log_file.write(' '.join(args) + '\n') + log(' '.join(args)) subprocess.check_output(args) # @@ -361,35 +377,35 @@ def main(): # create a log file for the build-ffmpeg command for build archival purposes log_file_name = base_artifact_name + '-log.txt' log_file_path = os.path.join(output_dir, log_file_name) - build_ffmpeg_log_file = open(log_file_path, 'w') + globals()['log_file'] = open(log_file_path, 'w') - build_ffmpeg_log_file.write('Begin build-ffmpeg-descript.py\n') - build_ffmpeg_log_file.write('=======================\n') + log('Begin build-ffmpeg-descript.py') + log('=======================') # Run the script - buildFFmpeg(base_dir, build_ffmpeg_log_file) + buildFFmpeg(base_dir, log_file) # Generate dSYM files for each built library - build_ffmpeg_log_file.write('\nGenerating Symbols\n') - build_ffmpeg_log_file.write('=======================\n') - copyOrGenerateSymbolFiles(packages_dir, symbol_temp_dir, build_ffmpeg_log_file) + log('\nGenerating Symbols') + log('=======================') + copyOrGenerateSymbolFiles(packages_dir, symbol_temp_dir, log_file) # Generate dSYM files for each executable # and copy their dependencies for executable in executables: - build_ffmpeg_log_file.write('\nCopying & Linking ' + executable + '\n') - build_ffmpeg_log_file.write('=======================\n') + log('\nCopying & Linking ' + executable) + log('=======================') executable_path = os.path.join(workspace_bin_dir, executable) - copyOrGenerateSymbolFile(executable_path, symbol_temp_dir, build_ffmpeg_log_file) - copyLibraryAndDependencies(executable_path, temp_dir, build_ffmpeg_log_file, executable_path) + copyOrGenerateSymbolFile(executable_path, symbol_temp_dir, log_file) + copyLibraryAndDependencies(executable_path, temp_dir, log_file, executable_path) # check that the copied file is runnable - build_ffmpeg_log_file.write('\nChecking ' + executable + '\n') - build_ffmpeg_log_file.write('=======================\n') + log('\nChecking ' + executable) + log('=======================') args = [os.path.join(temp_dir, executable), '-version'] - build_ffmpeg_log_file.write(' '.join(args) + '\n') + log(' '.join(args)) output = subprocess.check_output(args) - build_ffmpeg_log_file.write(output.decode('utf-8')) + log(output.decode('utf-8')) symbol_file_name = base_artifact_name + '-symbols' shutil.make_archive(os.path.join(output_dir, symbol_file_name), 'zip', symbol_temp_dir) @@ -400,20 +416,20 @@ def main(): os.path.join(workspace_dir, 'include'), os.path.join(temp_dir, 'include')) - build_ffmpeg_log_file.write('\nLibrary Info\n') - build_ffmpeg_log_file.write('=======================\n') + log('\nLibrary Info') + log('=======================') for lib in sorted(missing_libs): - build_ffmpeg_log_file.write('[WARNING] missing ' + lib + '\n') + log('[WARNING] missing ' + lib) for lib in sorted(skipped_libs): - build_ffmpeg_log_file.write('[NOTE] skipped ' + lib + '\n') + log('[NOTE] skipped ' + lib) for lib in sorted(copied_libs): - build_ffmpeg_log_file.write('Copied ' + lib + '\n') + log('Copied ' + lib) - build_ffmpeg_log_file.write('\nArchiving third-party source\n') - build_ffmpeg_log_file.write('=======================\n') + log('\nArchiving third-party source') + log('=======================') # bundle up the third-party source # grab each .tar.* from the packages folder @@ -421,25 +437,25 @@ def main(): with zipfile.ZipFile(os.path.join(output_dir, packages_zip_name), 'w', zipfile.ZIP_DEFLATED) as myzip: archives = pathlib.Path(packages_dir + '/').glob('*.tar.*') for archive in sorted(archives, key=lambda s: str(s).lower()): - build_ffmpeg_log_file.write(os.path.join('packages', archive.name) + '\n') + log(os.path.join('packages', archive.name)) myzip.write(str(archive.absolute()), archive.name) - build_ffmpeg_log_file.write('\nArchiving libraries\n') - build_ffmpeg_log_file.write('=======================\n') + log('\nArchiving libraries') + log('=======================') # bundle up the build artifacts os.chdir(temp_dir) shared_zip_name = base_artifact_name + '.zip' dest_file = os.path.join(output_dir, shared_zip_name) args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.'] - build_ffmpeg_log_file.write(' '.join(args) + '\n') + log(' '.join(args)) subprocess.check_output(args) shutil.rmtree(temp_dir) - build_ffmpeg_log_file.write('\nEnd of build-ffmpeg-descript.py\n') - build_ffmpeg_log_file.write('=======================\n') - build_ffmpeg_log_file.close() + log('\nEnd of build-ffmpeg-descript.py') + log('=======================') + log_file.close() # zip up log file with zipfile.ZipFile(os.path.splitext(log_file_path)[0] + '.zip', 'w', zipfile.ZIP_DEFLATED) as myzip: From 6e920b99850aa7d4bb3daf48576de891a7631d44 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 12:43:26 -0600 Subject: [PATCH 103/111] Better piping of log output --- descript/build-ffmpeg-descript.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 1ea491cb..05507c3a 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -54,6 +54,16 @@ def log(str): log_file.write(str + '\n') print(str) +# +# +# +def log_pipe(pipe): + """ + logs from a pipe by claling log() + """ + for line in iter(pipe.readline, b''): # b'\n'-separated lines + log(line.decode('utf-8').strip()) + # # # @@ -75,8 +85,13 @@ def buildFFmpeg(script_dir, log_file): '--full-shared', # custom Descript shim to build shared libraries instead of static '--enable-gpl-and-free'] # custom Descript shim to build GPL but not non-free (libpostproc is needed by Beamcoder and requires GPL) log(' '.join(args) + '\n') - process_result = subprocess.run(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True) - log(process_result.stdout.decode('utf-8')) + log_file.flush() + shell_proc = subprocess.Popen(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + with shell_proc.stdout: + log_pipe(shell_proc.stdout) + exitcode = shell_proc.wait() # 0 means success + if (exitcode != 0): + raise exitcode # # From 2490da300a850731a031ca180c34d061bd9e024a Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 12:46:06 -0600 Subject: [PATCH 104/111] Try better output of python script --- .github/workflows/descript-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/descript-build.yml b/.github/workflows/descript-build.yml index 4c1f3611..2fe7e7ae 100644 --- a/.github/workflows/descript-build.yml +++ b/.github/workflows/descript-build.yml @@ -18,5 +18,5 @@ jobs: - name: build-ffmpeg-descript.py run: | while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - python3 ./descript/build-ffmpeg-descript.py + output=$(python3 ./descript/build-ffmpeg-descript.py) kill %1 \ No newline at end of file From 0c9133184d16f6f2e67128a306198c584f292465 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 12:52:08 -0600 Subject: [PATCH 105/111] Try different way of running python script --- .github/workflows/descript-build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/descript-build.yml b/.github/workflows/descript-build.yml index 2fe7e7ae..698ff451 100644 --- a/.github/workflows/descript-build.yml +++ b/.github/workflows/descript-build.yml @@ -15,8 +15,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: build-ffmpeg-descript.py + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 #install the python needed + + - name: execute py script # run the run.py to get the latest data run: | - while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - output=$(python3 ./descript/build-ffmpeg-descript.py) - kill %1 \ No newline at end of file + python ./descript/build-ffmpeg-descript.py From a150884d06cae94fa3c6ac0599f6e132071ba173 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 12:58:13 -0600 Subject: [PATCH 106/111] try logging to stderr to see if that helps github --- descript/build-ffmpeg-descript.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 05507c3a..b28d9706 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -49,17 +49,17 @@ # def log(str): """ - Logs to stdout and to log_file + Logs to stderr and to log_file """ log_file.write(str + '\n') - print(str) + print(str, file=sys.stderr) # # # def log_pipe(pipe): """ - logs from a pipe by claling log() + logs from a pipe by calling log() """ for line in iter(pipe.readline, b''): # b'\n'-separated lines log(line.decode('utf-8').strip()) @@ -398,7 +398,7 @@ def main(): log('=======================') # Run the script - buildFFmpeg(base_dir, log_file) + #buildFFmpeg(base_dir, log_file) # Generate dSYM files for each built library log('\nGenerating Symbols') From 8269e96dc52f5b3d6a718bc7472668bd82b76824 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 13:00:10 -0600 Subject: [PATCH 107/111] try stdout again with flush --- descript/build-ffmpeg-descript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index b28d9706..52a547eb 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -49,10 +49,10 @@ # def log(str): """ - Logs to stderr and to log_file + Logs to stdout and to log_file """ log_file.write(str + '\n') - print(str, file=sys.stderr) + print(str, flush=True) # # From ffe9a8725cdb330529e6fa9e18744b0d455e190d Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 13:01:44 -0600 Subject: [PATCH 108/111] re-enable build-ffmpeg --- descript/build-ffmpeg-descript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index 52a547eb..c96b699a 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -398,7 +398,7 @@ def main(): log('=======================') # Run the script - #buildFFmpeg(base_dir, log_file) + buildFFmpeg(base_dir, log_file) # Generate dSYM files for each built library log('\nGenerating Symbols') From e87b40ccaa3120e011e61f9134c0d13e7c9a1135 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 14:45:22 -0600 Subject: [PATCH 109/111] Add more documentation and refine github action --- .github/workflows/descript-build.yml | 6 +++--- descript/README.md | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/descript-build.yml b/.github/workflows/descript-build.yml index 698ff451..6497c6e1 100644 --- a/.github/workflows/descript-build.yml +++ b/.github/workflows/descript-build.yml @@ -1,4 +1,4 @@ -name: descript build test +name: build shared-libs for Descript on: push: @@ -9,7 +9,7 @@ on: jobs: build-macos-shared: - name: build in native macOS + name: ffmpeg-ffprobe-shared-darwin runs-on: macos-latest steps: - name: Checkout code @@ -20,6 +20,6 @@ jobs: with: python-version: 3.8 #install the python needed - - name: execute py script # run the run.py to get the latest data + - name: build-ffmpeg-descript.py run: | python ./descript/build-ffmpeg-descript.py diff --git a/descript/README.md b/descript/README.md index 70c884e1..77958a2e 100644 --- a/descript/README.md +++ b/descript/README.md @@ -1,3 +1,5 @@ +![](../ffmpeg-build-script.png) + # Build FFmpeg for Descript ## Author / Contact: @@ -23,8 +25,22 @@ The build script automates the following basic operations. ## Development Known issues: -- . +- CI can only build `x86_64` and doesn't yet cross-compile to `arm64` +- When running on CI, there's libraries linked from `/usr/local/opt/...` which are non-portable + - Watch the script output at the end for warnings about this. These could turn into errors later. ## Patches +- The build-ffmpeg shell script is modified directly to allow for + - building shared libraries + - disable non-free codecs + - add additional codecs that Descript uses +## Deployment / Releases +- Currently, the script is run manually on a developer's machine + - once for each platform (`x86_64` and `arm64`) +- Build artifacts (`*.zip` files) are manually uploaded to a GitHub release and tagged +- `SHAMSUM256.txt` files need to be merged between the two platforms when adding to a release. +## Clients +- This build is consumed by Descript's Beamcoder fork + - https://github.com/descriptinc/beamcoder \ No newline at end of file From 3ac5fad4d7387f20b0143e723044d3abf1ab63c9 Mon Sep 17 00:00:00 2001 From: Charles Van Winkle Date: Wed, 8 Dec 2021 15:17:33 -0600 Subject: [PATCH 110/111] Add the additional libraries we want for Descript based off of change 6ceca48 --- build-ffmpeg | 95 ++++++++++++++++++++++++++++++++++++++++++++++ descript/README.md | 52 ++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 1 deletion(-) diff --git a/build-ffmpeg b/build-ffmpeg index e4231498..df0bd8d8 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -1050,6 +1050,101 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then CONFIGURE_OPTIONS+=("--enable-amf") fi + +## +## Descript Additions +## + +if $SHARED_LIBRARIES; then + if build "twolame" "0.4.0"; then + download "https://downloads.sourceforge.net/twolame/twolame-0.4.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + execute make -j $MJOBS + execute make install + + build_done "twolame" "0.4.0" + fi + CONFIGURE_OPTIONS+=("--enable-libtwolame") + + + if build "shine" "3.1.1"; then + download "https://github.com/toots/shine/archive/3.1.1.tar.gz" "shine-3.1.1.tar.gz" + execute autoreconf -i + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + execute make -j $MJOBS + execute make install + + build_done "shine" "3.1.1" + fi + CONFIGURE_OPTIONS+=("--enable-libshine") + + + if build "soxr" "0.1.3"; then + download "http://ftp.debian.org/debian/pool/main/libs/libsoxr/libsoxr_0.1.3.orig.tar.xz" "soxr-0.1.3.tar.xz" + make_dir build + cd build || exit + execute cmake .. -DWITH_OPENMP:BOOL=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=ON + execute make -j $MJOBS + execute make install + + build_done "soxr" "0.1.3" + fi + CONFIGURE_OPTIONS+=("--enable-libsoxr") + + + if build "speex" "1.2.0"; then + download "http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + execute make -j $MJOBS + execute make install + + build_done "speex" "1.2.0" + fi + CONFIGURE_OPTIONS+=("--enable-libspeex") + + + if build "openjpeg" "2.3.1"; then + download "https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz" "openjpeg-v2.3.1.tar.gz" + make_dir build + cd build || exit + execute cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DBUILD_SHARED_LIBS:bool=on + execute make -j $MJOBS + execute make install + + build_done "openjpeg" "2.3.1" + fi + CONFIGURE_OPTIONS+=("--enable-libopenjpeg") + + + if build "snappy" "1.1.8"; then + download "https://github.com/google/snappy/archive/1.1.8.tar.gz" + make_dir build + cd build || exit + execute cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DBUILD_SHARED_LIBS:bool=on + execute make -j $MJOBS + + #if [[ "$OSTYPE" == "darwin"* ]]; then + # execute install_name_tool -id "${WORKSPACE}/lib/libsnappy.1.dylib" libsnappy.1.dylib + #fi + + execute make install + + build_done "snappy" "1.1.8" + fi + CONFIGURE_OPTIONS+=("--enable-libsnappy") + + + if build "xz" "5.2.5"; then + download "https://tukaani.org/xz/xz-5.2.5.tar.gz" + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + execute make -j $MJOBS + execute make install + + build_done "xz" "5.2.5" + fi + +fi + ## ## FFmpeg ## diff --git a/descript/README.md b/descript/README.md index 77958a2e..66f919f7 100644 --- a/descript/README.md +++ b/descript/README.md @@ -43,4 +43,54 @@ Known issues: ## Clients - This build is consumed by Descript's Beamcoder fork - - https://github.com/descriptinc/beamcoder \ No newline at end of file + - https://github.com/descriptinc/beamcoder + +## Previous Documentation of targeted differences (prior to `arm64` port) +- ❌ don't need +- ✅ already in ffmpeg-build-script build +- 🕒 need to add to ffmpeg-build-script + +Target (`evermeet.cx` static build) +- `--cc=/usr/bin/clang` +- `--prefix=/opt/ffmpeg` +- `--extra-version=tessus` +- ❌ `--enable-avisynth` - non-linear editing +- ❌ `--enable-fontconfig` +- ✅ `--enable-gpl` +- ✅ `--enable-libaom` +- ❌ `--enable-libass` +- ❌ `--enable-libbluray` - bluray playback +- 🕒✅ `--enable-libdav1d` +- ❌ `--enable-libfreetype` - text rendering +- ❌ `--enable-libgsm` - GSM audio +- ❌ `--enable-libmodplug` - midi/instrument support (https://github.com/Konstanty/libmodplug) +- ✅ `--enable-libmp3lame` +- ❌ `--enable-libmysofa` - spatial audio +- ✅ `--enable-libopencore-amrnb` +- ✅ `--enable-libopencore-amrwb` +- 🕒✅ `--enable-libopenh264` +- 🕒✅ `--enable-libopenjpeg` +- ✅ `--enable-libopus` +- ❌ `--enable-librubberband` - time stretching +- 🕒✅ `--enable-libshine` - mp3 encoder +- 🕒✅ `--enable-libsnappy` - compression/decompression +- 🕒✅ `--enable-libsoxr` - resampling +- 🕒✅ `--enable-libspeex` - speex audio file format +- ✅ `--enable-libtheora` +- 🕒✅ `--enable-libtwolame` - mpeg2 +- ✅ `--enable-libvidstab` +- ❌ `--enable-libvmaf` - perceptual video quality metric +- ❌ `--enable-libvo-amrwbenc` - VisualOn AMR-WB encoder library +- ✅ `--enable-libvorbis` +- ✅ `--enable-libvpx` +- ✅ `--enable-libwebp` +- ✅ `--enable-libx264` +- ✅ `--enable-libx265` +- ❌ `--enable-libxavs` - AV standard of China +- ✅ `--enable-libxvid` +- 🕒✅ `--enable-libzimg` - Scaling, colorspace conversion, and dithering library +- ❌ `--enable-libzmq` - ZeroMQ Support To Let Multiple Clients Connect To A Single Instance (streaming) +- ❌ `--enable-libzvbi` - capture and decode VBI (vertical blanking interval) data +- ✅ `--enable-version3` +- `--pkg-config-flags=--static` +- `--disable-ffplay` From c3897f4ad60ffb9e8862a8919c95c127d50c2c41 Mon Sep 17 00:00:00 2001 From: C Van Winkle Date: Wed, 8 Dec 2021 16:19:24 -0600 Subject: [PATCH 111/111] Fix soxr on arm64 --- build-ffmpeg | 6 +++++- descript/build-ffmpeg-descript.py | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build-ffmpeg b/build-ffmpeg index df0bd8d8..3ec81483 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -5,7 +5,7 @@ PROGNAME=$(basename "$0") FFMPEG_VERSION=4.4 -SCRIPT_VERSION=1.33rc2 +SCRIPT_VERSION=1.33rc3 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -1083,6 +1083,10 @@ if $SHARED_LIBRARIES; then download "http://ftp.debian.org/debian/pool/main/libs/libsoxr/libsoxr_0.1.3.orig.tar.xz" "soxr-0.1.3.tar.xz" make_dir build cd build || exit + if [[ "$OSTYPE" == "darwin"* ]]; then + download "https://raw.githubusercontent.com/macports/macports-ports/master/audio/soxr/files/patch-pffft.c.diff" "patch-pffft.c.diff" + execute patch "${PACKAGES}/soxr-0.1.3/src/pffft.c" ${PACKAGES}/patch-pffft.c.diff"" + fi execute cmake .. -DWITH_OPENMP:BOOL=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=ON execute make -j $MJOBS execute make install diff --git a/descript/build-ffmpeg-descript.py b/descript/build-ffmpeg-descript.py index c96b699a..5c792ede 100755 --- a/descript/build-ffmpeg-descript.py +++ b/descript/build-ffmpeg-descript.py @@ -447,13 +447,15 @@ def main(): log('=======================') # bundle up the third-party source - # grab each .tar.* from the packages folder + # grab each .tar.* and any downloaded patches from the packages folder packages_zip_name = base_artifact_name + '-packages.zip' with zipfile.ZipFile(os.path.join(output_dir, packages_zip_name), 'w', zipfile.ZIP_DEFLATED) as myzip: - archives = pathlib.Path(packages_dir + '/').glob('*.tar.*') - for archive in sorted(archives, key=lambda s: str(s).lower()): - log(os.path.join('packages', archive.name)) - myzip.write(str(archive.absolute()), archive.name) + types = ['*.tar.*', '*.patch', '*.diff'] + for file_type in types: + archives = pathlib.Path(packages_dir + '/').glob(file_type) + for archive in sorted(archives, key=lambda s: str(s).lower()): + log(os.path.join('packages', archive.name)) + myzip.write(str(archive.absolute()), archive.name) log('\nArchiving libraries') log('=======================')