ffmpeg | ubuntu源码编译gpu版ffmpeg

安装nv-codec-hearers

地址:https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/

# clone源码
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

cd nv-codec-headers 

# checkout到指定版本
# 可使用 git tag 查看可选的版本
git checkout n11.0.10.2 -b nv-codec-headers

# 编译&安装
make -j32
make install -j8

# 验证是否安装成功
pkg-config --modversion ffnvcodec
安装ffmpeg编码库
# clone源码
git clone https://code.videolan.org/videolan/x264.git

# 配置
cd x264
./configure --disable-asm --enable-shared --enable-pic

# 编译 & 安装
make -j32
make install -j8
安装ffmpeg
# 安装依赖
apt update

apt install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev

apt install -y autoconf automake build-essential git libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev

apt install libavformat-dev libavcodec-dev libswresample-dev libswscale-dev libavutil-dev libsdl1.2-dev

# clone ffmpeg源码
git clone https://git.ffmpeg.org/ffmpeg.git

cd ffmpeg

./configure --prefix=/usr/local/ffmpeg --disable-static --enable-shared --disable-avdevice --disable-sdl2 --disable-ffplay --disable-zlib --disable-lzma --enable-cuda --disable-doc --enable-gpl --enable-libx264 --enable-cuvid --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64

# 编译 & 安装
make -j32
make install -j8

# 软链
ln -s /usr/local/ffmpeg/bin/* /usr/bin/

# 添加系统环境变量
vim ~/.bashrc
# 末尾加入
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ffmpeg/lib

# 使配置生效
source ~/.bashrc
检查是否安装成功
# 检查硬件加速
ffmpeg -hwaccels

# 检查编解码器
ffmpeg -codecs | grep cuvid

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值