Last active
December 6, 2021 17:08
-
-
Save orm011/94c3771352e96bf8cc9ed0a6254aed22 to your computer and use it in GitHub Desktop.
ffmpeg gpu support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
origin https://git.videolan.org/git/ffmpeg/nv-codec-headers.git | |
# tag n10.0.26.0 | |
# may be useful to point ffmpeg to different path, eg. conda | |
# --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu | |
base=/home/gridsan/omoll/ | |
mkdir ${base}/ffmpeg_install | |
prefix=${base}/ffmpeg_install | |
nv_codec_install=${base}/nv-codec-headers-install/ | |
./configure --enable-cuvid --enable-nvdec --enable-nvenc --enable-libnpp \ | |
--enable-libx264 --enable-libx265 --enable-libvpx --enable-libwebp --enable-libopenjpeg \ | |
--enable-libfreetype --enable-libfontconfig --enable-libfribidi \ | |
--enable-nonfree --enable-gpl \ | |
--enable-libssh --enable-openssl \ | |
--enable-zlib --enable-libmp3lame \ | |
--extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 \ | |
--prefix=$prefix \ | |
--extra-cflags=-I"${nv_codec_install}/include/" \ | |
--extra-cflags=-I"${prefix}/include/" --extra-ldflags=-L"${prefix}/lib/" \ | |
--disable-doc --enable-hardcoded-tables --enable-pic --enable-pthreads --enable-shared --disable-stripping | |
PATH=${local_build}/bin PKG_CONFIG_PATH=${local_build}/include/ ./configure --enable-cuvid --enable-nvdec --enable-nvenc --enable-libnpp \ | |
--enable-libx264 \ | |
--enable-libfreetype --enable-libfontconfig \ | |
--enable-nonfree --enable-gpl \ | |
--enable-openssl \ | |
--enable-zlib --enable-libmp3lame \ | |
--extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 \ | |
--prefix=$prefix \ | |
--extra-cflags=-I"${local_build}/include/" \ | |
--extra-ldflags=-L"${local_build}/lib/" \ | |
--disable-doc --enable-hardcoded-tables --enable-pic --enable-pthreads --enable-shared --disable-stripping | |
## example loading and rescaling using npp | |
file=myfile.mp4 | |
target_height=800 | |
device=0 | |
export LD_LIBRARY_PATH=./lib/ | |
## test with no output | |
./bin/ffmpeg_gpu -vsync 0 -hwaccel nvdec -hwaccel_device $device -c:v h264_cuvid -i $file \ | |
-vf hwupload_cuda,scale_npp=-1:$target_height:interp_algo=super -f null out | |
## output to a file | |
./bin/ffmpeg_gpu -vsync 0 -hwaccel nvdec -hwaccel_device $device -c:v h264_cuvid -i $file \ | |
-vf hwupload_cuda,scale_npp=-1:$target_height:interp_algo=super -c:v h264_nvenc ../output.mp4 | |
# if want to build other stuff manually | |
# check https://gist.github.com/Brainiarc7/3f7695ac2a0905b05c5b | |
# some explanation of gpu options, such as rescaling: | |
# https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment