-
Notifications
You must be signed in to change notification settings - Fork 237
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.
Anaconda Python 3.7 is preferred if you're planning to use Pytorch bindings.
-
Install latest Nvidia video driver and CUDA SDK.
-
Download Zeranoe FFMpeg build from https://ffmpeg.zeranoe.com/builds/
Get Windows 64-bit builds for both Shared and Dev linkage.
Unzip Dev package e. g. to C:\Install\ffmpeg-20191224-287620f-win64-dev
Unzip Shared package e. g. to C:\Install\ffmpeg-20191224-287620f-win64-shared -
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 (Anaconda recommended if you're going to use Pytorch bindings).
Recommended version is Python 3.7 -
Clone VPF into e. g. c:\GitHub\VideoProcessingFramework
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" ^
-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
cmake .. \
-DFFMPEG_DIR:PATH="$PATH_TO_FFMPEG" \
-DVIDEO_CODEC_SDK_DIR:PATH="$PATH_TO_SDK" \
-DGENERATE_PYTHON_BINDINGS:BOOL="1" \
-DPYTHON_LIBRARY=/home/user/anaconda3/lib/libpython3.7m.so \
-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