{"id":49594,"date":"2025-09-02T13:44:42","date_gmt":"2025-09-02T13:44:42","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=49594"},"modified":"2025-09-02T13:44:42","modified_gmt":"2025-09-02T13:44:42","slug":"compile-ffmpeg-8-0-in-ubuntu-with-nvidia-gpu-acceleration","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2025\/09\/compile-ffmpeg-8-0-in-ubuntu-with-nvidia-gpu-acceleration\/","title":{"rendered":"Compile FFmpeg 8.0 in Ubuntu with NVIDIA GPU Acceleration"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-37497\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/ffmpeg-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><b>This is a step by step guide shows how to manually compile &amp; install FFmpeg 8.0 from source with NVIDIA GPU acceleration support through <code>cuda-nvcc<\/code> and <code>enable-libnpp<\/code> in Ubuntu 24.04 &amp; 22.04.<\/b><\/p>\n<p><a href=\"https:\/\/ffmpeg.org\/index.html#news\" target=\"_blank\" rel=\"noopener\">FFmpeg 8.0<\/a> 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).<\/p>\n<p><!--more--><\/p>\n<p><b>This tutorial is tested in Ubuntu 24.04 &amp; 22.04, though it should also works in Debian, Linux Mint<\/b><\/p>\n<h3>Before Getting Started<\/h3>\n<p>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 <code>ffncodec<\/code>, and <code>scale_cuda<\/code> filters to replace <code>scale_npp<\/code>.<\/p>\n<p>They are usually enabled by default in FFmpeg packages from Ubuntu system repository or PPAs (e.g., <a href=\"https:\/\/launchpad.net\/~ubuntuhandbook1\/+archive\/ubuntu\/ffmpeg8\" target=\"_blank\" rel=\"noopener\">my PPA<\/a> and <a href=\"https:\/\/launchpad.net\/~savoury1\/+archive\/ubuntu\/ffmpeg8\" target=\"_blank\" rel=\"noopener\">Rob Savoury&#8217;s PPA<\/a>).<\/p>\n<p><b>Meaning, you don&#8217;t need to build FFmpeg by yourself, just install it from one the previous sources, then you have the basic NVIDIA GPU acceleration support.<\/b><\/p>\n<div id=\"attachment_49595\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49595\" class=\"size-large wp-image-49595\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/ffmpeg-nvenc-700x380.webp\" alt=\"\" width=\"610\" height=\"331\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/ffmpeg-nvenc-700x380.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/ffmpeg-nvenc-300x163.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/ffmpeg-nvenc-768x417.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/ffmpeg-nvenc.webp 972w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><p id=\"caption-attachment-49595\" class=\"wp-caption-text\">FFmpeg in Ubuntu &amp; PPA repositories has nvenc &amp; nvdec out-of-the-box<\/p><\/div>\n<p>You ONLY need to follow this tutorial, when you need specific or more advanced CUDA-dependent features and\/or <code>scale_npp<\/code> only filters.<\/p>\n<p>And, you need:<\/p>\n<ul>\n<li>a <b>NVIDIA GPU that support NVENC\/NVDEC<\/b> (see the <a href=\"https:\/\/developer.nvidia.com\/video-encode-and-decode-gpu-support-matrix-new\" target=\"_blank\" rel=\"noopener\">support list<\/a>).<\/li>\n<li>Install <b>NVIDIA proprietary driver<\/b>, though either Additional Drivers utility or <code>ubuntu-drivers<\/code> CLI tool. See the <a href=\"https:\/\/documentation.ubuntu.com\/server\/how-to\/graphics\/install-nvidia-drivers\/index.html\" target=\"_blank\" rel=\"noopener\">official guide<\/a>.<\/li>\n<\/ul>\n<h3>Step 1: Install Nvidia Codec SDK headers<\/h3>\n<p><code>nv-codec-headers<\/code>, the FFmpeg version of Nvidia Codec SDK headers, is available in Ubuntu repositories, but a bit old.<\/p>\n<p>For the most recent version, press <code>Ctrl+Alt+T<\/code> on keyboard to clone the source code:<\/p>\n<pre>git clone https:\/\/git.videolan.org\/git\/ffmpeg\/nv-codec-headers.git<\/pre>\n<p><i>Run <code>sudo apt install git<\/code> to install git first, if you don&#8217;t have it.<\/i><\/p>\n<p>Then, run the command below to navigate to the source folder, and install it:<\/p>\n<pre>cd nv-codec-headers &amp;&amp; sudo make install<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49596\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/build-nv-headers-700x373.webp\" alt=\"\" width=\"610\" height=\"325\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/build-nv-headers-700x373.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/build-nv-headers-300x160.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/build-nv-headers-768x409.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/build-nv-headers.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h3>Step 2: Install Build Dependencies<\/h3>\n<p>To build the source, we need some dependency libraries.<\/p>\n<p>First, run command in terminal (Ctrl+Alt+T) to <b>install the essential dependency packages<\/b>:<\/p>\n<pre>sudo apt install build-essential nasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev nvidia-cuda-toolkit pkg-config<\/pre>\n<p>For choice, you may install more via <code>sudo apt install package-name<\/code> (replace <code>package-name<\/code>) for more features, e.g.,<\/p>\n<ul>\n<li><code>libvulkan-dev<\/code>, for Vulkan compute-based hardware acceleration (the package in 22.04 is outdated).<\/li>\n<li><code>libjxl-dev<\/code>, for JPEG-XL support (the package is not available in 22.04).<\/li>\n<li><code>libgme-dev<\/code>, for Game Music Emu.<\/li>\n<li><code>libvpx-dev<\/code>, for VP8, VP9 decoding and encoding.<\/li>\n<\/ul>\n<p>And, below are the packages I use for building FFmpeg into PPA:<\/p>\n<pre>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<\/pre>\n<h3>Step 3: Compile &amp; install FFmpeg 8.0<\/h3>\n<h4>1. Download &amp; extract the source<\/h4>\n<p>Now download FFmpeg 8.0 source tarball from <a href=\"https:\/\/ffmpeg.org\/\" target=\"_blank\" rel=\"noopener\">its website<\/a>, decompress, then right-click on extracted folder and choose &#8220;Open in Terminal&#8221; to open terminal with source folder as working directory.<\/p>\n<div id=\"attachment_49597\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49597\" class=\"size-large wp-image-49597\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/open-ffmpeg-terminal-700x431.webp\" alt=\"\" width=\"610\" height=\"376\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/open-ffmpeg-terminal-700x431.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/open-ffmpeg-terminal-300x185.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/open-ffmpeg-terminal-768x473.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/open-ffmpeg-terminal.webp 1007w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><p id=\"caption-attachment-49597\" class=\"wp-caption-text\">open FFmpeg source folder in terminal<\/p><\/div>\n<p>For Ubuntu server without GUI, run the command below to download the source:<\/p>\n<pre>wget https:\/\/ffmpeg.org\/releases\/ffmpeg-8.0.tar.xz<\/pre>\n<p>Then, decompress and navigate to the source folder:<\/p>\n<pre>tar -Jxf ffmpeg-8.0.tar.xz &amp;&amp; cd ffmpeg-8.0<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49600\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/wget-ffmpeg8-700x398.webp\" alt=\"\" width=\"610\" height=\"347\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/wget-ffmpeg8-700x398.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/wget-ffmpeg8-300x170.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/wget-ffmpeg8.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h4>2. Configure the source<\/h4>\n<p>Now, configure the source by running command:<\/p>\n<pre>.\/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<\/pre>\n<p>Here, you may add more configure options, e.g.,:<\/p>\n<ul>\n<li><code>--enable-libvpx<\/code>, need &#8216;libvpx-dev&#8217; to be installed.<\/li>\n<li><code>--enable-vulkan<\/code>, need &#8216;libvulkan-dev&#8217; to be installed.<\/li>\n<li><code>--enable-libjxl<\/code>, need &#8216;libjxl-dev&#8217; to be installed.<\/li>\n<\/ul>\n<p>And even more. See either <code>configure<\/code> file, or run <code>.\/configure --help<\/code> to list more choices.<\/p>\n<div id=\"attachment_49601\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49601\" class=\"size-large wp-image-49601\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/configure-ffmpeg8-nv-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/configure-ffmpeg8-nv-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/configure-ffmpeg8-nv-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/configure-ffmpeg8-nv-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/configure-ffmpeg8-nv.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><p id=\"caption-attachment-49601\" class=\"wp-caption-text\">Configure the source<\/p><\/div>\n<h4>3. build &amp; install FFmpeg<\/h4>\n<p>If configure is done without error, you may then run the command below to build it:<\/p>\n<pre>make -j4<\/pre>\n<p>Here <code>j4<\/code> means to start 4 threads in parallel. You may replace it with <code>j8<\/code>, or even <code>j16<\/code> depends on your CPU, or use <code>-j$(nproc)<\/code> to use all CPU cores.<\/p>\n<div id=\"attachment_49602\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49602\" class=\"size-large wp-image-49602\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-ffmpeg8-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-ffmpeg8-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-ffmpeg8-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-ffmpeg8-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-ffmpeg8.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><p id=\"caption-attachment-49602\" class=\"wp-caption-text\">build with &#8216;make&#8217; command<\/p><\/div>\n<p>If everything goes well, finally install FFmpeg by running command:<\/p>\n<pre>sudo make install<\/pre>\n<div id=\"attachment_49603\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-49603\" class=\"size-large wp-image-49603\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-install-ffmpeg8-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-install-ffmpeg8-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-install-ffmpeg8-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-install-ffmpeg8-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/make-install-ffmpeg8.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><p id=\"caption-attachment-49603\" class=\"wp-caption-text\">install ffmpeg via &#8216;make install&#8217;<\/p><\/div>\n<h3>Step 4: Verify<\/h3>\n<p>After installed FFmpeg, run the command below to print its version and configuration.<\/p>\n<pre>ffmpeg<\/pre>\n<p>If it said error while loading shared libraries, then run command to add <code>\/usr\/local\/lib<\/code> as LD_LIBRARY_PATH environment variable, which works for current terminal session.<\/p>\n<pre>export LD_LIBRARY_PATH=\"\/usr\/local\/lib:$LD_LIBRARY_PATH\"<\/pre>\n<p>Or, write the command into end of <code>.profile<\/code> or <code>.bashrc<\/code> file in user home to make it permanent for current user.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49604\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/verify-ffmpeg8-700x554.webp\" alt=\"\" width=\"610\" height=\"483\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/verify-ffmpeg8-700x554.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/verify-ffmpeg8-300x237.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/verify-ffmpeg8-768x608.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/verify-ffmpeg8.webp 810w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<p>Finally, try to transcode with GPU acceleration via command (replace <code>input.mp4<\/code> with path to an existing media file):<\/p>\n<pre>ffmpeg -hwaccel cuda -i input.mp4 -vf scale_npp=-1:720 -c:v h264_nvenc -preset slow output.mkv<\/pre>\n<h3>Uninstall:<\/h3>\n<p>To uninstall, open the source folder again in terminal and run command:<\/p>\n<pre>sudo make uninstall<\/pre>\n<p>If you&#8217;ve already deleted that folder, then manually remove the executable files from <code>\/usr\/local\/bin<\/code> and libraries from <code>\/usr\/local\/lib<\/code>:<\/p>","protected":false},"excerpt":{"rendered":"<p>This is a step by step guide shows how to manually compile &amp; install FFmpeg 8.0 from source with NVIDIA GPU acceleration support through cuda-nvcc and enable-libnpp in Ubuntu 24.04 &amp; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37497,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[594],"class_list":["post-49594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-ffmpeg"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/49594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=49594"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/49594\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/37497"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=49594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=49594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=49594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}