8

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.

3
  • 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
10

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.

1
  • 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
6

Actually I went nuts about ffmpeg is not building with the same problem. I fianally managed to get it worked under Windows 10 x64:

  1. Download msys2 from https://www.msys2.org/ and install all packages with Pacman
    1. pacman -Su
    2. pacman -S make
    3. pacman -S diffutils
    4. pacman -S yasm
    5. pacman -S mingw-w64-x86_64-gcc
    6. pacman -S mingw-w64-x86_64-toolchain
    7. Maybe optional step: add pkgconfig to environment variable PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    8. Add additional installed toolchain to path: PATH=$PATH:/opt/bin
  2. 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
  3. Copy nVidia files

    1. Search on your harddisk for nvcc include directory e.g. C:\Program Files\NVIDIA Corporation\Installer2\nvcc_10.1.{542BC78D-DEB7-47AA-B531-BA67A40AB678}\include and copy files to your msys2 e.g. C:\msys64\tmp\nvidia_include
    2. 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\x64 and copy lib\x64 to your C:\msys64\tmp\nvidia_lib\x64
    3. 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}\include and copy include to C:\msys64\tmp\nvidia_npp_include
  4. git clone https://git.ffmpeg.org/ffmpeg.git to C:\msys64\home\<user>

  5. git clone https://github.com/libav/libav to C:\msys64\home\<user>
  6. Maybe optional step: git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git to C:\msys64\home\<user>
    1. make
    2. make install
    3. Copy ffnvcodec.pc to C:\msys64\usr\local\lib\pkgconfig
  7. Build libav avconv.exe and avprobe.exe are needed for ffmpeg later:
    1. cd C:\msys64\home\<user>\libav
    2. ./configure
    3. make
    4. make install
  8. Finally build ffmpeg:
    1. cd C:\msys64\home\<user>\ffmpeg
    2. ./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/x64
    3. make
    4. make install
    5. Copy avconv.exe and avprobe.exe to 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.
1
  • 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
2

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.

2
  • 2
    thanks for your answer talonmies, but the only solution i found was that i configured ffmpeg with --disable-libnpp flag... – Gio Feb 2 '17 at 11:35
  • Same here. I can't get libnpp detected to save my life. I'll just have to settle with disabling it. – SomeGuy Oct 9 '17 at 21:42
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.