Compile FFmpeg 8.0 in Ubuntu with NVIDIA GPU Acceleration

Last updated: September 2, 2025 — Leave a comment

This is a step by step guide shows how to manually compile & install FFmpeg 8.0 from source with NVIDIA GPU acceleration support through cuda-nvcc and enable-libnpp in Ubuntu 24.04 & 22.04.

FFmpeg 8.0 so far is the latest version of this popular multi-media library, that features APV and ProRes RAW decoders, hardware accelerated VP9 and VVC encoding, and new Vulkan compute-based codecs support for FFv1 (encoding and decoding).

This tutorial is tested in Ubuntu 24.04 & 22.04, though it should also works in Debian, Linux Mint

Before Getting Started

FFmpeg now supports hardware accelerated NVENC encoding (AV1, H.264, HEVC) and NVDEC decoding (H.264, HEVC, MJPEG, MPEG-1/2/4, VP8/VP9, VC-1, AV1) through ffncodec, and scale_cuda filters to replace scale_npp.

They are usually enabled by default in FFmpeg packages from Ubuntu system repository or PPAs (e.g., my PPA and Rob Savoury’s PPA).

Meaning, you don’t need to build FFmpeg by yourself, just install it from one the previous sources, then you have the basic NVIDIA GPU acceleration support.

FFmpeg in Ubuntu & PPA repositories has nvenc & nvdec out-of-the-box

You ONLY need to follow this tutorial, when you need specific or more advanced CUDA-dependent features and/or scale_npp only filters.

And, you need:

  • a NVIDIA GPU that support NVENC/NVDEC (see the support list).
  • Install NVIDIA proprietary driver, though either Additional Drivers utility or ubuntu-drivers CLI tool. See the official guide.

Step 1: Install Nvidia Codec SDK headers

nv-codec-headers, the FFmpeg version of Nvidia Codec SDK headers, is available in Ubuntu repositories, but a bit old.

For the most recent version, press Ctrl+Alt+T on keyboard to clone the source code:

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

Run sudo apt install git to install git first, if you don’t have it.

Then, run the command below to navigate to the source folder, and install it:

cd nv-codec-headers && sudo make install

Step 2: Install Build Dependencies

To build the source, we need some dependency libraries.

First, run command in terminal (Ctrl+Alt+T) to install the essential dependency packages:

sudo apt install build-essential nasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev nvidia-cuda-toolkit pkg-config

For choice, you may install more via sudo apt install package-name (replace package-name) for more features, e.g.,

  • libvulkan-dev, for Vulkan compute-based hardware acceleration (the package in 22.04 is outdated).
  • libjxl-dev, for JPEG-XL support (the package is not available in 22.04).
  • libgme-dev, for Game Music Emu.
  • libvpx-dev, for VP8, VP9 decoding and encoding.

And, below are the packages I use for building FFmpeg into PPA:

libmp3lame-dev zlib1g-dev libvorbis-dev libsdl2-dev libxvidcore-dev liblzo2-dev texinfo libgcrypt-dev libx264-dev libtheora-dev libgsm1-dev libsnappy-dev libdc1394-dev libbs2b-dev libspeex-dev libopencore-amrwb-dev libfreetype-dev libopenmpt-dev nasm libopenjp2-7-dev libharfbuzz-dev libvdpau-dev libtesseract-dev libopencore-amrnb-dev libxfixes-dev libgl-dev libbz2-dev libssl-dev libass-dev libasound2-dev libva-dev libjack-jackd2-dev libvpx-dev frei0r-plugins-dev libvo-amrwbenc-dev libsctp-dev libopus-dev gnutls-dev frei0r-plugins-dev libsoxr-dev linux-libc-dev ladspa-sdk libaom-dev libfontconfig-dev libfdk-aac-dev libpulse-dev libzvbi-dev libiec61883-dev libavc1394-dev libleptonica-dev liblzma-dev libx265-dev libxext-dev libcaca-dev libopenh264-dev librubberband-dev libwebp-dev libgme-dev glslang-dev opencl-c-headers libshine-dev libfribidi-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libcdio-paranoia-dev libcodec2-dev ocl-icd-opencl-dev libzimg-dev libmysofa-dev libbluray-dev libzmq3-dev libaribb24-dev liblensfun-dev liblilv-dev flite1-dev librsvg2-dev libtwolame-dev libopenal-dev librabbitmq-dev libvulkan-dev libxavs2-dev libsrt-gnutls-dev libdavs2-dev libomxil-bellagio-dev libxml2-utils libsmbclient-dev libchromaprint-dev libunwind-dev libdvdnav-dev libdvdread-dev

Step 3: Compile & install FFmpeg 8.0

1. Download & extract the source

Now download FFmpeg 8.0 source tarball from its website, decompress, then right-click on extracted folder and choose “Open in Terminal” to open terminal with source folder as working directory.

open FFmpeg source folder in terminal

For Ubuntu server without GUI, run the command below to download the source:

wget https://ffmpeg.org/releases/ffmpeg-8.0.tar.xz

Then, decompress and navigate to the source folder:

tar -Jxf ffmpeg-8.0.tar.xz && cd ffmpeg-8.0

2. Configure the source

Now, configure the source by running command:

./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared

Here, you may add more configure options, e.g.,:

  • --enable-libvpx, need ‘libvpx-dev’ to be installed.
  • --enable-vulkan, need ‘libvulkan-dev’ to be installed.
  • --enable-libjxl, need ‘libjxl-dev’ to be installed.

And even more. See either configure file, or run ./configure --help to list more choices.

Configure the source

3. build & install FFmpeg

If configure is done without error, you may then run the command below to build it:

make -j4

Here j4 means to start 4 threads in parallel. You may replace it with j8, or even j16 depends on your CPU, or use -j$(nproc) to use all CPU cores.

build with ‘make’ command

If everything goes well, finally install FFmpeg by running command:

sudo make install

install ffmpeg via ‘make install’

Step 4: Verify

After installed FFmpeg, run the command below to print its version and configuration.

ffmpeg

If it said error while loading shared libraries, then run command to add /usr/local/lib as LD_LIBRARY_PATH environment variable, which works for current terminal session.

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

Or, write the command into end of .profile or .bashrc file in user home to make it permanent for current user.

Finally, try to transcode with GPU acceleration via command (replace input.mp4 with path to an existing media file):

ffmpeg -hwaccel cuda -i input.mp4 -vf scale_npp=-1:720 -c:v h264_nvenc -preset slow output.mkv

Uninstall:

To uninstall, open the source folder again in terminal and run command:

sudo make uninstall

If you’ve already deleted that folder, then manually remove the executable files from /usr/local/bin and libraries from /usr/local/lib:

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*