-
Notifications
You must be signed in to change notification settings - Fork 238
Building from source
VPF relies on FFmpeg for bitstream demuxing, Video Codec SDK for multimedia features and CUDA for processing on GPU.
Make sure you have latest Nvidia video driver & CUDA SDK installed on your machine. \
-
Install latest Nvidia video driver and CUDA SDK.
-
Download any suitable FFMpeg build or build it from source. Some FFMpeg binary releases may be found at https://github.com/BtbN/FFmpeg-Builds/releases.
-
Download Nvidia Video Codec SDK from https://developer.nvidia.com/nvidia-video-codec-sdk
Unzip package e. g. to C:\Install\Video_Codec_SDK_9.1.23 -
Install Python for Windows. \
-
Clone VPF into e. g. c:\GitHub\VideoProcessingFramework\
If you want to generate Pytorch extension, set up corresponding CMake value GENERATE_PYTORCH_EXTENSION
Then generate Visual Studio project with CMake: \
cd c:\GitHub\VideoProcessingFramework\
mkdir build
cd build
cmake .. ^
-G"Visual Studio 15 2017 Win64" ^
-DFFMPEG_DIR:PATH="C:/Install/ffmpeg-20191224-287620f-win64-dev" ^
-DVIDEO_CODEC_SDK_DIR:PATH="C:/Install/Video_Codec_SDK_9.1.23" ^
-DGENERATE_PYTHON_BINDINGS:BOOL="1" ^
-DGENERATE_PYTORCH_EXTENSION:BOOL="1" ^
-DCMAKE_INSTALL_PREFIX:PATH="C:/GitHub/VideoProcessingFramework"
-
Open Visual Studio project & build the INSTALL target
-
Add path to FFMpeg DLLs from Shared package to PATH or copy them to install folder
-
Run one of the Samples to check that build is fine
-
Install latest Nvidia video driver and CUDA SDK.
-
If you wish to build FFMpeg from sources, follow these steps:
cd ~/Git
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
mkdir -p $(pwd)/build_x64_release_shared
./configure \
--prefix=$(pwd)/build_x64_release_shared \
--disable-static \
--disable-stripping \
--disable-doc \
--enable-shared
make -j -s && make install
-
VPF user CMake
find_library
to locate ffmpeg which searches default paths (such as e. g. /usr/lib) first and user-provided path second. Make sure you link VPF against desired ffmpeg version. -
The rest of build procedure is similar to that for Windows.
If multiple Python versions are installed across the system, it's better to setPYTHON_LIBRARY
CMake variable by hand.
# Export paths to Video Codec SDK and FFMpeg
export PATH_TO_SDK=~/Video_Codec_SDK_9.1.23
export PATH_TO_FFMPEG=~/Git/FFmpeg/build_x64_release_shared
# Clone repo and start building process
cd ~/Git
git clone https://github.com/NVIDIA/VideoProcessingFramework.git
# Export path to CUDA compiler (you may need this sometimes if you install drivers from Nvidia site):
export CUDACXX=/usr/local/cuda/bin/nvcc
# Now the build itself
cd VideoProcessingFramework
export INSTALL_PREFIX=$(pwd)/install
mkdir -p install
mkdir -p build
cd build
# If you want to generate Pytorch extension, set up corresponding CMake value GENERATE_PYTORCH_EXTENSION
cmake .. \
-DFFMPEG_DIR:PATH="$PATH_TO_FFMPEG" \
-DVIDEO_CODEC_SDK_DIR:PATH="$PATH_TO_SDK" \
-DGENERATE_PYTHON_BINDINGS:BOOL="1" \
-DGENERATE_PYTORCH_EXTENSION:BOOL="1" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX"
make && make install
Check that CUDA and Video Codec SDK libraries are loaded from those directories, where they were put by driver installer.
Otherwise cuInit()
or cuvidCtxLockCreate()
may return weird error codes.
Your PyNvCodec module may have different name but it's placed inside the install folder:
ldd PyNvCodec.cpython-37m-x86_64-linux-gnu.so
#You shall see that it loads CUDA and Video Codec SDK from e. g.
/usr/lib64/libcuda.so
/usr/lib64/libnvcuvid.so
Launch one of samples
cd ~/Git/VideoProcessingFramework/install/bin
export LD_LIBRARY_PATH=$PATH_TO_FFMPEG/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH
python3 ./SampleDecode.py