Article directory
Compilation and Installation Instructions
This guide document is translated from the official website of FFmpeg, and the link to the official document has been successfully installed on CentOS. It is specially recorded for future use. However, the English level is limited. If there are any incomprehensible or incorrect places, you can browse the official original content or Leave a message to correct me, thank you.
This document is based on the minimal installation of the latest version of CentOS. It will provide local non-system and level FFmpeg installation process, and support several common external decoders. This installation instruction also applies to the latest versions of Red Hat (RHEL) systems and Fedora systems.
For other information about compiling software, you can refer to the general compiling guide, refer to the link
The installation method designed in this document is non-intrusive and requires the creation of several folders locally:
- ffmpeg_sources – used to save the source code files downloaded during installation, which can be deleted after the installation is complete.
- ffmpeg_build – used to save the compiled source code files and the installation of dependent libraries, which can be deleted after the installation is complete.
- bin – the installation location of software and decoders, such as (ffmpeg, ffprobe, x264, x265), etc.
You can undo any step in this guide by referring to Reverting Changes .
Kind tips:If you are inconvenient or unable to compile the source code for other reasons, you can directly download the latest precompiled installation package download link
The installation environment depends on
illustrate:The # in the command code indicates that the command needs to be
root
executed by a super-privileged user or user. In this article,yum
the command must be executed by a super-privileged user
install dependencies
Install the necessary system dependencies. The following are the dependent libraries necessary for source code compilation and installation:
# yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel
create folder
家目录
Create a new folder in the user to save the source code FFmpeg
as well解码器
mkdir ~/ffmpeg_sources
Source code download, compilation and installation
Kind tips: If you don’t need to install all the decoders, just skip the corresponding decoder installation module and remove the corresponding parameters
FFmpeg
during installation./configure
. For example, if you don’t need to installlibvpx
, skip the installation process of this decoder, and then delete--enable-libvpx
Just configure parameters. #4CAF50
Install nasm
NASM
It is the compiler used by some dependent libraries in the system. It is strongly recommended to install it, otherwise the next installation and compilation process will be time-consuming.
cd ~/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
tar xjvf nasm-2.15.05.tar.bz2
cd nasm-2.15.05
./autogen.sh
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
Install Yasm
As above, Yasm
it is the compiler used by some dependent libraries in the system. It is strongly recommended to install it, otherwise the next installation and compilation process will be time-consuming.
cd ~/ffmpeg_sources
curl -O -L https://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="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
Install libx264
H.264 video decoder, please click the reference link for details and usage
ffmpeg
It needs to be configured during installation --enable-gpl
--enable-libx264
.
cd ~/ffmpeg_sources
git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make
make install
Install libx265
H.265/HEVC video decoder, please click the reference link for details and usage
ffmpeg
It needs to be configured during installation --enable-gpl
--enable-libx265
.
cd ~/ffmpeg_sources
git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git
cd ~/ffmpeg_sources/x265_git/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
Install libfdk_aac
AAC audio codec, please click the reference link for details and usage
ffmpeg
It needs to be configured during installation --enable-libfdk_aac
(if you have also configured it --enable-gpl
, you need to add it --enable-nonfree
)
cd ~/ffmpeg_sources
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
Install libmp3lame
MP3 Audio Codec
ffmpeg
Configuration required during installation--enable-libmp3lame
cd ~/ffmpeg_sources
curl -O -L https://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="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm
make
make install
Install libopus
Opus audio codec and decoder.
ffmpeg
Configuration required during installation--enable-libopus
cd ~/ffmpeg_sources
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="$HOME/ffmpeg_build" --disable-shared
make
make install
Install libvpx
VP8/VP9 video encoder and decoder. For details and usage, please click the reference link
ffmpeg
Configuration required during installation--enable-libvpx
cd ~/ffmpeg_sources
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install
Kind tips: Google resource download may cause problems such as connection timeout or slow resource download speed, which may lead to installation failure. It is recommended to use other methods (such as browser + scientific Internet access, etc.) to download the source code, upload the source code to gitee or github, and replace the original link After creating a new link, perform operations such as downloading, compiling and installing
ffmpeg
cd ~/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
make
make install
hash -d ffmpeg
At this point, FFmpeg
the installation process of some of its decoders is all over. The following content is about how to update and remove installed software or dependent libraries, if necessary, you can continue to read.
renew
FFmpeg is still under development, and there will be version updates and abnormal fixes from time to time. The update operation needs to remove the old version files first, and then update the dependent library files:
rm -rf ~/ffmpeg_build ~/bin/{ffmpeg,ffprobe,lame,x264,x265}
# yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
Update x264
cd ~/ffmpeg_sources/x264
make distclean
git pull
Then run./configure
, make
, and make install
as shown in theInstall x264
section.
Update x265
cd ~/ffmpeg_sources/x265_git
rm -rf ~/ffmpeg_sources/x265_git/build/linux/*
git pull
cd ~/ffmpeg_sources/x265_git/build/linux
Then run cmake
, make
, and make install
as shown in theInstall x265
section.
Update libfdk_aac
cd ~/ffmpeg_sources/fdk_aac
make distclean
git pull
Then run./configure
, make
, and make install
as shown in theInstall libfdk_aac
section.
update-libvpx
cd ~/ffmpeg_sources/libvpx
make distclean
git pull
Then run ./configure
, make
, and make install
as shown in the Install libvpx
section.
Update FFmpeg
rm -rf ~/ffmpeg_sources/ffmpeg
Rerun Install FFmpeg
section.
Undo all installations of this document
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,lame,nasm,vsyasm,x264,yasm,ytasm}
# yum erase autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool zlib-devel
hash -r