get ffmpeg sources and install build dependencies
mkdir ffmpeg-cuda
cd ffmpeg-cuda
apt-get source ffmpeg
sudo apt build-dep ffmpeg
patch the debian/rules to enable cuda (cuda dev packages need to be installed)
--- ffmpeg-3.4.2/debian/rules.orig 2018-03-18 00:08:00.717540941 +0100
+++ ffmpeg-3.4.2/debian/rules 2018-03-18 00:11:53.506937275 +0100
@@ -187,6 +187,8 @@
--target-os=$(DEB_HOST_ARCH_OS)
endif
+CONFIG += --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --enable-cuda-sdk
+
# Use the default debhelper scripts, where possible.
%:
dh $@
build it
cd ffmpeg-3.4.3
time nice dpkg-buildpackage -rfakeroot -uc -b -j5
the build will generate a bunch of *.deb files, they will conflict with the one installed by the system, so
mkdir install
for f in *.deb; do dpkg -x $f install; done
create a wrapper to use the built libraries (ffmpeg-cuda)
#!/bin/sh
export LD_LIBRARY_PATH=$INSTALL_PATH/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
exec $INSTALL_PATH/usr/bin/ffmpeg "$@"
use it to encode, for instance
ffmpeg-cuda -hwaccel cuvid -c:v h264_cuvid -i "$1" -vf scale_npp=1280:720 -c:v h264_nvenc "$2"
ffmpeg-cuda -i "$1" -c:v h264_nvenc "$2"