Build FFmpeg with maximum static linking for all codecs, while keeping NVIDIA libraries dynamically linked (as required). This creates a highly portable FFmpeg binary with NVIDIA GPU acceleration support.
- ✅ Multi-Distro Support: "Works" on Debian, Ubuntu, RHEL, Fedora, CentOS, Arch Linux, openSUSE
- ✅ Static Linking: All codec libraries statically linked with
-fPICfor PIE compatibility - ✅ NVIDIA Support: CUDA, NVENC, CUVID hardware acceleration (10x+ realtime encoding)
- ✅ VAAPI Support: Intel/AMD hardware acceleration
- ✅ Latest Versions: FFmpeg 8.0.1, NASM 2.16.03, AOM 3.13.1, and latest stable codecs
- ✅ Production Ready: Tested with H.264 and HEVC NVENC encoding
- H.264/AVC: libx264 (software), h264_nvenc (NVIDIA), h264_vaapi (VAAPI)
- H.265/HEVC: libx265 (software), hevc_nvenc (NVIDIA), hevc_vaapi (VAAPI)
- VP8/VP9: libvpx
- AV1: libaom (software encoder/decoder), av1_nvenc (NVIDIA - RTX 40 series+)
- MP3: libmp3lame
- AAC: libfdk-aac
- Opus: libopus
- Vorbis: libvorbis
- Theora: libtheora
- Linux distribution with one of these package managers: apt, dnf, yum, pacman, or zypper
- NVIDIA GPU (optional, for NVENC support)
- NVIDIA drivers installed (optional, for GPU acceleration)
- Root/sudo access for installing dependencies
Run the master build script to build all components:
cd scripts
./build-all.shThis will:
- Install system dependencies
- Install NVIDIA CUDA toolkit
- Build all codec libraries
- Build FFmpeg with all features
- Run validation tests
You can also build components individually:
cd scripts
# Install dependencies
./dependencies.sh
# Install NVIDIA CUDA
./nv-cuda-sdk.sh
# Build assemblers
./nasm.sh
./yasm.sh
# Install NVIDIA codec headers
./nv-codec-header.sh
# Build video codecs
./x264.sh
./x265.sh
./libvpx.sh
./aom.sh
# Build audio codecs
./opus.sh
./lame.sh
./libfdk-aac.sh
# Build FFmpeg
./ffmpeg.sh
# Validate build
./validation.shEdit vars.sh to customize:
# Library versions
NASM_VERSION="3.01"
X264_BRANCH="master"
X265_VERSION="4.1"
VPX_VERSION="v1.15.2"
FFMPEG_VERSION="8.0.1"
# ... and more
# Build directories
WORK_DIR="/tmp/sources" # Where source files are downloaded
DEST_DIR="/usr/local" # Where FFmpeg will be installed
# CUDA location
CUDA_DIR="/usr/local/cuda"
# Enable CUDA validation tests
VALIDATE_CUDA="false" # Set to "true" to test CUDA encoding
# Library versions
NASM_VERSION="2.16.03" # Updated for AOM compatibility
X265_VERSION="4.1"
VPX_VERSION="v1.15.2"
AOM_VERSION="v3.13.1"
FFMPEG_VERSION="8.0.1"# Uses apt package manager
# Tested on Debian 12 (Bookworm) and Ubuntu 22.04/24.04# Uses dnf/yum package manager
# Tested on Fedora 39+ and RHEL 8/9If NVENC encoders are not available:
-
Check NVIDIA drivers:
nvidia-smi
-
Verify CUDA libraries:
ls -la /usr/local/cuda/lib64/libnvcuvid.so* -
Check FFmpeg NVENC support:
/usr/local/bin/ffmpeg -encoders | grep nvenc
If you get library errors:
# Update library cache
sudo ldconfig
# Check library paths
echo $LD_LIBRARY_PATH
ldd /usr/local/bin/ffmpegIf AOM build fails with NASM errors:
- NASM 2.16.03+ is required for AOM v3.13+
- The build scripts use the correct version
- Rebuild NASM:
sudo ./scripts/nasm.sh
If you get relocation errors during FFmpeg build:
- All static libraries must be built with
-fPIC - The scripts automatically add these flags
- Rebuild the failing library with:
sudo ./scripts/<library>.sh
# Uses pacman package manager
# Tested on Arch Linux (rolling release)# Uses zypper package manager
# Tested on openSUSE Leap/TumbleweedThe FFmpeg binary will be located at:
/usr/local/bin/ffmpegTo verify which libraries are statically vs dynamically linked:
ldd /usr/local/bin/ffmpegExpected dynamic dependencies:
linux-vdso.so.1(kernel interface)libcuda.so.1(NVIDIA CUDA)libnvcuvid.so.1(NVIDIA Video Decoder)libnvidia-encode.so.1(NVIDIA Encoder)- Standard system libraries (libc, libm, libpthread, libdl)
All codec libraries (x264, x265, vpx, opus, etc.) should NOT appear in the output.
Expected performance with NVENC (actual speeds vary by GPU):
- H.264 NVENC: 10-15x realtime @ 1080p
- HEVC NVENC: 8-12x realtime @ 1080p
- Power efficiency: ~90% less CPU usage vs software encoding
- Quality: Comparable to software encoding at higher bitrates
- libx264: 1-4x realtime (depends on preset)
- libx265: 0.5-2x realtime (slower but better compression)
- libaom-av1: 0.1-0.5x realtime (best compression, very slow)
# H.264 encoding with libx264
/usr/local/bin/ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 output.mp4
# H.265 encoding with libx265
/usr/local/bin/ffmpeg -i input.mp4 -c:v libx265 -preset medium -crf 28 output.mp4# H.264 NVENC encoding
/usr/local/bin/ffmpeg -i input.mp4 -c:v h264_nvenc -preset fast -b:v 5M output.mp4
# HEVC NVENC encoding
/usr/local/bin/ffmpeg -i input.mp4 -c:v hevc_nvenc -preset fast -b:v 5M output.mp4
# NVENC with hardware decoding
/usr/local/bin/ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -c:v h264_nvenc -preset fast output.mp4
/ffmpeg-static/bin/ffmpeg -i input.mp4 -c:v libx265 -preset medium -crf 28 output.mp4
# VP9 encoding
/ffmpeg-static/bin/ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M output.webm
# AV1 encoding
/ffmpeg-static/bin/ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M output.mp4# H.264 with NVENC
/ffmpeg-static/bin/ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc -preset p4 -b:v 5M output.mp4
# H.265 with NVENC
/ffmpeg-static/bin/ffmpeg -hwaccel cuda -i input.mp4 -c:v hevc_nvenc -preset p4 -b:v 5M output.mp4
# With CUDA hardware acceleration
/ffmpeg-static/bin/ffmpeg -vsync 0 -hwaccel cuda -hwaccel_output_format cuda \
-i input.mp4 -c:v h264_nvenc -b:v 5M output.mp4# H.264 with VAAPI
/ffmpeg-static/bin/ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
-i input.mp4 -c:v h264_vaapi -b:v 5M output.mp4
# H.265 with VAAPI
/ffmpeg-static/bin/ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
-i input.mp4 -c:v hevc_vaapi -b:v 5M output.mp4If you see CUDA-related errors during build:
-
Check CUDA installation:
ls -la /usr/local/cuda nvcc --version
-
Update
CUDA_DIRin vars.sh if CUDA is in a different location -
Ensure NVIDIA drivers are installed:
nvidia-smi
If your distribution isn't automatically detected:
- Check dependencies.sh for the list of required packages
- Install them manually using your package manager
- Continue with the build scripts
If a component fails to build:
- Check the error message
- Ensure all dependencies are installed
- Check if you have enough disk space (build requires ~5GB)
- Try building components individually to isolate the issue
Current Versions (as of January 2026):
- FFmpeg: 8.0.1
- x264: latest (master branch)
- x265: 4.1
- libvpx: 1.15.2
- AOM: 3.13.1
- NASM: 3.01
- NVIDIA Codec Headers: 13.0.19.0
This build script collection is provided as-is. Individual components (FFmpeg, x264, x265, etc.) have their own licenses:
- FFmpeg: GPL/LGPL (depending on configuration)
- x264: GPL
- x265: GPL
- libfdk-aac: Fraunhofer FDK AAC (check license restrictions)
- Others: See individual component licenses
To update versions, edit vars.sh and update the version variables.
Maintained by: Daniel Ramirez Based on FFmpeg static build practices for NVENC support.