一、解压ffmpeg4.2.3到/opt目录下

cd /opt/ffmpeg-4.2.3

二、安装cuda依赖

 apt install nvidia-cuda-toolkit
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda-repo-ubuntu1804-11-0-local_11.0.2-450.51.05-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-0-local_11.0.2-450.51.05-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-0-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

参考:https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal

 

2.1找到cuda的include和lib文件

find / -name cuda

2.2拷贝include和lib到/opt/ffmpeg-4.2.3

mkdir -p /opt/ffmpeg-4.2.3/cuda/

执行下面的命令:

\cp -rf /usr/local/cuda-11.0/targets/x86_64-linux/* /opt/ffmpeg-4.2.3/cuda/

 

二、在ffmpeg目录执行下面的命令(第一步必须先执行)

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

 

三、编译

PKG_CONFIG_PATH=/opt/ffmpeg-4.2.3/nv-codec-headers \
./configure --prefix=/opt/ffmpeg-4.2.3/build \
--enable-debug \
--enable-shared \
--disable-static \
--arch=x86_64 \
--enable-stripping \
--enable-optimizations \
--enable-x86asm \
--enable-asm \
--disable-network \
--disable-iconv \
--extra-cflags=-I./nv-codec-headers/include \
--extra-cflags=-I./cuda/include \
--extra-ldflags=-L./cuda/lib \
--disable-schannel \
--disable-xlib \
--disable-zlib \
--enable-protocol=file \
--enable-cuda-sdk \
--enable-cuda \
--enable-cuvid \
--enable-nvenc \
--enable-nonfree \
--enable-libnpp \
--enable-outdev=sdl2 \
--enable-nonfree \
--enable-version3 \
--enable-gpl \
--enable-ffmpeg \
--enable-ffplay \
--disable-ffprobe

四、make && make install

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐