linux(centos8)下编译ffmpeg

必要依赖

bash 复制代码
# 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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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 源码

bash 复制代码
cd /usr/local/src
git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg

配置 FFmpeg

bash 复制代码
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

解决方案:

bash 复制代码
sudo yum install libass-devel

问题2:opus

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

解决方案:

bash 复制代码
sudo yum install opus opus-devel

问题3:vorbis

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

解决方案:

bash 复制代码
sudo yum install libvorbis-devel

问题4:libvorbis

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

解决方案:

bash 复制代码
# 下载源码方式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

编译并安装

bash 复制代码
make -j$(nproc)
sudo make install

动态库拷贝

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

环境变量配置

bash 复制代码
export PATH=/usr/local/ffmpeg/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH

查看版本

bash 复制代码
ffmpeg -version
相关推荐
生活爱好者!34 分钟前
NAS 部署白板工具,实现思维导图/画板/流程图自由
运维·docker·容器
sanggou3 小时前
Linux批量执行工具脚本使用指南:一键运行多个release-dev.sh脚本
linux·bash
牧以南歌〆8 小时前
在Ubuntu主机中修改ARM Linux开发板的根文件系统
linux·arm开发·驱动开发·ubuntu
互联网搬砖老肖8 小时前
运维打铁: MongoDB 数据库集群搭建与管理
运维·数据库·mongodb
Antonio9159 小时前
【音视频】HLS简介与服务器搭建
运维·服务器·音视频
夜月yeyue9 小时前
设计模式分析
linux·c++·stm32·单片机·嵌入式硬件
kfepiza9 小时前
Debian的`/etc/network/interfaces`的`allow-hotplug`和`auto`对比讲解 笔记250704
linux·服务器·网络·笔记·debian
艾伦_耶格宇10 小时前
【docker】-1 docker简介
运维·docker·容器
R.X. NLOS10 小时前
VS Code远程开发新方案:使用SFTP扩展解决Remote-SSH连接不稳定问题
运维·服务器·ssh·debug·vs code
cuijiecheng201810 小时前
Ubuntu下布署mediasoup-demo
linux·运维·ubuntu