CentOS 7: FFmpegをビルドする

FFmpegのビルドに必要なライブラリを導入して、ビルドする手順を記載します。

 

1 ビルドに必要なパッケージをインストールする

ビルドに必要なパッケージの内、CentOS 7が持つパッケージをyumでインストールします。

$ sudo yum install -y fribidi-devel libbluray-devel flite-devel \
gsm-devel openjpeg-devel opus-devel pulseaudio-libs-devel \
libssh-devel speex-devel libtheora-devel libvorbis-devel \
libvpx-devel wavpack-devel

2 ビルドに必要なパッケージを移植する

Fedora 22のsrc.rpmをできるかぎり利用します。

Fedora 22にないパッケージは各リポジトリを利用します。

Fedora 22のsrc.rpmのURLは以下のものを用います。

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

移植するパッケージのビルドに必要なパッケージをインストールします。

sudo yum install -y nasm ladspa-devel libsndfile-devel libid3tag-devel \
slang-devel glut-devel libGLU-devel tetex-latex tetex-dvips ruby-devel \
openssl-devel orc-devel glew-devel gtk-doc cmake asciidoc xmlto \
mercurial

2.1 OpenH264

$ git clone https://github.com/cisco/openh264
$ cd openh264
$ git checkout v1.5.0 -b v1.5.0
$ make && sudo make install
$ cd ..

2.2 enca

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

2.3 libass

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

2.4 libbs2b

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

2.5 imlib2

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

2.6 libcaca

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

2.7 libmodplug

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

2.8 mp3lame

$ wget -O - http://downloads.sourceforge.net/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 ..

2.9 rtmpdump

$ git clone git://git.ffmpeg.org/rtmpdump
$ cd rtmpdump
$ make && sudo make install
$ cd ..

2.10 schroedinger

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

2.11 shine

$ git clone https://github.com/toots/shine
$ cd shine
$ ./bootstrap && ./configure
$ make && sudo make install
$ cd ..

2.12 soxr

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

2.13 twolame

$ git clone https://github.com/njh/twolame/
$ cd twolame
$ ./autogen.sh
$ make && sudo make install
$ cd ..

2.14 x265

$ hg clone http://hg.videolan.org/x265
$ cd x265
$ cmake -G 'Unix Makefiles' source
$ make && sudo make install
$ cd ..

2.15 zvbi

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

2.16 openal

$ git clone https://github.com/JogAmp/openal-soft
$ cd openal-soft
$ cmake -G 'Unix Makefiles'
$ make && sudo make install
$ cd ..

3 FFmpegをビルドする

$ git clone https://github.com/FFmpeg/FFmpeg
$ cd FFmpeg
$ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure \
               --enable-gpl \
               --enable-shared \
               --disable-stripping \
               --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-x11grab \
               --enable-libopenh264
$ make && sudo make install
$ cd ..

4 実行結果

LD_LIBRARY_PATHで/usr/local/libを指定して下さい。

$ LD_LIBRARY_PATH=/usr/local/lib ffmpeg
ffmpeg version N-80117-gdac030d Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --enable-gpl --enable-shared --disable-stripping
--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-x11grab --enable-libopenh264
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 43.100 / 57. 43.100
  libavformat    57. 37.101 / 57. 37.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.100 /  6. 46.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  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'