Launch VS2015 x86 Native Tools Command Prompt. E.g.

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 Native Tools Command Prompt
In your MSYS2 shell navigate to your cloned FFmpeg folder. E.g.

cd /c/ffmpeg
Set the following environment variables in the launched command prompt above

SET LIB=%VSINSTALLDIR%VC\lib\store;%VSINSTALLDIR%VC\atlmfc\lib;%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86;;%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x86;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x86
SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib;%VSINSTALLDIR%VC\lib;
SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTVersion%\ucrt;%UniversalCRTSdkDir%Include\%UCRTVersion%\um;%UniversalCRTSdkDir%Include\%UCRTVersion%\shared;%UniversalCRTSdkDir%Include\%UCRTVersion%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;
Invoke the following make commands

mkdir -p Output/Windows10/x86

cd Output/Windows10/x86

../../../configure \
--toolchain=msvc \
--disable-programs \
--disable-d3d11va \
--disable-dxva2 \
--arch=x86 \
--enable-shared \
--enable-cross-compile \
--target-os=win32 \
--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00" \
--extra-ldflags="-APPCONTAINER WindowsApp.lib" \
--prefix=../../../Build/Windows10/x86

make

make install
Launch VS2015 x86 x64 Cross Tools Command Prompt. E.g.

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt
Launch VS2015 x86 ARM Cross Tools Command Prompt. E.g.

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 ARM Cross Tools Command Prompt
If you encounter an error linking because link.exe complains that MSPDB140.dll has the wrong version installed. Run the following command from an administrative command-prompt and rebuild:

copy "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\mspdbsrv.exe" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"

My environment is Ubuntu Server 16.10 64bit.
After a fresh installation I installed MinGW using the command:

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:

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:

As final step I launched Configure once again using the following parameters:


sudo apt-get install mingw-w64


./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/


cuda_8.0.61_win10.exe\npp_dev\lib -> tmp/lib  
cuda_8.0.61_win10.exe\npp_dev\include -> tmp/include


./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/

output of the test code


0.00129578 seconds

General configuration for OpenCV 3.1.0-dev =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            D:/git/opencv_contrib/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2016-05-27T19:59:05Z
    Host:                        Windows 10.0.10586 AMD64
    CMake:                       3.5.0-rc3
    CMake generator:             Visual Studio 14 2015 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
    MSVC:                        1900

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe  (ver 19.0.23506.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /MD /O2 /Ob2 /D NDEBUG
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi    /MP4  /MD /O2 /Ob2 /D NDEBUG
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi    /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
    Precompiled headers:         NO
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 D:/git/pthreadVC2.lib
    3rdparty dependencies:       zlib libjpeg libpng libtiff libjasper IlmImf libprotobuf

  OpenCV modules:
    To be built:                 core flann imgproc ml photo reg surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired cvblobslib dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light videostab xfeatures2d ximgproc aruco optflow stitching tracking ayvos java
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 python3 viz cvv hdf matlab sfm

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        NO
    PNG:                         build (ver 1.6.19)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    Video for Windows:           NO
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 56.41.100)
      format:                    YES (ver 56.36.101)
      util:                      YES (ver 54.27.100)
      swscale:                   YES (ver 3.1.101)
      resample:                  NO
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            Concurrency

  Other third-party libraries:
    Use IPP:                     NO
    Use IPP Async:               NO
    Use Eigen:                   NO
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                D:/git/opencv/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.11)

  Python 3:
    Interpreter:                 NO

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         C:/Program Files/apache-ant/bin/ant.bat (ver 1.9.6)
    JNI:                         C:/Program Files/Java/jdk1.8.0_74/include C:/Program Files/Java/jdk1.8.0_74/include/win32 C:/Program Files/Java/jdk1.8.0_74/include
    Java wrappers:               YES
    Java tests:                  NO

  Matlab:                        NO

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  D:/opencv-build/install

  cvconfig.h is in:              D:/opencv-build
-----------------------------------------------------------------

Recommend

FFMPEG Prerequisites and First Time Setup Instructions Verifying your FFmpeg Environment Setup

FFMPEG Prerequisites and First Time Setup Instructions Prerequisites MSYS2 Setup

FFMPEG How to encode with ffmpeg from Adobe Premiere Pro FAQ The audio is out of sync after I encode with ffmpeg from the frameserver

FFMPEG How to encode with ffmpeg from Adobe Premiere Pro FAQ ffmpeg gives me an error

FFMPEG How to encode with ffmpeg from Adobe Premiere Pro Use a frameserver

FFMPEG FFmpeg MP3 Encoding Guide VBR Encoding

FFMPEG Progressive Download

FFMPEG Metadata

FFMPEG Native FFmpeg AAC Encoder Examples

FFMPEG Fraunhofer FDK AAC (libfdk_aac) High-Efficiency AAC Examples

FFMPEG Fraunhofer FDK AAC (libfdk_aac) Variable Bit Rate (VBR) mode Examples

FFMPEG Fraunhofer FDK AAC (libfdk_aac) Constant Bit Rate (CBR) mode Examples

FFMPEG SVT-AV1 Presets and tunes

FFMPEG SVT-AV1 CRF

FFMPEG libaom HDR and high bit depth

FFMPEG libaom Average Bitrate (ABR)

FFMPEG libaom Two-Pass

FFMPEG libaom Constrained Quality

FFMPEG libaom Constant Quality

FFMPEG Rate control modes Two-Pass Encoding Two-Pass Example

FFMPEG Rate control modes Two-Pass Encoding

FFMPEG Rate control modes Constant Rate Factor (CRF)

FFMPEG Encode/VP8–FFmpeg Alpha Channel

FFMPEG Encode/VP8–FFmpeg Constant Bitrate

FFMPEG Encode/VP8–FFmpeg Variable Bitrate

FFMPEG Read from existing file

FFMPEG FFV1 encoding cheatsheet FFV1 version 3 Examples

FFMPEG FFV1 encoding cheatsheet FFV1 version 1 Examples

FFMPEG MPEG-4 Encoding Guide Constant Bit Rate Two-pass example

FFMPEG MPEG-4 Encoding Guide Constant Bit Rate

FFMPEG MPEG-4 Encoding Guide Variable Bit Rate with -qscale

FFMPEG MPEG-4 Encoding Guide

FFMPEG Using ffmpeg in a VFX pipeline Using the linux render farm

FFMPEG Using ffmpeg in a VFX pipeline Output H.264 Frame-by-Frame scrubbing

FFMPEG Using ffmpeg in a VFX pipeline Output Photo JPEG

FFMPEG Using ffmpeg in a VFX pipeline Output Prores

FFMPEG Using ffmpeg in a VFX pipeline Output Mono vs. Stereo

FFMPEG Using filters

FFMPEG Utilizing the included album cover/art

FFMPEG Upscaling video for higher peak quality

FFMPEG faststart for MP4/M4V/MOV files

FFMPEG Basic Examples

FFMPEG FFmpeg and VP9 Encoding Guide Compatibility

FFMPEG FFmpeg and VP9 Encoding Guide Lossless VP9

FFMPEG FFmpeg and VP9 Encoding Guide Constant Bitrate

FFMPEG FFmpeg and VP9 Encoding Guide Variable Bitrate (VBR) Constrained Quality

FFMPEG FFmpeg and VP9 Encoding Guide Variable Bitrate (VBR) Constant Quality

FFMPEG FFmpeg and VP9 Encoding Guide Variable Bitrate (VBR) Two-Pass

FFMPEG FFmpeg and VP9 Encoding Guide Variable Bitrate (VBR) Average Bitrate (ABR)

FFMPEG Additional Information & Tips Constrained encoding (VBV / maximum bit rate)

FFMPEG Additional Information & Tips CBR (Constant Bit Rate)

FFMPEG Overwriting default preset settings

FFMPEG Lossless H.264

FFMPEG Two-Pass Two-Pass Example

FFMPEG Two-Pass

FFMPEG Constant Rate Factor (CRF) CRF Example

FFMPEG Constant Rate Factor (CRF) 2. Choose a preset and tune List presets and tunes

FFMPEG Guidelines for high quality lossy audio encoding Recommended minimum bitrates to use

FFMPEG Guidelines for high quality lossy audio encoding Audio encoders FFmpeg can use

FFMPEG Guidelines for high quality lossy audio encoding Copying audio tracks

FFMPEG FFmeeting/2016-05–FFmpeg Full meeting log

FFMPEG FFmeeting/2014-01–FFmpeg Full meeting log

FFMPEG FFmeeting/2020-02–FFmpeg Full meeting log

FFMPEG FFmeeting/2014-10–FFmpeg Ful meeting log

FFMPEG FFmeeting/2015-09–FFmpeg Full meeting log

FFMPEG FFmeeting/2019-12–FFmpeg Context Navigation

FFMPEG FFmeeting/2020-12–FFmpeg Context Navigation

FFMPEG Speeding up/slowing down audio