当前位置: 首页 > news >正文

linux(centos8)下编译ffmpeg

必要依赖

# centos8有些找不到依赖包,需要手动下载源码编译
sudo dnf install -y epel-release
sudo dnf install -y git gcc gcc-c++ make nasm yasm \
  libtool autoconf automake cmake \
  bzip2 bzip2-devel zlib-devel \
  xz xz-devel x264-devel x265-devel \
  openssl-devel freetype-devel \
  libvpx-devel libvorbis-devel \
  libass-devel opus-devel

nasm

cd /usr/local/src
wget https://www.nasm.us/pub/nasm/stable/nasm-2.16.03.tar.xz
tar -xf nasm-2.16.03.tar.xz
cd nasm-2.16.03
./configure
make -j$(nproc)
sudo make install

x264

cd /usr/local/src
git clone --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
./configure --enable-static --enable-pic
make -j$(nproc)
sudo make install

x265

cd /usr/local/src
git clone --depth 1 https://bitbucket.org/multicoreware/x265_git.git x265
cd x265/build/linux
mkdir build && cd build
cmake ../../../source -DCMAKE_INSTALL_PREFIX=/usr/local
# ./multilib.sh
make -j$(nproc)
sudo make install

# 查看安装是否成功
pkg-config --modversion x265

yasm

cd /usr/local/src
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0

./configure --prefix=/usr/local
make -j$(nproc)
sudo make install

yasm --version

libvpx

cd /usr/local/src
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix=/usr/local --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make -j$(nproc)
sudo make install

fdk-aac

cd /usr/local/src
git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix=/usr/local --enable-shared
make -j$(nproc)
sudo make install

sudo ldconfig
ls /usr/local/lib | grep fdk-aac

ffmpeg

下载 FFmpeg 源码

cd /usr/local/src
git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg

配置 FFmpeg

PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure \
  --prefix=/usr/local/ffmpeg \
  --enable-gpl \
  --enable-nonfree \
  --enable-shared \
  --disable-static \
  --enable-libx264 \
  --enable-libx265 \
  --enable-libvpx \
  --enable-libfdk-aac \
  --enable-libass \
  --enable-libopus \
  --enable-libvorbis \
  --enable-openssl

问题汇总

问题1:libass相关

报错内容:ERROR: libass >= 0.11.0 not found using pkg-config

解决方案:

sudo yum install libass-devel

问题2:opus

报错内容:ERROR: opus not found using pkg-config

解决方案:

sudo yum install opus opus-devel

问题3:vorbis

报错内容:ERROR: vorbis not found using pkg-config

解决方案:

sudo yum install libvorbis-devel

问题4:libvorbis

报错内容:ERROR: vorbis not found using pkg-config

解决方案:

# 下载源码方式1(可能会失败)
git clone https://github.com/xiph/vorbis.git
cd vorbis

#下载源码方式2
wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.gz
tar -xzf libvorbis-1.3.7.tar.gz
cd libvorbis-1.3.7

# 解压、配置、编译和安装
./autogen.sh  # 可能需要
./configure --prefix=/usr/local --enable-shared
make -j$(nproc)
sudo make install

编译并安装

make -j$(nproc)
sudo make install

动态库拷贝

将上述/usr/local/lib/下编译好的动态库拷贝至/usr/local/ffmpeg/lib。

环境变量配置

export PATH=/usr/local/ffmpeg/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH

查看版本

ffmpeg -version

相关文章:

  • HCIA-PPP
  • 每天五分钟深度学习PyTorch:循环神经网络RNN的计算以及维度信息
  • 大数据 Spark 技术简介
  • TLSR8355F128芯片特色解析
  • Linux中的epoll简单使用案例
  • 视频转音频, 音频转文字
  • 通过socket实现文件上传和下载功能
  • 信息系统运行管理员教程5--信息系统数据资源维护
  • PAT甲级(Advanced Level) Practice 1023 Have Fun with Numbers
  • LeetCode 1005. K 次取反后最大化的数组和 java题解
  • C语言 —— 此去经年梦浪荡魂音 - 深入理解指针(卷二)
  • SpringBoot3+Druid+MybatisPlus多数据源支持,通过@DS注解配置Service/Mapper/Entity使用什么数据源
  • Windows11 新机开荒(二)电脑优化设置
  • C++ 类和对象 友元 内部类 this指针 默认成员函数 初始化列表……
  • Pandas DataFrame:数据分析的利器
  • 14 结构体
  • WebSocket和长轮询
  • 【操作系统】Ch6 文件系统
  • 【最后203篇系列】015 几种消息队列的思考
  • ORA-00600错误的深度剖析:如何避免与解决?
  • 沙青青评《通勤梦魇》︱“人机组合”的通勤之路
  • 持续8年仍难终了的纠纷:败诉方因拒执罪被立案,胜诉方银行账户遭冻结
  • 体坛联播|安切洛蒂执掌巴西男足,字母哥尝试离开雄鹿
  • 济南市委副秘书长吕英伟已任历下区领导
  • 美国三大指数全线高开:纳指涨逾4%,大型科技股、中概股大涨
  • 上海浦东机场1号、2号航站楼均推出国内出发安检24小时服务