See Nvidia FFMPEG install docs here. I had to modify their instructions slightly to avoid issues with A100 cards.
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers && sudo make install && cd –
git clone --branch release/7.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg/Add libx264-dev also to enable x264 support
sudo apt update && apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev libx264-dev
./configure --enable-nonfree --enable-cuda-nvcc --enable-libx264 --enable-gpl --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared
make -j 8
sudo make installMake sure to run this to make sure library paths are updated
sudo ldconfigThen to test (the examples in the Nvidia docs don't work)
ffmpeg -i example-001.mp4 -c:a copy -c:v libx264 -preset fast -b:v 5M example-001-out.mp4