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選項是必需的,否則安裝之后仍無法識別x264
make
make install
---------------------------------------------------------------
2、安裝nvcodec
(1)下載源代碼
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
注意:使用版本11.1.5.2
其他版本在ffmpeg的編譯配置時,執行./configure命令報錯:
ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec
(2)進入源碼根目錄
make
make install
(3)配置環境變量
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)編譯
進入源碼根目錄
./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 配置依賴庫:
vim /etc/ld.so.conf
在文件末尾添加:
/usr/local/ffmpeg/lib
保存退出
ldconfig
(4)查看版本號
ffmpeg -version
可以看到各組件的版本號
------------------------------------------------------------------
4、轉碼應用
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
小王 閱讀(370)
評論(0) 編輯 收藏 引用 所屬分類:
CUDA 、
音視頻