Skip to content

Instantly share code, notes, and snippets.

@1am
Created December 20, 2025 16:02
Show Gist options
  • Select an option

  • Save 1am/ff3c08f963bb8658ed460a6321e532c5 to your computer and use it in GitHub Desktop.

Select an option

Save 1am/ff3c08f963bb8658ed460a6321e532c5 to your computer and use it in GitHub Desktop.
Linux Install ffmpeg build dependencies and compile ffmpeg from source with libsvtav1
#!/bin/bash
set -e
# Build script for ffmpeg with libsvtav1 support on Ubuntu
# Based on git tag: a1328e68877e12ab5a6e5d92a84aefa566783ea5
# As noted in https://wiki.seeedstudio.com/lerobot_so100m_new/ for Linux
# Tested on Ubuntu 24.04.1 LTS
echo "=== Installing ffmpeg build dependencies ==="
sudo apt-get update
sudo apt-get install -y \
build-essential \
git \
yasm \
cmake \
nasm \
libx264-dev \
libx265-dev \
libvpx-dev \
libfdk-aac-dev \
libmp3lame-dev \
libopus-dev \
libvorbis-dev \
libtheora-dev \
libxvidcore-dev \
libass-dev \
libfreetype6-dev \
libfontconfig1-dev \
libfribidi-dev \
libharfbuzz-dev \
libnuma-dev \
pkg-config \
autoconf \
automake \
libtool \
zlib1g-dev \
libssl-dev
echo "=== Creating build directory ==="
BUILD_DIR="$HOME/ffmpeg_build"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
echo "=== Cloning and building SVT-AV1 ==="
if [ ! -d "SVT-AV1" ]; then
git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git
fi
cd SVT-AV1
git checkout v2.3.0 # Use a stable version
cd Build
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
sudo ldconfig
cd "$BUILD_DIR"
echo "=== Cloning ffmpeg from specific tag ==="
if [ ! -d "ffmpeg" ]; then
git clone https://git.ffmpeg.org/ffmpeg.git
fi
cd ffmpeg
git fetch --all --tags
git checkout a1328e68877e12ab5a6e5d92a84aefa566783ea5
echo "=== Configuring ffmpeg with libsvtav1 support ==="
./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-libsvtav1 \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libtheora \
--enable-libxvid \
--enable-libass \
--enable-libfreetype \
--enable-libfontconfig \
--enable-libfribidi \
--enable-libharfbuzz \
--enable-openssl \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--enable-shared \
--enable-pic
echo "=== Building ffmpeg ==="
make -j$(nproc)
echo "=== Installing ffmpeg ==="
sudo make install
sudo ldconfig
echo "=== Verifying installation ==="
/usr/local/bin/ffmpeg -version
echo ""
echo "=== Checking for libsvtav1 support ==="
/usr/local/bin/ffmpeg -encoders | grep svtav1 || echo "Warning: svtav1 encoder not found"
/usr/local/bin/ffmpeg -decoders | grep av1 || echo "Warning: av1 decoder not found"
echo ""
echo "=== Cleaning up build directory ==="
rm -rf "$BUILD_DIR"
echo "Build directory removed: $BUILD_DIR"
echo ""
echo "=== Build complete! ==="
echo "ffmpeg binary location: $(which ffmpeg)"
echo "If you see /usr/bin/ffmpeg, you may need to update your PATH or use /usr/local/bin/ffmpeg directly"
# ============================================================================
# REVERTING FFMPEG PRECEDENCE
# ============================================================================
# This script installs ffmpeg to /usr/local/bin/ffmpeg, which typically takes
# precedence over the system ffmpeg (usually at /usr/bin/ffmpeg) because
# /usr/local/bin comes before /usr/bin in the default PATH.
#
# To revert back to using the system ffmpeg (e.g., Ubuntu's ffmpeg 7.6.1):
#
# Option 1: Remove the custom build (recommended if you want to completely remove it)
# sudo rm /usr/local/bin/ffmpeg /usr/local/bin/ffprobe /usr/local/bin/ffplay
# sudo rm -rf /usr/local/lib/libav* /usr/local/lib/libsw*
# sudo ldconfig
#
# Option 2: Rename the custom build (keeps it available but not in PATH)
# sudo mv /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg-custom
# sudo mv /usr/local/bin/ffprobe /usr/local/bin/ffprobe-custom
# sudo mv /usr/local/bin/ffplay /usr/local/bin/ffplay-custom
#
# Option 3: Adjust PATH priority (temporary, per-session)
# export PATH="/usr/bin:$PATH"
# Or make it permanent by editing ~/.bashrc or ~/.zshrc:
# echo 'export PATH="/usr/bin:$PATH"' >> ~/.zshrc
#
# Option 4: Use full path when needed
# /usr/bin/ffmpeg # Use system ffmpeg
# /usr/local/bin/ffmpeg # Use custom build with libsvtav1
#
# Verify which ffmpeg is being used:
# which ffmpeg
# ffmpeg -version
# ============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment