Skip to content

Instantly share code, notes, and snippets.

@hekmon
Last active February 23, 2026 09:46
Show Gist options
  • Select an option

  • Save hekmon/b273e55139183370c5000f766fccc128 to your computer and use it in GitHub Desktop.

Select an option

Save hekmon/b273e55139183370c5000f766fccc128 to your computer and use it in GitHub Desktop.
ffmpeg w vmaf
# ffmpeg v8 with cuda 13.1 on Ubuntu 24.04 on WSL2 with optional support of CUDA for RTX 5000 series (SM_120)
# https://docs.nvidia.com/video-technologies/video-codec-sdk/13.0/ffmpeg-with-nvidia-gpu/index.html#compiling-for-linux
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
# https://developer.nvidia.com/cuda-downloads (if you want CUDA)
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-13-1
export PATH=/usr/local/cuda/bin:$PATH
# install required packages for compilation
sudo apt -y install autoconf automake build-essential cmake git-core libass-dev libc6 libc6-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libnuma1 libnuma-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo unzip wget yasm zlib1g-dev
# install nvidia codec headers (if you want CUDA)
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers && sudo make install && cd –
# prepare for ffmpeg build
mkdir -p ~/ffmpeg_sources ~/bin
sudo apt install nasm libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libopus-dev libdav1d-dev libunistring-dev libaom-dev
# AV1 encoder (we use v3 because v4 has issue with ffmpeg 8 : error: ‘EbSvtAv1EncConfiguration’ has no member named ‘enable_adaptive_quantization’)
cd ~/ffmpeg_sources && \
git -C SVT-AV1 pull 2> /dev/null || git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git && cd SVT-AV1 && git checkout v3.1.2 && \
mkdir -p build && cd build && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF .. && \
PATH="$HOME/bin:$PATH" make -j $(nproc) && \
make install
# VMAF
## meson utils for build configure
sudo apt install -y python3-pip && pip3 install --user meson
## vmaf lib
cd ~/'ffmpeg_sources' && git -C vmaf pull 2> /dev/null || git clone --depth 1 https://github.com/Netflix/vmaf.git && mkdir -p 'vmaf/libvmaf/build' && cd 'vmaf/libvmaf/build'
### Modifying the line from the ffmpeg guide to add -Denable_cuda=true and -Denable_avx512=true
### Remove -Denable_cuda=true if you do not build with CUDA support
meson setup -Denable_cuda=true -Denable_avx512=true -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static '..' --prefix "$HOME/ffmpeg_build" --libdir="$HOME/ffmpeg_build/lib" && ninja && ninja install
# clone ffmpeg source
cd ~/ffmpeg_sources && git clone https://github.com/FFmpeg/FFmpeg.git && cd FFmpeg && git checkout n8.0.1
# adapted line from ffmpeg guide and nvidia guide
## with CUDA support (120 is for RTX 5000 series)
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I/usr/local/cuda/include -I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L/usr/local/cuda/lib64 -L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--nvccflags="-gencode arch=compute_120,code=sm_120 -O2" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libdav1d \
--enable-libvmaf \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-cuda-nvcc \
--enable-static \
--disable-shared
## without CUDA support
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libdav1d \
--enable-libvmaf \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-static \
--disable-shared
## compile now
PATH="$HOME/bin:$PATH" make -j $(nproc) && make -j $(nproc) install && hash -r
ls "$HOME/bin/ffmpeg"
# Check build for VMAF support
export PATH="$HOME/bin:$PATH"
which ffmpeg
ffmpeg -filters | grep -i libvmaf # you should see libvmaf and libvmaf_cuda if compiled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment