1、准备工作,安装必要的环境
yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
2、创建目录
ffmpeg_sources 目录是下载软件包的目录
ffmpeg 目录是安装目录
mkdir /usr/local/ffmpeg_sources mkdir /usr/local/ffmpeg
3、安装ffmpeg
3.1、安装 nasm
cd /usr/local/ffmpeg_sources
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
tar xjvf nasm-2.13.02.tar.bz2
cd nasm-2.13.02
./autogen.sh
./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/bin"
make && make install
3.2 安装 yasm
cd /usr/local/ffmpeg_sources
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/bin"
make && make install
3.3、安装 libx264
cd /usr/local/ffmpeg_sources
git clone https://code.videolan.org/videolan/x264.git
cd x264
PKG_CONFIG_PATH="/usr/local/ffmpeg/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/bin" --enable-static
make && make install
3.4、安装 libx265
cd /usr/local/ffmpeg_sources
git clone https://github.com/videolan/x265.git
cd /usr/local/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local/ffmpeg" -DENABLE_SHARED:bool=off ../../source
make && make install
3.5、安装 fdk-aac
cd /usr/local/ffmpeg_sources
这个是fdk-aac官方地址
https://sourceforge.net/projects/opencore-amr/files/fdk-aac
下载
wget https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-2.0.2.tar.gz
tar -zxvf fdk-aac-2.0.2.tar.gz
mv fdk-aac-2.0.2 fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="/usr/local/ffmpeg" --disable-shared
make && make install
3.6、安装 libmp3lame
cd /usr/local/ffmpeg_sources
curl -O -L http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make && make install
3.7 安装 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 --prefix="/usr/local/ffmpeg" --disable-shared
make && make install
3.8 安装 libogg
cd /usr/local/ffmpeg_sources
curl -O -L http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.gz
tar xzvf libogg-1.3.3.tar.gz
cd libogg-1.3.3
./configure --prefix="/usr/local/ffmpeg" --disable-shared
make && make install
3.9 安装 libvorbis
cd /usr/local/ffmpeg_sources
curl -O -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar xzvf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5
./configure --prefix="/usr/local/ffmpeg" --with-ogg="/usr/local/ffmpeg" --disable-shared
make && make install
3.10、安装 libvpx
在阿里云镜像网站下载
https://mirrors.aliyun.com/blfs/conglomeration/libvpx/
cd /usr/local/ffmpeg_sources
tar -zxvf libvpx-1.13.0.tar.gz
mv libvpx-1.13.0 libvpx
cd libvpx
./configure --prefix="/usr/local/ffmpeg" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make && make install
3.11、安装 FFmpeg
ffmpeg 下载地址:Index of /releases
cd /usr/local/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
重点:
export PKG_CONFIG_PATH="/usr/local/ffmpeg/lib/pkgconfig"
./configure \
--prefix="/usr/local/ffmpeg" \
--pkg-config-flags="--static" \
--extra-cflags="-I/usr/local/ffmpeg/include" \
--extra-ldflags="-L/usr/local/ffmpeg/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="/usr/local/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
make
make install
4、检查是否安装成功
4.1 查看 ffmpeg 的版本号信息
ffmpeg -version
4.2、查看是否支持 libx264 信息
ffmpeg -h encoder=libx264