Last active
December 1, 2025 03:21
-
-
Save thenadz/c2791d74a9ec47e014a1 to your computer and use it in GitHub Desktop.
Downloads & builds headless FFMPEG along with all dependencies in parallel, enabling all features
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| # Distro: Debian 13 | |
| # Derived from https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu | |
| # Builds the dependencies in parallel prior to starting FFmpeg build. | |
| apt-get update | |
| apt-get --no-install-recommends --no-install-suggests -y install \ | |
| autoconf automake nasm build-essential cmake unzip git-core ca-certificates \ | |
| libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libtool \ | |
| libopus-dev libdav1d-dev libvorbis-dev meson ninja-build \ | |
| pkg-config texinfo wget yasm zlib1g-dev libtheora-dev | |
| ROOT_DIR=$HOME/ffmpeg | |
| SRC_DIR=$ROOT_DIR/sources | |
| BUILD_DIR=$ROOT_DIR/build | |
| BIN_DIR=$HOME/bin | |
| rm -rf $ROOT_DIR | |
| mkdir -p $SRC_DIR | |
| mkdir -p $BUILD_DIR | |
| mkdir -p $BIN_DIR | |
| cd $SRC_DIR | |
| libx264() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| git -C x264 pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/x264.git && \ | |
| cd x264 && \ | |
| PATH="$BIN_DIR:$PATH" PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig" ./configure --prefix="$BUILD_DIR" --bindir="$BIN_DIR" --enable-static --enable-pic && \ | |
| PATH="$BIN_DIR:$PATH" make && \ | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libx265() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| wget -O- https://bitbucket.org/multicoreware/x265_git/get/master.tar.bz2 | tar xjv | |
| cd multicoreware*/build/linux | |
| PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$BUILD_DIR" -DENABLE_SHARED=off ../../source | |
| PATH="$BIN_DIR:$PATH" make | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libfdk_aac() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master | |
| unzip fdk-aac.zip | |
| cd mstorsjo-fdk-aac* | |
| autoreconf -fiv | |
| ./configure --prefix="$BUILD_DIR" --disable-shared | |
| make | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libvpx() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git | |
| cd libvpx | |
| PATH="$BIN_DIR:$PATH" ./configure --prefix="$BUILD_DIR" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm | |
| PATH="$BIN_DIR:$PATH" make | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libaom() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom | |
| mkdir -p aom_build | |
| cd aom_build | |
| PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$BUILD_DIR" -DENABLE_TESTS=OFF -DENABLE_NASM=on ../aom | |
| PATH="$BIN_DIR:$PATH" make | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libsvtav1() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| git -C SVT-AV1 pull 2> /dev/null || git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git | |
| mkdir -p SVT-AV1/build | |
| cd SVT-AV1/build | |
| PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF .. | |
| PATH="$BIN_DIR:$PATH" make | |
| make install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| libvmaf() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| git clone 'https://github.com/Netflix/vmaf' 'vmaf-master' | |
| mkdir -p 'vmaf-master/libvmaf/build' | |
| cd 'vmaf-master/libvmaf/build' | |
| meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static '../' --prefix "$BUILD_DIR" --bindir="$BIN_DIR" --libdir="$BUILD_DIR/lib" | |
| ninja | |
| ninja install | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| ffmpeg_download() { | |
| echo "STARTING ${FUNCNAME[0]}." | |
| cd $SRC_DIR | |
| wget -O- http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 | tar xjv | |
| echo "ENDING ${FUNCNAME[0]}." | |
| } | |
| # Build all components in parallel | |
| libx264 | |
| libx265 | |
| libvpx | |
| libfdk_aac | |
| libaom | |
| libsvtav1 | |
| libvmaf | |
| ffmpeg_download | |
| # ffmpeg | |
| echo "STARTING ffmpeg." | |
| cd $SRC_DIR/ffmpeg | |
| PATH="$BIN_DIR:$PATH" PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig" ./configure \ | |
| --prefix="$HOME/ffmpeg/build" \ | |
| --pkg-config-flags="--static" \ | |
| --extra-cflags="-I$BUILD_DIR/include" \ | |
| --extra-ldflags="-L$BUILD_DIR/lib" \ | |
| --extra-libs="-lpthread" \ | |
| --ld="g++" \ | |
| --bindir="$BIN_DIR" \ | |
| --enable-gpl \ | |
| --enable-gnutls \ | |
| --enable-libaom \ | |
| --enable-libass \ | |
| --enable-libfdk-aac \ | |
| --enable-libfreetype \ | |
| --enable-libmp3lame \ | |
| --enable-libopus \ | |
| --enable-libsvtav1 \ | |
| --enable-libdav1d \ | |
| --enable-libvorbis \ | |
| --enable-libvpx \ | |
| --enable-libx264 \ | |
| --enable-libx265 \ | |
| --enable-libvmaf \ | |
| --enable-nonfree | |
| PATH="$BIN_DIR:$PATH" make | |
| make install | |
| hash -r |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Latest update catches up with various changes to dependency build procedures over past few years. Introduces some debug logging. Removes
sudousages since assumption is we'll be within context of a container when running this build process.