Recompile ffmpeg with Cuda support on Debian

Tags:

Whenever I prepare the videos of the German Perl Workshop for release, I dread that my custom build of ffmpeg broke due to a Debian upgrade. Neither does happen often, the German Perl Workshop happens once every year, and a Debian upgrade maybe every two years. But still.

I'm in the process of preparing the videos of the 2026 German Perl Workshop, and it occurred to me that I can simply patch the Debian distribution and recompile it instead of cloning the ffmpeg repository and then hunting down the prerequisites etc. .

So, without further ado here is the process which the good folks at Debian already documented quite well:

Get the ffmpeg source

   apt source ffmpeg

Patch debian/rules

To append our new instructions, we need to edit the CONFIG command in debian/rules and append at the end of the stanza:

    --enable-nonfree         --enable-cuda-nvcc         --enable-libnpp         --extra-cflags=-I/usr/include/cuda         --extra-ldflags=-L/usr/lib/cuda         --cpu=native

Rebuild the package

debuild -b -uc -us

Install the patched version

sudo apt install ../ffmpeg_7.1.5-0+deb13u1_amd64.deb

Check that it works

/usr/bin/ffmpeg 2>&1 |grep -i cuda --color

This should list --enable-cuda-nvcc somewhere.