ffmpeg
is no longer able to use your NVidia's card for hardware decode/encode after an OS or software upgrade, ensure your running X11/NV driver and the CUDA libraries are compatible otherwise you will get cryptic error messages:
$ ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda \
-c:v h264_cuvid -i 201231-163836.mkv \
-c:a copy \
-vf scale_npp=-1:720 \
-rc vbr_hq -c:v h264_nvenc \
-b:v 3M -minrate 500k -maxrate 12M \
output.mp4
...
failed call to cuInit: CUDA_ERROR_UNKNOWN: unknown error
Unable to create device
No device available for decoder: device type cuda needed for codec h264
Check your NV graphics driver and the CUDA libraries version are matching or compatible. I've not had great success with rpmfusion's CUDA pkg which is in sync with their NVidia driver so this may apply to manual installs only.Verify what CUDA drivers are available at CUDA toolkit archive and download and install the most recent but compatible toolkit for your graphics driver.
$ wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
In this example I'm using a 455.80.01 driver already. Whilst this CUDA library says that its using anything after the 455.32.00 driver this package will come with the driver too.Once the matchin CUDA drivers are installed, your installed
ffmpeg
will work again with hw accelerated encode and decode.If you want to rebuild
ffmpeg
along with the system installed ffmpeg, detailed instructions are available:
# get the nv headers
$ git clone https://github.com/FFmpeg/nv-codec-headers && cd nv-codec-headers && sudo make install
# get ffmpeg source
$ git clone https://git.ffmpeg.org/ffmpeg.git && cd ffmpeg && \
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig/ ./configure --prefix=/usr/local --sysconfdir=/etc \
--disable-debug \
--disable-shared --enable-static \
--enable-nonfree --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp \
--enable-libpulse \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags="-L/usr/local/cuda/lib64 -Wl,-rpath=/usr/local/cuda/lib64" && \
make -j install
No comments:
Post a Comment