FFmpeg using NVIDIA GPUs

官方文件: https://developer.nvidia.com/ffmpeg

編譯一般的 CPU 的組態,設定之前要先安裝 lame/3.100 & x264/0.157.2935

./configure –enable-nonfree –enable-gpl –enable-libx264 –enable-libmp3lame –enable-shared –enable-static –prefix=/opt/ffmpeg/4.1_cpu

在弄 GPU 組態之前要先安裝 nv-codec-headers

# git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
# cd nv-codec-headers/
# make
# make install

# export PKG_CONFIG_PATH=”/usr/local/lib/pkgconfig”


ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec

GPU 組態如下:

./configure –enable-cuda – -enable-cuvid – -enable-nvenc – -enable-nonfree – -enable-libnpp – -extra-cflags=-I/usr/local/cuda/include – -extra-ldflags=-L/usr/local/cuda/lib64 – -prefix=/opt/ffmpeg/4.1_gpu

然後就用 make 編譯

安裝好之後,就可以用下列的參數使用 GPU 加速:

$ ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -vsync 0 -i XXX.mp4 -vcodec h264_nvenc XXX_output.mp4


$ ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -vsync 0 -i XXX.mp4 -vf scale_npp=1920:1072 -vcodec h264_nvenc XXX-1-264.mp4 -vf scale_npp=1280:720 -vcodec h264_nvenc XXX-2-264.mp4


nasm/yasm not found or too old. Use –disable-x86asm for a crippled build.

代表要安裝或更新 nasm / yasm,假設你也是使用 CentOS 6.X,指令如下:

# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install -y epel-release
# yum install -y nasm yasm

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.