Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------
- UPDATE: Just use media-autobuild_suite, it's a billion times easier.
- ----------------------------------------------------------------------
- Prerequisites:
- - CUDA Toolkit: https://developer.nvidia.com/Cuda-toolkit
- - Media-autobuild_suite: https://github.com/m-ab-s/media-autobuild_suite
- - Have at least 12 Gb available, the final build will be around 700 Mb. Building itself will take several hours.
- - With CUDA installed, run media-autobuild_suite.bat
- - Follow instructions, generally self explanatory. Important choices: select "non-free", select "yes, custom ffmpeg options".
- - If you get errors during "/making" of ffmpeg, visit ...\build\ffmpeg_options.txt and comment out sketchy modules.
- My options, for example: https://pastebin.com/zGhA8CJG
- Once building has finished (suite should autoclose itself), copy following files into your directory of choice:
- - All files from ...\media-autobuild_suite\local64\bin-video\
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppc64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppicc64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppidei64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppig64_11.dll
- Now that ffmpeg is ready, you can uninstall CUDA and remove all MAS files. The copied over files is what you'll use.
- You're good to go here, and can ignore the rest of this text.
- ----------------------------------------------------------------------
- ----------------------------------------------------------------------
- This guide should aid with building Ffmpeg with Cuda SDK.
- It's heavily based on following answer: https://stackoverflow.com/a/56875864
- System:
- - OS: Windows 10, version 2004
- - CUDA version: 11.2
- - GPU: GTX 1660, Turing
- Prerequisites:
- - Visual Studio 2019 (or newer), with C++ packages
- - MSYS2: https://www.msys2.org/
- - CUDA Toolkit: https://developer.nvidia.com/Cuda-toolkit
- 1. Run Msys2.exe, execute following lines:
- pacman -Su
- pacman -S make
- pacman -S diffutils
- pacman -S yasm
- pacman -S mingw-w64-x86_64-gcc
- pacman -S mingw-w64-x86_64-toolchain
- PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/loca/lib/pkgconfig
- PATH=$PATH:/opt/bin
- git clone https://git.ffmpeg.org/ffmpeg.git
- git clone https://github.com/libav/libav
- git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
- 2. Launch "x64 Native Tools Command Prompt for VS2019". Run C:\msys32\mingw64.exe using Native Tools command prompt.
- 3. (Building avconv.exe and avprobe.exe) Using Mingw64.exe, enter following lines:
- cd libav
- ./configure
- make
- make install
- cd ..
- 4. (Building ffnvcodec.pc) Using Mingw64.exe, enter following lines:
- cd nv-codec-headers
- make
- make install
- cd ..
- 5. Copy file C:\msys32\home\<user>\nv-codec-headers\ffnvcodec.pc to following directory: C:\msys32\usr\local\lib\pkgconfig\
- 6. Open CUDA Toolkit's installer (e.g. cuda_11.2.0_460.89_win10.exe) using 7-Zip. Find and extract following folders:
- - ...\nvcc\include\ to MSYS2\tmp\nvidia_include\
- - ...\npp_dev\lib\x64\ to MSYS2\tmp\nvidia_lib\x64\
- - ...\npp_dev\include\ to MSYS2\tmp\nvidia_npp_include\
- 7. (Specifying GPU microarchitecture.)
- Open file "C:\msys32\home\<user>\ffmpeg\configure" (it doesn't have extension.)
- Find block that starts with "if enabled cuda_nvcc; then" (first occurrence, roughly at line #4345.)
- Replace the number in "compute_30" and "sm_30" according to your GPU architecture, use this webpage as a cheat-sheet: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
- For example, Turing will have compute_75, sm_75.
- 8. (Building ffmpeg.exe) Using Mingw64.exe, enter following lines:
- export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
- cd 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/x64
- make
- make install
- In case of errors during "./configure" procedure, be sure to investigate C:\msys32\home\<user>\ffmpeg\ffbuild\config.log
- 9. Create a new directory for your compiled ffmpeg. Copy following files into it:
- - C:\msys32\home\<user>\ffmpeg\ffmpeg.exe
- - C:\msys32\home\<user>\ffmpeg\ffprobe.exe
- - C:\msys32\home\<user>\libav\avconv.exe
- - C:\msys32\home\<user>\libav\avprobe.exe
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppc64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppicc64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppidei64_11.dll
- - C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nppig64_11.dll
- Copy all DLL files from C:\msys32\mingw64\bin\ directory as well.
- 10. Test the program. In case of errors, find and copy remaining missing DLLs.
- Documentation: https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/
Add Comment
Please, Sign In to add comment