使用nvidia gpu来为ffmpeg(av-codec)进行运算加速

以前由于一些原因,我们在使用通信等系统时,一般是不会使用GPU来进行某些运算的,不过现在相对而言,技术的成熟和日益复杂的功能需求,也不断地在倒逼我们使用GPU来进行图形图像或者高清语音等的运算,更何况在人工智能领域,这部分的需求本来就非常旺盛。

建议自己从源代码安装各部分,如果不想从源码编译安装,那么就在debian系统中

apt install libfdk-acc-dev libx264-dev libx265-dev -y

编译安装(前提是已安装了nvidia的驱动及cuda,见链接:使用Paddle-gpu进行asr和tts):

Fdk-aac 

git clone --depth 1 https://gitee.com/nwaycn/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --disable-shared --with-pic
make -j 16 && make install

h264

git clone https://code.videolan.org/videolan/x264.git
cd x264
./configure --enable-shared –enable-static
#如果没有汇编相关的,可以禁止asm即以下的configure参数  --disable-asm  
make -j 16
make install

h265


//wget -c https://bitbucket.org/multicoreware/x265/downloads/x265_3.4.tar.gz

//tar zxvf x265_3.4.tar.gz
cd /opt
git clone https://bitbucket.org/multicoreware/x265_git.git x265
cd x265
//cd x265_3.4
cd build/linux
./make-Makefiles.bash
make -j 16 && make install

ffnvcodec使用nvidia gpu必备

cd /opt
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make -j 16  #代表cpu为16核
make install

ffmpeg


cd /opt
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-gpl   --enable-version3  --enable-nonfree --disable-static --enable-shared --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages  --enable-zlib --enable-iconv --enable-libx264 --enable-libx265  --enable-libmp3lame  --enable-libfdk-aac --enable-pic
make -j 16 && make install

在此过程结束后,需要把/etc/profile中的LD_LIBRARY_PATH重新导出一下

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.7/lib64:/usr/local/lib

调用ffmpeg应该就可以使用gpu了

ffmpeg -codecs | grep nv

使用nvidia gpu来为ffmpeg(av-codec)进行运算加速

作者:宁卫

版权声明:本文内容转自互联网,本文观点仅代表作者本人。本站仅提供信息存储空间服务,所有权归原作者所有。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至1393616908@qq.com 举报,一经查实,本站将立刻删除。

(0)

相关推荐

发表回复

登录后才能评论