步驟基本上從網上抄襲就行。主要是3安裝nv-codec-headers的版本,需要跟自己的驅動一致。我由于沒有一致,安裝cuda,安裝其他的什么都沒搞定,其中安裝驅動還導致重裝系統(tǒng)了,血的教訓。
(輸入命令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