Ubuntu18.04 编译ffmpeg、intel media sdk、cuda合并流程

一、下载intel media sdk

下载地址:https://github.com/Intel-Media-SDK/MediaSDK/releases

下载版本:Media SDK 20.2.0

参考资料:https://github.com/Intel-FFmpeg-Plugin/Intel_FFmpeg_plugins/wiki

Ubuntu18.04 编译ffmpeg、intel media sdk、cuda合并流程_第1张图片

选择MediaStack.tar.gz下载

二、 安装intel media sdk 

将MediaStack.tar.gz解压到某个目录,执行install_media.sh的脚本

./install_media.sh

会存在/opt/intel/mediasdk目录

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

cd /opt/ffmpeg-4.2.3

在/opt/ffmpeg-4.2.3目录下创建mfx文件夹、cuda文件夹

mkdir mfx
mkdir cuda
mkdir mfx/include
mkdir mfx/lib

四、拷贝intel media sdk文件夹的include和lib64文件到指定目录

\cp -rf /opt/intel/mediasdk/include/* /opt/ffmpeg-4.2.3/mfx/include
\cp -rf /opt/intel/mediasdk/lib64/* /opt/ffmpeg-4.2.3/mfx/lib

五、在/opt/ffmpeg-4.2.3/mfx目录下创建libmfx.pc

prefix=/opt/intel/mediasdk
    exec_prefix=/opt/intel/mediasdk/
    libdir=${prefix}/lib/lin_x64/
    includedir=${prefix}/include/
    Name: libmfx
    Description: mfx
    Version: 1.0.0
    Cflags: -I${includedir} 
    Libs: -L${libdir} -lmfx -ldl -lstdc++ -lrt -lva -lva-drm
    Libs.private: -lstdc++ -ldl

 

六、安装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

 

6.1找到cuda的include和lib文件

find / -name cuda

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

\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 \
PKG_CONFIG_PATH=/opt/ffmpeg-4.2.3/mfx \
./configure --prefix=/opt/ffmpeg-4.2.3/build \
--enable-debug \
--enable-shared \
--enable-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 \
--extra-cflags=-I./mfx/include \
--extra-ldflags=-L./mfx/lib/ \
--disable-schannel \
--disable-xlib \
--disable-zlib \
--enable-protocol=file \
--enable-libmfx \
--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

你可能感兴趣的:(Linux,ffmpeg)