-
Notifications
You must be signed in to change notification settings - Fork 90
NVIDIA nvdec and nvenc plugins
Installation of nvdec (and nvenc) plugins from gstreamer1.0-plugins-bad, for GStreamer-1.16.x or earlier.
Since GStreamer-1.18.0, the NVIDIA nvcodec plugins have been shipped with GStreamer, but
before then, the NVIDIA plugins were named nvdec and nvenc, and
required three proprietary-header files from NVIDIA to be copied into the gst-plugins-bad source in order to be built.
These files
- cuviddec.h, nvcuvid.h (needed for nvdec plugin)
- nvEncodeAPI.h (needed for nvenc plugin).
are now released with a free-software license, and are now included with the gst-plugins-bad-1.16.x source code in gst-build/subprojects/gst-plugins-bad/sys/nvdec/ and gst-build/subprojects/gst-plugins-bad/sys/nvenc./. You can find them there in the 1.16.x release if you need to add them to these directories when building the plugins for older releases of GStreamer.
Because of this history, users of GStreamer-1.16.3 and earlier must build these plugins themselves. Here is the build procedure for 1.16.x; it may be more complicated for earlier versions. OpenSUSE-15.3 (1.16.3) or Ubuntu-16.04LTS (1.16.2) are examples of current distributions still using v 1.16.x.
First determine where the GStreamer plugins are installed on your system:
find / -name gstreamer-1.0
They will be in (path to)/gstreamer-1.0, where (path to) is something like /usr/lib (e.g., for 64-bit OS, /usr/lib64 on OpenSUSE, /usr/lib/x86_64-gnu-linux on Debian/Ubuntu, etc.). The Gstreamer development files may also need to be installed.
You should also make sure pkg-config is installed:
which pkg-config
If you need to install it, the package that supplies it may be called pkgconf, or pkgconfig.
Next Install NVIDIA's CUDA packages. These may be available through your package manager, or directly from NVIDIA. GStreamer-1.16.x requires a CUDA version 10.1 or earlier (Install CUDA-10.1). The GStreamer build process checks to see if CUDA with a version in this range is installed, using pkgconfig.
- if the CUDA pkgconfig files (cuda-10.1.pc, cudart-10.1.pc) are missing (as in a number of distributions, e.g. see here, where links to download the missing files are given), GStreamer will not find CUDA: this seems to be the case in Ubuntu-20.04LTS, where downloading and placing these files in the pkgconfig directory (/usr/lib/x86_64-linux-gnu/pkgconfig in the 64-bit OS) solves the problem. You can also place them somewhere else, and add
-Dpkg_config_path=...
in step 8 below, where...
is the path to the directory containing these files.
The GStreamer build process with (version) = 1.16.2 or 1.16.3, etc., is:
- (install required packages) meson flex bison
- git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git
- cd gst-build
- git checkout (version)
- meson build
- cd gst-plugins-bad
- meson build
- meson configure build -Dnvdec=enabled
- cd build
- ninja
- cd sys/nvdec
- strip libgstnvdec.so
- cp libgstnvdec.so (path to)/gstreamer-1.0
If step 10 fails because CUDA is not found, check that a required version is installed; also check that the pkgconfig files for CUDA are not missing (see earlier).
If step 10 fails because of missing wayland*.h files (these are expected to be in /usr/include but could be installed elsewhere, as in /usr/include/wayland on OpenSUSE15.3) , repeat step 8, with -Dwayland=disabled
. Alternatively,
find the wayland include files and copy them to either /usr/include, or gst-build/gst-plugins-bad/gst-libs/gst/wayland/. Then continue.
If you want to also build the nvenc plugin for encoding video,also add -Dnvenc=enabled
at step 8, and repeat steps 15-17 with "nvenc" replacing "nvdec".
For GStreamer-1.14 and earlier, the -D option at step 8 is not valid, and the maximum required version of CUDA is lower; you also need to obtain cuviddec.h and nvcuvid.h from GStreamer-1.16 or later and copy them into gst-build/subprojects/gst-plugins-bad/sys/nvdec/ (also copy nvEncodeAPI.h into gst-build/subprojects/gst-plugins-bad/sys/nvenc/ if you wish to build nvenc); this needs to be done after step 5.