34
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ffmpegをスタティックビルドする(CentOS6)

Last updated at Posted at 2013-10-27

ffmpegを

--disable-ffserver --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libvpx --enable-librtmp --enable-libfdk_aac --enable-openssl --enable-runtime-cpudetect --enable-libspeex --enable-libfreetype --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-filter=movie --enable-frei0r --enable-libxvid --arch=x86_64 --enable-static --disable-shared --disable-debug

といったオプション群をつけてスタティックビルドするときの手順。

準備

rpm で下記の様に開発環境を整えておく。

# yum groupinstall -y "Development Tools"
# yum install -y zlib-devel git subversion opencv-devel openssl-devel gnutls-devel
# yum install -y glibc-static openssl-static zlib-static

また、ここでは ffmpeg ユーザで作業を行うのでそのユーザを作成しておく。

# useradd ffmpeg
# su - ffmpeg
$ mkdir src

周辺モジュールのビルド・インストール

frei0r

これは rpm で入れてしまってもOKだったので、下記コマンドでインストール

# rpm -ivh http://pkgrepo.linuxtech.net/el6/release/x86_64/frei0r-devel-1.3-3.el6.x86_64.rpm \
http://pkgrepo.linuxtech.net/el6/release/x86_64/frei0r-plugins-1.3-3.el6.x86_64.rpm \
http://pkgrepo.linuxtech.net/el6/release/x86_64/libgavl-1.2.0-2.el6.x86_64.rpm \
http://pkgrepo.linuxtech.net/el6/release/x86_64/libgdither-0.6-3.el6.x86_64.rpm

以降では、すべて ffmpeg ユーザで作業。

yasm

$ cd ~/src
$ wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
$ tar zxf yasm-1.2.0.tar.gz
$ cd yasm-1.2.0
$ ./configure --prefix=$HOME
$ make
$ make install 

keyutils

$ cd ~/src
$ wget http://people.redhat.com/~dhowells/keyutils/keyutils-1.5.8.tar.bz2
$ tar xjf keyutils-1.5.8.tar.bz2
$ cd keyutils-1.5.8

Makefile の DESTDIR を下記の様に記述。

DESTDIR         := /home/ffmpeg
$ make 
$ make install  

kerberos

$ cd ~/src
$ wget http://web.mit.edu/kerberos/dist/krb5/1.11/krb5-1.11.3-signed.tar
$ tar xf krb5-1.11.3-signed.tar
$ tar xzf krb5-1.11.3.tar.gz
$ cd krb5-1.11.3/src
$ ./configure --prefix=$HOME --disable-shared  --enable-static
$ make
$ make install

openjpeg

$ cd ~/src
$ wget https://openjpeg.googlecode.com/files/openjpeg-1.5.1.tar.gz
$ tar xzf openjpeg-1.5.1.tar.gz 
$ cd openjpeg-1.5.1 
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

librtmp

$ cd ~/src
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump

Makfile, および librtmp/Makefile の先頭部分に記述されている prefix を以下の様に変更する。

prefix=/home/ffmpeg

そしてビルド

$ make SHARED=
$ make install

faac

$ cd ~/src
$ wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
$ tar zxf faac-1.28.tar.gz
$ cd faac-1.28

[CentOS] faacライブラリのコンパイルエラー の内容に従って、strcasestr の定義をコメントアウトする。

そしてビルド。

$ ./configure --prefix=$HOME --disable-shared 
$ make
$ make install

fdk_aac

$ cd ~/src
$ git clone https://github.com/mstorsjo/fdk-aac.git
$ cd fdk-aac/
$ autoreconf -fiv
$ ./configure --prefix=$HOME --disable-shared 
$ make
$ make install

libpng

$ cd ~/src
$ wget "http://prdownloads.sourceforge.net/libpng/libpng-1.6.6.tar.gz?download"
$ tar xzf libpng-1.6.6.tar.gz
$ cd libpng-1.6.6
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

bzip2

$ cd ~/src
$ wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
$ tar xzf bzip2-1.0.6.tar.gz
$ cd bzip2-1.0.6
$ make
$ make install PREFIX=$HOME

freetype2

$ cd ~/src
$ wget "http://downloads.sourceforge.net/project/freetype/freetype2/2.5.0/freetype-2.5.0.1.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffreetype%2Ffiles%2Ffreetype2%2F2.5.0%2F&ts=1382454119&use_mirror=jaist"
$ tar xjf freetype-2.5.0.1.tar.bz2
$ cd freetype-2.5.0.1  
$ CFLAGS="-I$HOME/include" LDFLAGS="-L$HOME/lib" ./configure --prefix=$HOME --disable-shared 
$ make
$ make install

lame

$ cd ~/src
$ wget "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1365466294&use_mirror=jaist" 
$ tar xzf lame-3.99.5.tar.gz
$ cd lame-3.99.5
$ ./configure --prefix=$HOME --enable-nasm --disable-shared 
$ make
$ make install

opencore-amr

$ cd ~/src
$ wget "http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fopencore-amr%2F&ts=1366120785&use_mirror=jaist"
$ tar xzf opencore-amr-0.1.3.tar.gz
$ cd opencore-amr-0.1.3
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

libogg

$ cd ~/src
$ wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
$ tar xzf libogg-1.3.1.tar.gz
$ cd libogg-1.3.1
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

libtheora

$ cd ~/src
$ wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
$ tar xjf libtheora-1.1.1.tar.bz2
$ cd libtheora-1.1.1
$ ./configure --prefix=$HOME --disable-shared --with-ogg=$HOME
$ make
$ make install

speex

$ cd ~/src
$ wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
$ tar xzf speex-1.2rc1.tar.gz
$ cd speex-1.2rc1
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

vo-aacenc

$ cd ~/src
$ wget "http://downloads.sourceforge.net/project/opencore-amr/vo-aacenc/vo-aacenc-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fvo-aacenc%2F&ts=1382764016&use_mirror=jaist"
$ tar xzf vo-aacenc-0.1.3.tar.gz
$ cd vo-aacenc-0.1.3
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

vo-amrwbenc

$ cd ~/src
$ wget "http://downloads.sourceforge.net/project/opencore-amr/vo-amrwbenc/vo-amrwbenc-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fvo-amrwbenc%2F&ts=1382764197&use_mirror=jaist"  
$ tar xzf vo-amrwbenc-0.1.3.tar.gz
$ cd vo-amrwbenc-0.1.3
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

libvorbis

$ cd ~/src
$ wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
$ tar xzf libvorbis-1.3.3.tar.gz
$ cd libvorbis-1.3.3
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

libvpx

$ cd ~/src
$ git clone http://git.chromium.org/webm/libvpx.git
$ cd libvpx/
$ ./configure --prefix=$HOME --disable-shared
$ make
$ make install

x264

$ cd ~/src
$ git clone git://git.videolan.org/x264.git
$ cd x264
$ ./configure --prefix=$HOME --enable-static
$ make
$ make install

xvid

$ cd ~/src
$ wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
$ tar xzf xvidcore-1.3.2.tar.gz
$ cd xvidcore
$ cd build/generic
$ ./configure --prefix=$HOME
$ make
$ make install   

ffmpeg 本体

周辺モジュールがビルドできれば以下の手順でビルドできる。

$ cd ~/src
$ wget http://www.ffmpeg.org/releases/ffmpeg-2.0.2.tar.bz2
$ tar xjf ffmpeg-2.0.2.tar.bz2
$ cd ffmpeg-2.0.2
$ PKG_CONFIG_PATH=$HOME/lib/pkgconfig ./configure --prefix=$HOME \
--disable-ffserver --enable-gpl --enable-version3 --enable-nonfree \
--enable-postproc --enable-pthreads --enable-libfaac --enable-libmp3lame \
--enable-libvorbis --enable-libtheora --enable-libx264 --enable-libvpx \
--enable-librtmp --enable-libfdk_aac --enable-openssl \
--enable-runtime-cpudetect --enable-libspeex --enable-libfreetype \
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray \
--enable-libopenjpeg --enable-libopencore-amrnb --enable-libopencore-amrwb \
--enable-filter=movie --enable-frei0r --enable-libxvid \
--arch=x86_64 --enable-static --disable-shared --disable-debug \
--extra-cflags="-I$HOME/include -I$HOME/usr/include --static" \
--extra-libs='-static -lpng -lbz2 -lm -lz -lkrb5 -lkrb5support -lk5crypto -lcom_err -lkeyutils -lresolv -L/usr/lib -L$HOME/lib  -L$HOME/usr/lib64'
$ make
$ make install 

これで /home/ffmpeg/bin/ffmpeg にできている。

$ cd ~/bin/
$ ldd ffmpeg
	not a dynamic executable

となればスタティックビルドできている。

34
34
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?