You are here

FFmpeg on CentOS 7

These instructions are based on a build for Zoneminder on a CentOS 6 box which has a section on building ffmpeg for Zoneminder.  As time goes on, new versions come out and things change, like faac is no longer there and you have to use the compat version of the GCC compiler.

Before I start, the alternative way is to simply use RPMs built by someone else.  So be forewarned this is the harder way, I did it this way because I may need to compile other features in to this build.  Also the simple fact is I want to learn.  I may as well share.  This document was started Dec 27, 2018 for future reference.

So, this build is from the sources, it is longer than a simple yum install.

You should probably do this as a normal user, I will note sections you should be root, but for the most part, if you need to run a priviledged command, use sudo.

These instructions were originally done on a machine that I had a kickstart build, but tested on a CentOS 7 1804 using a minimal build on an ESXi 6.0 virtual machine.

So here we go

Enable EPEL

Although we will be compiling most of the software you will need, there are some packages you will need from the EPEL repository, so enable it using the following command.

yum install epel-release

Install some rpms

Now you will need to install some rpms

sudo yum install wget cmake zlib zlib-devel openjpeg openjpeg-devel \
openjpeg2 openjpeg2-devel gcc-c++ compat-gcc-44 git subversion \
gnutls-devel ladspa ladspa-devel libass libass-devel libdc1394 libdc1394-devel \
gsm-devel opus opus-devel pulseaudio-libs-devel soxr soxr-devel speex speex-devel \
libtheora libtheora-devel libv4l-devel libv4l v4l-utils libvorbis libvorbis-devel \
vo_amrwbenc vo_amrwbenc-devel openal openal-soft-devel libcdio libcdio-devel \
libcdio-paranoia libcdio-paranoia-devel bzip2 bzip2-devel libxcb libxcb-devel

Make a Workspace

In your home directory create a place to do all this work

cd ~
mkdir ffmpeg
cd ffmpeg

Then get the following files


Here is a scripted way to get those files

wget -O lame-3.100.tar.gz
wget -O faad2-2.8.8.tar.gz
wget -O opencore-amr-0.1.5.tar.gz
wget -O vo-amrwbenc-0.1.3.tar.gz

Install NASM rpm

One of the things downloaded was a later version of NASM, install it using the following command

yum install nasm-2.14.02-0.fc27.x86_64.rpm

Install via Source Code

For the rest of these packages the steps are pretty much

  1. Untar
  2. Go in to the directory
  3. ./configure
  4. make
  5. sudo make install

I will note when things are slightly different

Installing Opencore

tar zxvf opencore-amr-0.1.5.tar.gz
cd opencore-amr-0.1.5
sudo make install

Installing FAAD2

cd ..
tar zxvf faad2-2.8.8.tar.gz
cd faad2-2.8.8
sudo make install

Installing libmp3lame

cd ..
tar zxvf lame-3.100.tar.gz
cd lame-3.100
sudo make install

Installing vo-amrwbenc

cd ..
tar zxvf vo-amrwbenc-0.1.3.tar.gz
cd vo-amrwbenc-0.1.3
sudo make install

Installing Xvid

cd ..
tar zvxf xvidcore-1.3.5.tar.gz
cd xvidcore/build/generic
sudo make install

Installing x264

Note that you are using git to download the source code and we are enabling shared libs

cd /usr/src/ffmpeg
git clone
cd x264
./configure --enable-shared
sudo make install


Before you do the compile ffmpeg run as root the following commands

echo "/usr/local/lib/" >> /etc/
ldconfig -v

Installing FFMPEG

Here is where we install ffmpeg from source.  The configure command is where you would normally enable the features you need in ffmpeg.  The features enabled in this example make use of rpms and sources installed above.  Note that a popular feature is x265 and it is not enabled here.  There is a problem I am trying to work out regarding including it (as well as opus).  I will create a new document once it is figure out.

git clone ffmpeg
cd ffmpeg
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
export TMPDIR=/tmp
./configure --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg \
--incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 \
--optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \
--extra-ldflags='-Wl,-z,relro ' \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libvo-amrwbenc \
--enable-version3 \
--enable-bzlib \
--disable-crystalhd \
--enable-gnutls \
--enable-ladspa \
--enable-libass \
--enable-libcdio \
--enable-libdc1394 \
--disable-indev=jack \
--enable-libfreetype \
--enable-libgsm \
--enable-libmp3lame \
--enable-openal \
--enable-libopenjpeg \
--enable-libpulse \
--enable-libsoxr \
--enable-libspeex \
--enable-libtheora \
--enable-libvorbis \
--enable-libv4l2 \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libxcb \
--enable-avfilter \
--enable-avresample \
--enable-postproc \
--enable-pthreads \
--disable-static \
--enable-shared \
--enable-gpl \
--disable-debug \
--disable-stripping \
--shlibdir=/usr/lib64 \
--enable-runtime-cpudetect \
sudo make install

That should be it, go ahead and test ffmpeg

There was a problem with the version of x265 I was using, before you run configure for ffmpeg 

As root edit


Line 672 add struct before x265_parm, so that section should look like this

typedef struct x265_zone
    int   startFrame, endFrame; /* range of frame numbers */
    int   bForceQp;             /* whether to use qp vs bitrate factor */
    int   qp;
    float bitrateFactor;
    struct x265_param* zoneParam;
} x265_zone;

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer