I`m trying to compile ffmpeg in windows with nvidia libraries for hardware acceleration using MinGW/msys. tried to follow the instruction on nvidias website (section: Getting Started with FFmpeg/libav using NVIDIA GPUs). configured with --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-Ilocal/include --extra-cflags=-I../common/inc --extra-ldflags=-L../common/lib/x64 --prefix=ffmpeg but stopped at "ERROR: libnpp not found." where common folder is downloaded from NVIDIA Video Codec SDK but there is no npp libs or header files. is there any solution for that? thanks for edvice.
-
Go and download the CUDA toolkit. NPP is distributed as part of that – talonmies Jan 26 '17 at 10:36
-
Or just don't build with NPP support – talonmies Jan 26 '17 at 10:57
-
I have already tried it. installed cuda toolkit, found npp libs and headers and copied them to common/lib/x64 and common/inc folders but still not works... – Gio Jan 26 '17 at 11:43
I managed to successfuly cross compile ffmpeg under linux targeting Windows 64 bit with --enable-libnpp included.
My environment is Ubuntu Server 16.10 64bit.
After a fresh installation I installed MinGW using the command:
sudo apt-get install mingw-w64
First I successfully compiled the Linux version with the --enable-libnpp option activated following the instructions on the NVIDIA dev site Compile Ffmpeg with NVIDIA Video Codec SDK.
In order to do that you need to install the CUDA Toolkit. Just follow the instructions and the package installer will create the symbolic links (I have the CUDA Toolkit 8.0):
/usr/local/cuda/include/ -> /usr/local/cuda-8.0/targets/x86_64-linux/include
/usr/local/cuda/lib64/ -> /usr/local/cuda-8.0/targets/x86_64-linux/lib
This should provide Configure the right path to find the correct libraries and headers.
The command line I have used to compile the linux version of ffmpeg is:
./configure --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/
The problem you got is that when using cross-compilation you need to provide Configure the right path where to find headers and library for the Windows version of the libnpp library.
From the CUDA Toolkit Download page mentioned above I simply downloaded the exe(local) version of the Windows package.
Under the root of my working folder I created a folder called tmp where I copied the subfolders I found under npp_dev inside the package cuda_8.0.61_win10.exe:
cuda_8.0.61_win10.exe\npp_dev\lib -> tmp/lib
cuda_8.0.61_win10.exe\npp_dev\include -> tmp/include
As final step I launched Configure once again using the following parameters:
./configure --arch=x86_64 --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --pkg-config=pkg-config --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/include --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --extra-cflags=-I../tmp/include/ --extra-ldflags=-L../tmp/lib/x64/
The compilation completed successully. When I copied the ffmpeg.exe file to Windows and tried to execute it I got an errore message saying the executable was missing some npp_*.dll.
From the package cuda_8.0.61_win10.exe I copied all the dlls included into the folder npp\bin to the same directory I put ffmpeg.exe.
After that the application run normally and a simple conversion from a 4K file completed as expected.
-
on Ubuntu you should use
dpkg-query -L cuda-npp-dev-10-0(or your NPP package name) to figure out which paths are the NPP include and lib directories – cat Jan 14 '19 at 3:47
Actually I went nuts about ffmpeg is not building with the same problem. I fianally managed to get it worked under Windows 10 x64:
- Download msys2 from https://www.msys2.org/ and install all packages with Pacman
pacman -Supacman -S makepacman -S diffutilspacman -S yasmpacman -S mingw-w64-x86_64-gccpacman -S mingw-w64-x86_64-toolchain- Maybe optional step: add pkgconfig to environment variable
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig - Add additional installed toolchain to path:
PATH=$PATH:/opt/bin
- Download and install Cuda from nVidia https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exenetwork
Copy nVidia files
- Search on your harddisk for nvcc include directory e.g.
C:\Program Files\NVIDIA Corporation\Installer2\nvcc_10.1.{542BC78D-DEB7-47AA-B531-BA67A40AB678}\includeand copy files to your msys2 e.g.C:\msys64\tmp\nvidia_include - Search on your harddisk for npp_dev lib directory e.g.
C:\Program Files\NVIDIA Corporation\Installer2\npp_dev_10.1.{00719503-CFFE-40D7-A2A6-7108A2AE59B5}\lib\x64and copy lib\x64 to yourC:\msys64\tmp\nvidia_lib\x64 - Search on your harddisk for npp_dev include e.g.
C:\Program Files\NVIDIA Corporation\Installer2\npp_dev_10.1.{00719503-CFFE-40D7-A2A6-7108A2AE59B5}\includeand copy include toC:\msys64\tmp\nvidia_npp_include
- Search on your harddisk for nvcc include directory e.g.
git clone https://git.ffmpeg.org/ffmpeg.gittoC:\msys64\home\<user>git clone https://github.com/libav/libavtoC:\msys64\home\<user>- Maybe optional step:
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.gittoC:\msys64\home\<user>makemake install- Copy ffnvcodec.pc to
C:\msys64\usr\local\lib\pkgconfig
- Build libav
avconv.exeandavprobe.exeare needed for ffmpeg later:cd C:\msys64\home\<user>\libav./configuremakemake install
- Finally build ffmpeg:
cd C:\msys64\home\<user>\ffmpeg./configure --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/tmp/nvidia_npp_include --extra-cflags=-I/tmp/nvidia_include --extra-ldflags=-L/tmp/nvidia_lib/x64makemake install- Copy
avconv.exeandavprobe.exeto ffmpeg directory
Done.
Bugfixing:
- Missing DLLs: find x64 missing DLLs on your harddisk or in internet.
- Use dependency walker for analyzing errors
- Download the newest nVidia drivers and use nSight making sure CUVID is supported for your graphic card.
-
Thanks for putting this together, I went through all stages but was not able to resolve all the nVidia files in section 3, as the new 11.1 offering has moved the files around (I downloaded and installed the local installation not the network one, hope that wasn't the issue!). So the exact directories required were not there, and I think that derailed my attempt. – topspeed Nov 18 '20 at 14:32
This would seem to be caused by a broken configuration script in the FFmpeg code base. There is no library called npp in recent CUDA distributions, instead on Windows platforms you will have
nppc.lib
nppi.lib
npps.lib
and on linux
libnppc.so
libnppi.so
libnpps.so
You will either need to modify the configuration system yourself or file a bug request with the project developers to do it for you.
There might still be additional problems building the project with MinGW, but that is way beyond the scope of a Stack Overflow question.
If you check config.log, there may have a lot link warnings:
LINK : warning LNK4044: unrecognized option '/L...'; ignored
cause
ERROR: libnpp not found.
Since /L is not a correct argument for msvc linker, in order to include library path, the argument should as follow:
./configure .... --extra-cflags=-I/usr/local/cuda/... --extra-ldflags=-LIBPATH:/usr/local/cuda/...
This should able to solve the libnpp not found issue.
FYI, linker options are listed in the following link (included LIBPATH):
Linker Options