diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0efb7e..6fd575d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,147 +4,149 @@ on: push: paths-ignore: - '*.md' - pull_request: - branches: [ master ] jobs: - build-linux: - name: build in native linux - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 +# build-linux: +# name: build in native linux +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: install libva-dev +# run: | +# sudo apt-get update +# sudo apt-get install -y libva-dev +# +# - name: build ffmpeg +# run: | +# while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & +# SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build +# kill %1 +# - name: check shared library +# run: | +# ldd ./workspace/bin/ffmpeg +# - name: test run ffmepg +# run: | +# ./workspace/bin/ffmpeg -buildconf +# - name: clean up +# run: | +# ./build-ffmpeg --cleanup - - name: install libva-dev - run: | - sudo apt-get update - sudo apt-get install -y libva-dev +# build-macos: +# name: build in native macOS +# runs-on: macos-10.15 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: Use nodejs +# uses: actions/setup-node@v1 +# +# - name: build ffmpeg +# run: | +# while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & +# SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build +# kill %1 +# - name: check shared library +# run: | +# otool -L ./workspace/bin/ffmpeg +# - name: test run ffmepg +# run: | +# ./workspace/bin/ffmpeg -buildconf +# - name: clean up +# run: | +# ./build-ffmpeg --cleanup - - name: build ffmpeg - run: | - while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build - kill %1 - - name: check shared library - run: | - ldd ./workspace/bin/ffmpeg - - name: test run ffmepg - run: | - ./workspace/bin/ffmpeg -buildconf - - name: clean up - run: | - ./build-ffmpeg --cleanup - - build-macos: - name: build in native macOS - runs-on: macos-10.15 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: build ffmpeg - run: | - while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build - kill %1 - - name: check shared library - run: | - otool -L ./workspace/bin/ffmpeg - - name: test run ffmepg - run: | - ./workspace/bin/ffmpeg -buildconf - - name: clean up - run: | - ./build-ffmpeg --cleanup - - build-docker: - name: build in docker - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: pull base image - id: ubuntu_pull - run: | - docker pull ubuntu:20.04 - - name: run if ubuntu_pull failed - if: failure() && steps.ubuntu_pull.outcome == 'failure' - run: | - docker pull ubuntu:20.04 - - name: build ffmpeg - run: | - docker build -t ffmpeg:ubuntu -f Dockerfile . - - name: test run ffmepg - run: | - docker run --rm ffmpeg:ubuntu -buildconf - - build-cuda-ubuntu-docker: - name: build in ubuntu docker with cuda - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: pull base image - id: cuda_ubuntu_pull - run: | - docker pull nvidia/cuda:11.1-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 ubuntu:20.04 - - name: build ffmpeg - run: | - docker build -t ffmpeg:cuda-ubuntu -f cuda-ubuntu.dockerfile . - - name: test run ffmepg - run: | - docker run --rm ffmpeg:cuda-ubuntu -buildconf - - build-cuda-centos-docker: - name: build in centos docker with cuda - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: pull base image - id: cuda_centos_pull - run: | - docker pull nvidia/cuda:11.1-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 centos:8 - - name: build ffmpeg - run: | - docker build -t ffmpeg:cuda-centos -f cuda-centos.dockerfile . - - name: test run ffmepg - run: | - docker run --rm ffmpeg:cuda-centos -buildconf - - build-full-static: - name: full static build in docker - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: pull base image - id: cuda_ubuntu_pull - run: | - docker pull nvidia/cuda:11.1-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 - - name: build ffmpeg - run: | - docker build -t ffmpeg:cuda-static -f full-static.dockerfile . - - name: test run ffmepg - run: | - docker run --rm ffmpeg:cuda-static -buildconf \ No newline at end of file +# +# build-docker: +# name: build in docker +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: pull base image +# id: ubuntu_pull +# run: | +# docker pull ubuntu:20.04 +# - name: run if ubuntu_pull failed +# if: failure() && steps.ubuntu_pull.outcome == 'failure' +# run: | +# docker pull ubuntu:20.04 +# - name: build ffmpeg +# run: | +# docker build -t ffmpeg:ubuntu -f Dockerfile . +# - name: test run ffmepg +# run: | +# docker run --rm ffmpeg:ubuntu -buildconf +# +# build-cuda-ubuntu-docker: +# name: build in ubuntu docker with cuda +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: pull base image +# id: cuda_ubuntu_pull +# run: | +# docker pull nvidia/cuda:11.1-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 ubuntu:20.04 +# - name: build ffmpeg +# run: | +# docker build -t ffmpeg:cuda-ubuntu -f cuda-ubuntu.dockerfile . +# - name: test run ffmepg +# run: | +# docker run --rm ffmpeg:cuda-ubuntu -buildconf +# +# build-cuda-centos-docker: +# name: build in centos docker with cuda +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: pull base image +# id: cuda_centos_pull +# run: | +# docker pull nvidia/cuda:11.1-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 centos:8 +# - name: build ffmpeg +# run: | +# docker build -t ffmpeg:cuda-centos -f cuda-centos.dockerfile . +# - name: test run ffmepg +# run: | +# docker run --rm ffmpeg:cuda-centos -buildconf +# +# build-full-static: +# name: full static build in docker +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 +# +# - name: pull base image +# id: cuda_ubuntu_pull +# run: | +# docker pull nvidia/cuda:11.1-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 +# - name: build ffmpeg +# run: | +# docker build -t ffmpeg:cuda-static -f full-static.dockerfile . +# - name: test run ffmepg +# run: | +# docker run --rm ffmpeg:cuda-static -buildconf diff --git a/.gitignore b/.gitignore index 4725dcff..e2053e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ workspace .idea linux .artifacts +.DS_Store diff --git a/.node-version b/.node-version new file mode 100644 index 00000000..9cd25a1f --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +12.18.3 diff --git a/build-ffmpeg b/build-ffmpeg index b172de4c..6a6fe024 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.rc5 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -14,19 +14,33 @@ LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" CONFIGURE_OPTIONS=() +is_mac () { + if [[ "$OSTYPE" == "darwin"* ]]; then + return 0 + fi + + return 1 +} + +# read by gcc and cmake +# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html +export MACOSX_DEPLOYMENT_TARGET=10.11 + # Speed up the process # Env Var NUMJOBS overrides automatic detection if [[ -n "$NUMJOBS" ]]; then MJOBS="$NUMJOBS" elif [[ -f /proc/cpuinfo ]]; then MJOBS=$(grep -c processor /proc/cpuinfo) -elif [[ "$OSTYPE" == "darwin"* ]]; then +elif is_mac; then MJOBS=$(sysctl -n machdep.cpu.thread_count) CONFIGURE_OPTIONS=("--enable-videotoolbox") else MJOBS=4 fi +CONFIGURE_OPTIONS+=("--extra-version=beamcube") + make_dir () { remove_dir "$1" if ! mkdir "$1"; then @@ -142,6 +156,13 @@ library_exists () { return 0 } +set_mac_install_name () { + local name="${2:-$1}" + if is_mac; then + execute install_name_tool -id "${WORKSPACE}/lib/$name" $1 + fi +} + build_done () { touch "$PACKAGES/$1.done" } @@ -184,7 +205,7 @@ while (( $# > 0 )); do cleanup fi if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then - if [[ "$OSTYPE" == "darwin"* ]]; then + if is_mac; then echo "Error: A full static binary can only be build on Linux." exit 1 fi @@ -271,21 +292,16 @@ fi if build "zlib"; then download "https://www.zlib.net/zlib-1.2.11.tar.gz" - execute ./configure --static --prefix="${WORKSPACE}" + execute ./configure --shared --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.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 - - build_done "openssl" +if build "meson"; then + execute python3 -m pip install meson ninja + build_done "meson" fi -CONFIGURE_OPTIONS+=("--enable-openssl") if build "cmake"; then download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" @@ -304,9 +320,9 @@ if build "x264"; then download "https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.bz2" if [[ "$OSTYPE" == "linux-gnu" ]]; then - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic CXXFLAGS="-fPIC" + execute ./configure --prefix="${WORKSPACE}" --enable-shared --enable-pic CXXFLAGS="-fPIC" else - execute ./configure --prefix="${WORKSPACE}" --enable-static --enable-pic + execute ./configure --prefix="${WORKSPACE}" --enable-shared --enable-pic fi execute make -j $MJOBS @@ -320,8 +336,11 @@ 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 cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=on -DBUILD_SHARED_LIBS=on ../../source execute make -j $MJOBS + + set_mac_install_name "libx265.198.dylib" + execute make install if [ -n "$LDEXEFLAGS" ]; then @@ -335,14 +354,21 @@ 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" - if [[ "$OSTYPE" == "darwin"* ]]; then + EXTRA_FLAG="" + + if is_mac; 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 + EXTRA_FLAG="--target=x86_64-darwin15-gcc" fi - execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --disable-shared --as=yasm + + execute ./configure --prefix="${WORKSPACE}" --disable-unit-tests --enable-shared --disable-static --as=yasm "${EXTRA_FLAG}" execute make -j $MJOBS + + set_mac_install_name "libvpx.6.dylib" + execute make install build_done "libvpx" @@ -352,7 +378,7 @@ 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 ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install @@ -370,27 +396,64 @@ 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" - execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DUSE_OMP=OFF -DENABLE_SHARED=off . + execute cmake -DBUILD_SHARED_LIBS=on -DCMAKE_INSTALL_PREFIX:PATH="${WORKSPACE}" -DUSE_OMP=OFF -DENABLE_SHARED=on . execute make execute make install + set_mac_install_name "${WORKSPACE}/lib/libvidstab.1.1.dylib" "libvidstab.1.1.dylib" + build_done "vid_stab" fi CONFIGURE_OPTIONS+=("--enable-libvidstab") +if build "twolame"; 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" +fi +CONFIGURE_OPTIONS+=("--enable-libtwolame") + if build "av1"; then download "https://aomedia.googlesource.com/aom/+archive/430d58446e1f71ec2283af0d6c1879bc7a3553dd.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 + execute cmake -DBUILD_SHARED_LIBS=1 -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib "$PACKAGES"/av1 execute make -j $MJOBS + + set_mac_install_name "libaom.2.0.0.dylib" "libaom.2.dylib" + execute make install build_done "av1" fi CONFIGURE_OPTIONS+=("--enable-libaom") +if build "dav1d"; then + download "https://code.videolan.org/videolan/dav1d/-/archive/0.7.1/dav1d-0.7.1.tar.gz" + make_dir "$PACKAGES"/dav1d_build + cd "$PACKAGES"/dav1d_build || exit + execute meson --prefix="${WORKSPACE}" ../dav1d-0.7.1 + execute ninja + execute ninja install + + build_done "dav1d" +fi +CONFIGURE_OPTIONS+=("--enable-libdav1d") + +if build "zimg"; then + download "https://github.com/sekrit-twc/zimg/archive/release-3.0.1.tar.gz" + execute autoreconf -i + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static + execute make -j $MJOBS + execute make install + + build_done "zimg" +fi +CONFIGURE_OPTIONS+=("--enable-libzimg") ## ## audio library @@ -398,7 +461,7 @@ CONFIGURE_OPTIONS+=("--enable-libaom") if build "opencore"; 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 ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install @@ -408,7 +471,9 @@ CONFIGURE_OPTIONS+=("--enable-libopencore_amrnb" "--enable-libopencore_amrwb") if build "lame"; 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 + sed "/lame_init_old/d" include/libmp3lame.sym > include/libmp3lame.sym.patched + mv include/libmp3lame.sym.patched include/libmp3lame.sym + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install @@ -418,7 +483,7 @@ CONFIGURE_OPTIONS+=("--enable-libmp3lame") if build "opus"; then download "https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install @@ -428,7 +493,7 @@ CONFIGURE_OPTIONS+=("--enable-libopus") if build "libogg"; 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 ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install build_done "libogg" @@ -436,7 +501,7 @@ fi if build "libvorbis"; 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 + OGG_CFLAGS="-I${WORKSPACE}/include/ogg" OGG_LIBS="-L${WORKSPACE}/lib -logg" execute ./configure --prefix="${WORKSPACE}" --with-ogg-libraries="${WORKSPACE}"/lib --with-ogg-includes="${WORKSPACE}"/include/ --disable-static --enable-shared --disable-oggtest execute make -j $MJOBS execute make install @@ -449,7 +514,7 @@ if build "libtheora"; 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 + OGG_CFLAGS="-I${WORKSPACE}/include/ogg" OGG_LIBS="-L${WORKSPACE}/lib -logg" 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 execute make -j $MJOBS execute make install @@ -457,16 +522,38 @@ if build "libtheora"; then 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 +if build "shine"; 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 "fdk_aac" + build_done "shine" fi -CONFIGURE_OPTIONS+=("--enable-libfdk-aac") +CONFIGURE_OPTIONS+=("--enable-libshine") + +if build "soxr"; 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" +fi +CONFIGURE_OPTIONS+=("--enable-libsoxr") + +if build "speex"; 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" +fi +CONFIGURE_OPTIONS+=("--enable-libspeex") ## ## image library @@ -476,7 +563,7 @@ 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 cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include -DENABLE_SHARED=ON -DENABLE_STATIC=OFF ../ execute make -j $MJOBS execute make install @@ -484,6 +571,18 @@ if build "libwebp"; then fi CONFIGURE_OPTIONS+=("--enable-libwebp") +if build "openjpeg"; 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" +fi +CONFIGURE_OPTIONS+=("--enable-libopenjpeg") + ## ## other library @@ -491,29 +590,36 @@ CONFIGURE_OPTIONS+=("--enable-libwebp") if build "libsdl"; then download "https://www.libsdl.org/release/SDL2-2.0.12.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static + execute ./configure --prefix="${WORKSPACE}" --enable-shared --disable-static execute make -j $MJOBS execute make install 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 build "snappy"; 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 [ -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 + set_mac_install_name "libsnappy.1.1.8.dylib" "libsnappy.1.dylib" + + execute make install - build_done "srt" + build_done "snappy" fi -CONFIGURE_OPTIONS+=("--enable-libsrt") +CONFIGURE_OPTIONS+=("--enable-libsnappy") +if build "xz"; 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" +fi ## ## HWaccel library @@ -562,12 +668,10 @@ download "https://ffmpeg.org/releases/ffmpeg-4.3.1.tar.bz2" ./configure "${CONFIGURE_OPTIONS[@]}" \ --disable-debug \ --disable-doc \ - --disable-shared \ + --disable-static \ --enable-gpl \ - --enable-nonfree \ --enable-pthreads \ - --enable-static \ - --enable-small \ + --enable-shared \ --enable-version3 \ --extra-cflags="${CFLAGS}" \ --extra-ldexeflags="${LDEXEFLAGS}" \ @@ -581,7 +685,7 @@ execute make -j $MJOBS execute make install INSTALL_FOLDER="/usr/bin" -if [[ "$OSTYPE" == "darwin"* ]]; then +if is_mac; then INSTALL_FOLDER="/usr/local/bin" fi @@ -597,12 +701,12 @@ 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" - sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + 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" - sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" + sudo cp "$WORKSPACE/bin/ffplay" "$INSTALL_FOLDER/ffplay" echo "Done. FFmpeg is now installed to your system." fi elif [[ ! "$SKIPINSTALL" == "yes" ]]; then @@ -612,15 +716,22 @@ 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." ;; esac fi +cd $CWD +if is_mac; then + node copy_mac_libs.js + cd "$WORKSPACE/mac" + execute zip --symlinks -r "ffmpeg-ffprobe-shared-darwin-x86_64.${VERSION}.zip" * +fi + exit 0 diff --git a/config-target.txt b/config-target.txt new file mode 100644 index 00000000..12edcbef --- /dev/null +++ b/config-target.txt @@ -0,0 +1,48 @@ +❌ 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 diff --git a/copy_mac_libs.js b/copy_mac_libs.js new file mode 100644 index 00000000..2edd9c93 --- /dev/null +++ b/copy_mac_libs.js @@ -0,0 +1,99 @@ +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 ${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}`); +}