Enable NVENC for FFMPEG

Reading time: 1 min

Based on this Article: https://www.cyberciti.biz/faq/how-to-install-ffmpeg-with-nvidia-gpu-acceleration-on-linux/

To enable NVENC to use the h264_nvenc encoder for example you have to compile ffmpeg yourself.

Requirements: You have installed the standard Nvidia drivers.

Use nvidia-detect to find the right driver for you.

If you want cuda support aswell install the nvidia-cuda-toolkit

Create a compilation directory:

Terminal window
mkdir ~/nvidia/ && cd ~/nvidia/ git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

\

Compile the missing headers (ffnvcodec):

Terminal window
cd nv-codec-headers && sudo make install

\

Download FFMPEG Source Code:

Terminal window
cd ~/nvidia/ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/`

\

Install the compilation tools:

Terminal window
sudo apt install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev`

\

Configure FFMPEG to compile with nvenc and cuda enabled. (You can remove the cuda flags if you only need nvenc):

Terminal window
PKG_CONFIG_PATH="~/nvidia/nv-codec-headers" ./configure --enable-nonfree --enable-cuda-nvcc --enable-cuda-llvm --enable-nvenc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64

\

Compile FFMPEG:

make -j $(nproc)

\

Now there should be a executeable created:

ls -l ffmpels -l ffmpe`g ./ffmpeg

\

If you want you can install this executable:

Terminal window
make install

\

Now you can use cuda hardware acceleration and the nvenc codec

Update:

Or just grab the latest release from Jellyfin ffmpeg:

[

Releases ยท jellyfin/jellyfin-ffmpeg

FFmpeg for Jellyfin. Contribute to jellyfin/jellyfin-ffmpeg development by creating an account on GitHub.

GitHubjellyfin

](โ€œhttps://github.com/jellyfin/jellyfin-ffmpeg/releasesโ€)