Forward from White Wolf Stack: See the original article

About the installation of FFMPEG, some people may have to toss about for a long time, or even toss about for a week, the reason, the basic is to compile and install the trouble.

There are four types of installation available, the most complex being compilation and installation on Centos7.

  1. FFMPEG static library download and install
  2. Install FFMPEG on your Mac
  3. Build and install FFMPEG on Centos7
  4. Install FFMPEG using Docker

You can choose to install according to your preferences.

Why is FFmpeg the most complicated thing to compile and install on Linux? Because we need to install many extension libraries before compiling, everyone’s environment is different, and the codec library to install is more or less different.

Install FFmpeg under Linux, let’s take Centos7 compilation and installation as an example.

Let’s take a look at the system environment

[root@localhost vagrant]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

1. Install dependencies

yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel

If a dependency is installed during the process, report the following error

File "/bin/yum", line 30
    except KeyboardInterrupt, e:

or

Updates | 2.9 kB 00:00:00 File "/ usr/libexec/urlgrabber - ext - down", line 28 except OSError, e:

The default Python is 2.x or 3.x. If it is 3.x, change it to 2.x.

2. Install some necessary codec libraries. 1) Compile NASM, X264 dependent assembly optimized libraries

CD/opt/ffmpeg curl https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2 - O - L tar XJVF /autogen.sh./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make install ln -s /opt/ffmpeg/nasm /usr/bin/nasm

2) Compile YASM, which can be understood as FFMPEG-dependent assembly optimized library

CD/opt/ffmpeg curl https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz - O - L tar XZVF yasm - 1.3.0. Tar. Gz CD Yasm-1.3.0. /configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make install ln -s / opt/ffmpeg/yasm - 1.3.0 / yasm/usr/bin/yasm

3) Compile libx264

cd /opt/ffmpeg
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

Some people, when they compile X264, ERROR: Found no assembler, Minimum version is NASM-2.13, If you really want to compile without ASM, Configure with –disable-asm: configure with –disable-asm, this means that there are other NASM files on your computer that are too old, or that you didn’t add to the environment variable that we created in the first step. Make sure that NASM-V isa new package that we installed in the first step. Once set up, X264 is ready to proceed with the installation from./configure.

4) Compile libx265

cd /opt/ffmpeg git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git cd cd x265_git/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off .. /.. /source make make install

5) Compile libfdk_aac

cd /opt/ffmpeg
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

6) Compile libmp3lame

CD/opt/ffmpeg curl https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz - O - L tar XZVF /configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make make install

7) Compile Libopus

CD/opt/ffmpeg curl https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz - O - L tar XZVF opus - 1.3.1. Tar. Gz CD Opus-1.3.1. /configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install

8) Compile libvpx

cd /opt/ffmpeg
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

If the libvpx code can’t be pulled down, try the following method, other steps being the same

Wget https://github.com/webmproject/libvpx/archive/refs/tags/v1.10.0.tar.gz tar ZXVF v1.10.0. Tar. Gz CD libvpx - 1.10.0

Compiling is a long process, and we’re about half way there, so let’s compile and install today’s hero FFMPEG

Download the latest stability package and start the compilation and installation

cd /opt/ffmpeg 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 ln -s /opt/ffmpeg/ffmpeg/ffmpeg /usr/bin/ffmpeg

Finally verify whether the installation is successful

$FFmpeg - Version FFmpeg Version N-102343-G4D3474432F Copyright (C) 2000-2021 The FFmpeg Developers Built with GCC 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44) Configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 57.0.100/57.0.100 libavcodec 59.0.100/59.0.100 libavformat 59.0.100 / 59. 0.100 libavDevice 59. 0.100/59. 0.100 libavFilter 8.0.101/8.0.101 libswScale 6.0.100/6.0.100 Libswresample 4.0.100/4.0.100 libpostproc 56.0.100/56.0.100