1. 安装基础依赖
bash
sudo yum update -y
sudo yum groupinstall "Development Tools" -y
sudo yum install epel-release -y
sudo yum install cmake3 git wget mercurial -y
2、创建编译目录
bash
mkdir -p ~/xsources
3. 安装NASM
bash
cd ~/xsources
wget https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/nasm-2.16.01.tar.gz
tar xzf nasm-2.16.01.tar.gz
cd nasm-2.16.01
./autogen.sh
./configure
make -j$(nproc)
sudo make install
4. 安装Yasm
bash
cd ~/xsources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make -j$(nproc)
sudo make install
5. 安装x264(H.264编码器)
bash
cd ~/xsources
git clone https://code.videolan.org/videolan/x264.git --depth=1
cd x264
./configure --enable-static --enable-shared
make -j$(nproc)
sudo make install
sudo ldconfig
6. 安装x265(H.265编码器)
踩坑:安装其它版本易报错
bash
cd ~/xsources
wget https://download.videolan.org/pub/videolan/x265/x265_3.5.tar.gz
tar xzf x265_3.5.tar.gz
cd x265_3.5/build/linux
cmake3 -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local ../../source
make -j$(nproc)
sudo make install
sudo ldconfig
7. 安装fdk-aac(AAC音频编码器)
bash
cd ~/xsources
wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.3.tar.gz
tar xzf fdk-aac-2.0.3.tar.gz
cd fdk-aac-2.0.3
./configure --disable-shared
make -j$(nproc)
sudo make install
8. 安装LAME(MP3编码器)
bash
cd ~/xsources
wget https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzf lame-3.100.tar.gz
cd lame-3.100
./configure --disable-shared
make -j$(nproc)
sudo make install
9. 安装Opus(音频编码器)
bash
cd ~/xsources
wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure --enable-shared
make -j$(nproc)
sudo make install
sudo ldconfig
ls /usr/local/lib/pkgconfig/opus.pc
echo 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH' | sudo tee -a /etc/profile
source /etc/profile
pkg-config --libs --cflags opus
10. 安装FFmpeg
bash
cd ~/xsources
wget https://ffmpeg.org/releases/ffmpeg-6.1.tar.xz
tar xJf ffmpeg-6.1.tar.xz
cd ffmpeg-6.1
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-nonfree \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libx264 \
--enable-libx265 \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib"
make -j$(nproc)
sudo make install
sudo ldconfig
11. 验证安装
bash
# 查看版本
ffmpeg -version
# 检查编解码器支持
ffmpeg -codecs | grep -E '264|265|fdk|mp3|opus'