#!/usr/bin/env bash set -euo pipefail FFMPEG_VERSION="8.1.2" FFMPEG_SHA256="464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c" NASM_VERSION="2.16.03" NASM_SHA256="1412a1c760bbd05db026b6c0d1657affd6631cd0a63cddb6f73cc6d4aa616148" # Ubuntu 20.04 on purpose: it pins the .so to glibc 2.31, the same floor as docker/linux-builder and # therefore as the shipped AppImage. Building on anything newer produces libraries the AppImage cannot # load on the older distros we claim to support. BUILD_IMAGE="ubuntu:20.04" PLATFORM="linux/amd64" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DEST="${HERE}/ffmpeg" echo "===================================================" echo " Building LGPL ffmpeg ${FFMPEG_VERSION} (x86_64, decode-only)" echo " image: ${BUILD_IMAGE} (${PLATFORM})" echo " dest : ${DEST}" echo "===================================================" command -v docker >/dev/null || { echo "ERROR: docker not found"; exit 1; } rm -rf "$DEST" mkdir -p "$DEST" docker run --rm --platform "$PLATFORM" -v "${DEST}:/out" "$BUILD_IMAGE" bash -eu -c " export DEBIAN_FRONTEND=noninteractive apt-get update -qq apt-get install -y -qq --no-install-recommends ca-certificates curl xz-utils build-essential >/dev/null # 20.04 ships nasm 2.14, which chokes on ffmpeg 8's AVX macros (\"error: expecting ')'\" in # libswscale/x86/ops_float.asm). Build a current nasm rather than reaching for --disable-x86asm: that # would drop the SIMD decode paths and slow every frame down, on the machines least able to afford it. cd /tmp curl -sSL -o nasm.tar.xz https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz echo '${NASM_SHA256} nasm.tar.xz' | sha256sum -c - tar -xf nasm.tar.xz cd nasm-${NASM_VERSION} ./configure --prefix=/usr/local >/dev/null && make -j\$(nproc) >/dev/null && make install >/dev/null nasm -v cd /tmp curl -sSL -o ffmpeg.tar.xz https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz echo '${FFMPEG_SHA256} ffmpeg.tar.xz' | sha256sum -c - tar -xf ffmpeg.tar.xz cd ffmpeg-${FFMPEG_VERSION} # Same LGPL, decode-only configuration as the macOS build (see ../macos/build_ffmpeg.sh); only the # platform bits differ. Keep the two in step: a codec enabled on one platform and not the other is a # file that previews on a Mac and fails on Linux. ./configure \ --prefix=/tmp/stage \ --enable-shared \ --disable-static \ --enable-pic \ --disable-programs \ --disable-doc \ --disable-autodetect \ --disable-everything \ --disable-avdevice \ --disable-avfilter \ --disable-swresample \ --disable-network \ --disable-gpl \ --disable-nonfree \ --enable-decoder=h264,hevc,mjpeg,mjpegb \ --enable-parser=h264,hevc,mjpeg \ --enable-demuxer=mov,matroska,avi,flv,mpegts,h264,hevc,mjpeg,image2 \ --enable-protocol=file \ --enable-bsf=h264_mp4toannexb,hevc_mp4toannexb,extract_extradata \ >/tmp/configure.log 2>&1 || { tail -30 /tmp/configure.log; exit 1; } make -j\$(nproc) >/dev/null make install >/dev/null mkdir -p /out/include /out/lib cp -R /tmp/stage/include/* /out/include/ # Copy the real .so under its soname: the unversioned symlinks make install leaves behind do not # survive a git checkout, and the soname is what the loader actually resolves. for f in /tmp/stage/lib/*.so.*; do [ -L \"\$f\" ] && continue soname=\$(objdump -p \"\$f\" | awk '/SONAME/ {print \$2}') cp \"\$f\" \"/out/lib/\$soname\" done chmod -R a+rX /out chown -R \$(stat -c '%u:%g' /out) /out " echo "" echo "Verifying..." FAIL=0 for f in "${DEST}/lib/"*.so*; do [[ -f "$f" ]] || { echo "ERROR: no shared library produced"; exit 1; } done for f in "${DEST}/lib/"*.so*; do printf ' %-28s %s\n' "$(basename "$f")" "$(du -h "$f" | cut -f1)" done [[ "$FAIL" -eq 0 ]] || exit 1 echo "" echo "Done. Next: rebuild the AppImage and check that no libav* resolves outside the bundle."