I see support for nvidia NVENC in this document, but it seems confusing, some step by step? or PPA with ffmpeg-nvenc for ubuntu?


3 Answers 3


As always with FFmpeg continuing development shifts the goal posts many times and this is certainly true of nvenc and FFmpeg. There have been 3 phases:

  1. Roll your own: Pre August 27th 2016 it was necessary to track down your own headers to build nvenc. Arduous and more than a little confusing.
  2. Built into the source: August 27th 2016 saw the required headers incorporated as part of the FFmpeg source, nothing required but the ability to compile the FFmpeg source from git, or use a 'release' version cut from git at this time.
  3. Use nv-codec-headers: On February 26th 2018 the NVidia headers were removed from the FFmpeg source. A separate git repository was created to hold continuing work with these headers. At the moment these headers must be installed as well as FFmpeg from git to get access to nvenc and friends.

Two steps are required:

1. Install the nv-codec-headers package:

Something like the following Terminal commands should suffice:

sudo apt-get install make git
mkdir $HOME/nv-codec-headers_build && cd $HOME/nv-codec-headers_build
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make && sudo make install

If for some reason you change your mind and wish to completely remove the installed files as well as the build directory simply run the following two Terminal commands:

sudo rm -v /usr/local/{lib/pkgconfig/ffnvcodec.pc,include/ffnvcodec/*.h}
rm -rfv $HOME/nv-codec-headers_build

And your system has been cleaned. If however you wish to continue use the following step:

2. Compile FFmpeg:

Use this very well tested guide:

The nv-codec-headers will be automagically recognised (no extra ./configure options are needed) and nvenc will be successfully built.


I have tested this on Bionic Beaver LTS and the results are:

andrew@ilium:~$ ffmpeg -encoders 2>/dev/null | grep nvenc
 V..... h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V..... hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)

And if you see a similar picture as above, and you have a supported graphics card, you are right to go :)


  • The latest version corresponds to Video Codec SDK version 11.0.10 and requires NVidia drivers version 455.28 or newer.
  • Older versions: There is now an automated github copy of the nv-codec-headers which also creates tarballs perfect for using an older version of the headers. Great if you want the headers to sync with an older version of the NVidia drivers that you are unable or unwilling to update.
  • Hardware Acceleration Guide for FFmpeg: FFmpeg Wiki guide for hardware acceleration in general with FFmpeg, a canonical section for compiling and using nvenc...
  • 1
    Thanks so much for this detailed guide. I got similar output from your testing section, which is great. Aside from the nVidia drivers, do we also need to install the Cuda SDK to get FFMPEG to use the installed GPU? Apr 3, 2019 at 17:20
  • @KimberlyW Not required on my system, I have just now tested...
    – andrew.46
    Apr 3, 2019 at 22:03
  • @andrew.46 I did what you said but I still don't have the hardware acceleration for vp9 :/
    – Freedo
    May 17, 2019 at 8:36
  • @Freedo Unfortunately nvenc is for H.264 and HEVC encoding...
    – andrew.46
    May 17, 2019 at 8:50
  • 1
    @DPS Ouch!! But not the simple uninstall of the nv-codec-headers that I have given in this answer?
    – andrew.46
    Feb 4, 2020 at 7:51

Looks like that according to Focal's changelog that nv-codec-headers are now included.

ffmpeg (7:4.2.2-1ubuntu1) focal; urgency=medium

  • Build with external nv-codec-headers for NVENC accelerated video encoding. (LP: #1810649)

    • debian/control:
      • Add B-D libffmpeg-nvenc-dev
    • debian/rules:
      • Add --enable-nvenc for amd64 only

    -- Martin Wimpress Sat, 07 Mar 2020 08:39:35 +0000

  • Always a little sad when an answer such as mine starts to become obsolete :). I have voted up...
    – andrew.46
    Apr 7, 2020 at 1:49

@andrew.46 your response is great, thank you. My reputation is below the threshold to post this as a comment. If possible, please expand your response with the following information.

If you need to revert to an earlier version of nv-codec-headers, download and compile an earlier release from https://github.com/FFmpeg/nv-codec-headers/releases.

This may be necessary if you compile ffmpeg against latest nv-codec-headers, but your graphics driver is of a version that does not yet handle the minimum CUDA API version required by nv-codec-headers. The symptom will be that ffmpeg will fail transcoding video streams. In my case nv-codec-headers required CUDA API 9.1, while the latest nvidia-driver for my distribution (testing) was still at a version using 9.0.

Reverting to an earlier nv-codec-headers is probably safer than downloading the latest driver directly from Nvidia and building it outside of your distribution's update mechanism.

  • Thanks! I have added this in to the 'Notes' section...
    – andrew.46
    Jan 5, 2020 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.