1、如果需要支持h264,需先安裝x264
下載x264
git clone https://code.videolan.org/videolan/x264.git
編譯x264
./configure --disable-asm --enable-shared --enable-pic
或者
./configure --enable-shared
注意:--enable-shared選項(xiàng)是必需的,否則安裝之后仍無(wú)法識(shí)別x264
make
make install
---------------------------------------------------------------
2、安裝nvcodec
(1)下載源代碼
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
注意:使用版本11.1.5.2
其他版本在ffmpeg的編譯配置時(shí),執(zhí)行./configure命令報(bào)錯(cuò):
ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec
(2)進(jìn)入源碼根目錄
make
make install
(3)配置環(huán)境變量
vim /root/.bashrc
在文件末尾添加:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
保存退出
source /root/.bashrc
查看ffnvcodec版本:
pkg-config --modversion ffnvcodec
---------------------------------------------------------------
3、安裝FFmpeg
(1)下載源碼
本次安裝使用的是4.4版本
(2)編譯
進(jìn)入源碼根目錄
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --disable-doc --enable-gpl --enable-libx264
如果需要支持CUDA,還需加上
--enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc
即:
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --disable-doc --enable-gpl --enable-libx264 --enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc
make
make install
(3)配置
I 配置軟鏈接:
sudo ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg
sudo ln -s /usr/local/ffmpeg/bin/ffprobe /usr/bin/ffprobe
II 配置依賴(lài)庫(kù):
vim /etc/ld.so.conf
在文件末尾添加:
/usr/local/ffmpeg/lib
保存退出
ldconfig
(4)查看版本號(hào)
ffmpeg -version
可以看到各組件的版本號(hào)
------------------------------------------------------------------
4、轉(zhuǎn)碼應(yīng)用
ffmpeg -hwaccel cuda -i test1.mp4 -c:v h264_nvenc -b:v 5M -c:a copy test1_out.mp4
O了!
posted on 2024-01-10 23:01
小王 閱讀(369)
評(píng)論(0) 編輯 收藏 引用 所屬分類(lèi):
CUDA 、
音視頻