文章目录
附录2 Linux下编译FFmpeg
1 安装依赖项
yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel
2 NASM
NASM是一个汇编器的名称,全称是Netwide Assembler,支持x86与x64架构的CPU(注意不支持ARM架构)。
wget --no-check-certificate https://www.nasm.us/pub/nasm/releasebuilds/2.15/nasm-2.15.tar.gz
tar -xvf nasm-2.15.tar.gz
cd nasm-2.15/
./configure
make && sudo make install
3 Yasm
YASM是windows平台下的一个汇编器。
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && sudo make install
4 libx264
x264编码库libx264实现真正的视频编解码,该编解码算法是基于块的混合编码技术,即帧内/帧间预测,然后对预测值变换、量化,最后熵编码所得。编码帧的类型分为I帧(x264_type_i)、P帧(x264_type_p)、B帧(x264_type_b),在H264中叫做图像片Slice。
要求将 ffmpeg 配置为 --enable-gpl --enable-libx264.
git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
./configure --enable-shared --enable-static
make && make install
5 libx265
H.265 / HEVC视频编码器。
要求将 ffmpeg 配置为 --enable-gpl --enable-libx265.
git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git
cd x265_git/source
cmake ../source
make && make install
6 libfdk_aac
要求将 ffmpeg 配置为 --enable-libfdk_aac (and --enable-nonfree if you also included --enable-gpl).
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --enable-shared
make
make install
7 libmp3lame
MP3音频编码器。
要求将 ffmpeg 配置为 --enable-libmp3lame.
wget --no-check-certificate https://sourceforge.net/projects/lame/files/latest/download/lame-3.100.tar.gz
tar xf lame-3.100.tar.gz
cd lame-3.100
./configure --enable-shared --enable-static
make && make install
8 libopus
Opus音频解码器和编码器。
要求将 ffmpeg 配置为 --enable-libopus.
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xzvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure --enable-shared
make
make install
9 libvpx
P8/VP9视频编码器和解码器
要求将 ffmpeg 配置为 --enable-libvpx.
git clone https://github.com/webmproject/libvpx.git
cd libvpx
./configure --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install
10 FFmpeg
wget http://www.ffmpeg.org/releases/ffmpeg-5.1.tar.gz
tar xf ffmpeg-5.1.tar.gz
cd ffmpeg
./configure --prefix="/usr/local/ffmpeg" --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
make
make install