CentOS 7: Build FFmpeg

This article will describe installing and porting packages for FFmpeg, and building FFmpeg.

 

1 Build FFmpeg

The following script will build FFmpeg with using Fedora 22 src.rpm as possible.

#!/bin/sh

set -e

FEDORA_ARCHIVE=http://archives.fedoraproject.org/pub/archive
FEDORA_RELEASE=${FEDORA_ARCHIVE}/fedora/linux/releases
FEDORA_22_SRPMS=${FEDORA_RELEASE}/22/Everything/source/SRPMS

ffmpeg_install_devel()
{
  sudo yum group install -y "Development Tools"
  sudo yum install -y wget git mercurial rpmdevtools yum-utils
}

ffmpeg_install_openh264()
{
  sudo yum install -y nasm
  git clone https://github.com/cisco/openh264
  cd openh264
  git checkout v1.5.0 -b v1.5.0
  make && sudo make install
  cd ..
}

ffmpeg_install_enca()
{
  wget -q ${FEDORA_22_SRPMS}/e/enca-1.15-3.fc22.src.rpm
  sudo yum-builddep -y enca-*.src.rpm
  rpmbuild --rebuild enca-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/enca-*.rpm
}

ffmpeg_install_libass()
{
  wget -q ${FEDORA_22_SRPMS}/l/libass-0.12.0-1.fc22.src.rpm
  sudo yum-builddep -y libass-*.src.rpm
  rpmbuild --rebuild libass-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/libass-*.rpm
}

ffmpeg_install_libbs2b()
{
  wget -q ${FEDORA_22_SRPMS}/l/libbs2b-3.1.0-13.fc22.src.rpm
  sudo yum-builddep -y libbs2b-*.src.rpm
  rpmbuild --rebuild libbs2b-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/libbs2b-*.rpm
}

ffmpeg_install_imlib2()
{
  wget -q ${FEDORA_22_SRPMS}/i/imlib2-1.4.6-3.fc22.src.rpm
  sudo yum-builddep -y imlib2-*.src.rpm
  rpmbuild --rebuild imlib2-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/imlib2-*.rpm
}

ffmpeg_install_libcaca()
{
  wget -q ${FEDORA_22_SRPMS}/l/libcaca-0.99-0.23.beta18.fc22.src.rpm
  sudo yum-builddep -y libcaca-*.src.rpm
  rpmbuild --rebuild libcaca-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/libcaca-*.rpm
}

ffmpeg_install_libmodplug()
{
  wget -q ${FEDORA_22_SRPMS}/l/libmodplug-0.8.8.5-4.fc22.src.rpm
  sudo yum-builddep -y libmodplug-*.src.rpm
  rpmbuild --rebuild libmodplug-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/libmodplug-*.rpm
}

ffmpeg_install_lame()
{
  SF=http://downloads.sourceforge.net
  wget -q -O - ${SF}/project/lame/lame/3.99/lame-3.99.5.tar.gz | \
    tar zxf -
  cd lame-3.99.5/
  ./configure --disable-shared --enable-nasm --with-pic
  make && sudo make install
  cd ..
}

ffmpeg_install_rtmpdump()
{
  sudo yum install -y openssl-devel
  git clone git://git.ffmpeg.org/rtmpdump
  cd rtmpdump
  make && sudo make install
  cd ..
}

ffmpeg_install_schroedinger()
{
  wget -q ${FEDORA_22_SRPMS}/s/schroedinger-1.0.11-7.fc22.src.rpm
  sudo yum-builddep -y schroedinger-*.src.rpm
  rpmbuild --rebuild schroedinger-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/schroedinger-*.rpm
}

ffmpeg_install_shine()
{
  git clone https://github.com/toots/shine
  cd shine
  ./bootstrap && ./configure
  make && sudo make install
  cd ..
}

ffmpeg_install_soxr()
{
  wget -q ${FEDORA_22_SRPMS}/s/soxr-0.1.1-4.fc22.src.rpm
  sudo yum-builddep -y soxr-*.src.rpm
  rpmbuild --rebuild soxr-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/soxr-*.rpm
}

ffmpeg_install_twolame()
{
  sudo yum install -y asciidoc xmlto
  git clone https://github.com/njh/twolame/
  cd twolame
  ./autogen.sh
  make && sudo make install
  cd ..
}

ffmpeg_install_x265()
{
  hg clone http://hg.videolan.org/x265
  cd x265
  cmake -G 'Unix Makefiles' source
  make && sudo make install
  cd ..
}

ffmpeg_install_zvbi()
{
  wget -q ${FEDORA_22_SRPMS}/z/zvbi-0.2.33-18.fc22.src.rpm
  sudo yum-builddep -y zvbi-*.src.rpm
  rpmbuild --rebuild zvbi-*.src.rpm
  sudo yum localinstall -y ~/rpmbuild/RPMS/x86_64/zvbi-*.rpm
}

ffmpeg_install_openal()
{
  git clone https://github.com/JogAmp/openal-soft
  cd openal-soft
  cmake -G 'Unix Makefiles'
  make && sudo make install
  cd ..
}

ffmpeg_install_ffmpeg()
{
  sudo yum install -y \
       gnutls-devel \
       ladspa-devel \
       libbluray-devel \
       fontconfig-devel \
       freetype-devel \
       gsm-devel \
       openjpeg-devel \
       opus-devel \
       pulseaudio-libs-devel \
       speex-devel \
       libssh-devel \
       libtheora-devel \
       libvorbis-devel \
       libvpx-devel \
       wavpack-devel

  git clone https://github.com/FFmpeg/FFmpeg
  cd FFmpeg
  git checkout n3.1.8 -b n3.1.8
  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure \
                 --enable-pic \
                 --enable-gpl \
                 --disable-stripping \
                 --enable-shared \
                 --disable-decoder=libopenjpeg \
                 --disable-decoder=libschroedinger \
                 --enable-avresample \
                 --enable-avisynth \
                 --enable-gnutls \
                 --enable-ladspa \
                 --enable-libass \
                 --enable-libbluray \
                 --enable-libbs2b \
                 --enable-libcaca \
                 --enable-libfontconfig \
                 --enable-libfreetype \
                 --enable-libfribidi \
                 --enable-libgsm \
                 --enable-libmodplug \
                 --enable-libmp3lame \
                 --enable-libopenjpeg \
                 --enable-libopus \
                 --enable-libpulse \
                 --enable-librtmp \
                 --enable-libschroedinger \
                 --enable-libshine \
                 --enable-libsoxr \
                 --enable-libspeex \
                 --enable-libssh \
                 --enable-libtheora \
                 --enable-libtwolame \
                 --enable-libvorbis \
                 --enable-libvpx \
                 --enable-libwavpack \
                 --enable-libx265 \
                 --enable-libzvbi \
                 --enable-openal \
                 --enable-opengl \
                 --enable-libopenh264 \
                 --enable-ffmpeg \
                 --enable-ffplay \
                 --enable-ffprobe \
                 --enable-libxcb \
                 --enable-ffserver
  make && sudo make install
  cd ..

  sudo su -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf'
  sudo ldconfig
}

ffmpeg_main()
{
  mkdir ffmpeg
  cd ffmpeg
  ffmpeg_install_devel
  ffmpeg_install_openh264
  ffmpeg_install_enca
  ffmpeg_install_libass
  ffmpeg_install_libbs2b
  ffmpeg_install_imlib2
  ffmpeg_install_libcaca
  ffmpeg_install_libmodplug
  ffmpeg_install_lame
  ffmpeg_install_rtmpdump
  ffmpeg_install_schroedinger
  ffmpeg_install_shine
  ffmpeg_install_soxr
  ffmpeg_install_twolame
  ffmpeg_install_x265
  ffmpeg_install_zvbi
  ffmpeg_install_openal
  ffmpeg_install_ffmpeg
  cd ..
}

ffmpeg_main

2 Execution result

Execution result is the following.

$ ffmpeg
ffmpeg version n3.1.8 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
  configuration: --enable-pic --enable-gpl --disable-stripping
--enable-shared --disable-decoder=libopenjpeg
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgsm --enable-libmodplug --enable-libmp3lame
--enable-libopenjpeg --enable-libopus --enable-libpulse
--enable-librtmp --enable-libschroedinger --enable-libshine
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libx265 --enable-libzvbi --enable-openal
--enable-opengl --enable-libopenh264 --enable-ffmpeg --enable-ffplay
--enable-ffprobe --enable-libxcb --enable-ffserver
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile
options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'