ffmpeg4,编码解码硬加速的实现

步骤基本上从网上抄袭就行。主要是3安装nv-codec-headers的版本,需要跟自己的驱动一致。我由于没有一致,安装cuda,安装其他的什么都没搞定,其中安装驱动还导致重装系统了,血的教训。

(输入命令nvidia-smi查看显卡驱动版本,nv-codec-headers/readme里面查看是否匹配)

如参考:

https://blog.csdn.net/weixin_45091328/article/details/103606433


sudo apt-get -y remove ffmpeg x264 libx264-dev

sudo apt-get -y install build-essential git yasm nasm unzip wget sysstat pkg-config

1.

wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2

然后解压在cd到目录下,再编译安装。

./configure

make

sudo make install

2.

git clone http://git.videolan.org/git/x264.git

cd x264

./configure --disable-cli --enable-static --enable-shared --enable-strip

make -j 4

sudo make install

sudo ldconfig

3.nv-codec-headers

里面有nv-codec-headers/readme,看看跟显卡驱动是否匹配,驱动418对9.0,(输入命令nvidia-smi查看显卡驱动版本)否则会提示:

[h264_nvenc @ 0x1b42940] Driver does not support the required nvenc API version. Required: 9.1 Found: 9.0

https://github.com/FFmpeg/nv-codec-headers/tree/sdk/9.0

cd nv-codec-headers

make

sudo make install

4.

https://github.com/FFmpeg/FFmpeg/tree/release/4.0

./configure --enable-shared --enable-gpl --enable-pthreads --enable-nvenc --enable-cuda --enable-cuvid --enable-libx264 --prefix=/usr/local/ffmpeg

make

sudo make install

5.

sudo gedit /etc/ld.so.conf

add: /usr/local/ffmpeg/lib

sudo ldconfig

6.

sudo gedit ~/.bashrc

FFMPEG="/usr/local/ffmpeg"

export PATH="$FFMPEG/bin:$PATH"

source ~/.bashrc

7.

ffmpeg -version

ffmpeg -codecs | grep cuvid

ffmpeg -codecs | grep nvenc

ffmpeg -encoders | grep 264

你可能感兴趣的:(ffmpeg4,编码解码硬加速的实现)