Amazon Linux 2013.09 に FFmpeg をインストールする


公式ドキュメントの [Compile FFmpeg on CentOS 6.x](https://trac.ffmpeg.org/wiki/CentosCompilationGuide) とほぼ同じ方法でインストールしました。

公式ドキュメントの方は$HOMEへのインストールだったので、それを ```/usr/local``` へインストールするように修正しただけです。

## Get the Dependencies
```
sudo yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
```

```
cd /usr/local/src
mkdir ffmpeg_sources
```

## Compilation & Installation
### Yasm
```
cd /usr/local/src/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/bin"
make
sudo make install
make distclean
export "PATH=$PATH:/usr/local/bin"
```

### libx264
```
cd /usr/local/src/ffmpeg_sources
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/bin" --enable-static
make
sudo make install
make distclean
```

### libfdk_aac
```
cd /usr/local/src/ffmpeg_sources
git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
```

### libmp3lame
```
cd /usr/local/src/ffmpeg_sources
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make
sudo make install
make distclean
```

### libopus
```
cd /usr/local/src/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
tar xzvf opus-1.1.tar.gz
cd opus-1.1
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
```

### libogg
```
cd /usr/local/src/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
tar xzvf libogg-1.3.1.tar.gz
cd libogg-1.3.1
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
```

### libvorbis
```
cd /usr/local/src/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
tar xzvf libvorbis-1.3.4.tar.gz
cd libvorbis-1.3.4
./configure --prefix="/usr/local/ffmpeg_build" --with-ogg="/usr/local/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
```

### libvpx
```
cd /usr/local/src/ffmpeg_sources
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --prefix="/usr/local/ffmpeg_build" --disable-examples
make
sudo make install
make clean
```

### FFmpeg
```
cd /usr/local/src/ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="/usr/local/ffmpeg_build"
--extra-cflags="-I/usr/local/ffmpeg_build/include"
--extra-ldflags="-L/usr/local/ffmpeg_build/lib" --bindir="/usr/local/bin" --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264
make
sudo make install
make distclean
```

### 設定ファイルの再読込
#### bashの場合
```
source ~/.bashrc
```
#### zshの場合
```
source ~/.zshrc
```

終わり。

```
Note: ffmpeg_sources ディレクトリはアップデートやアンインストール時に必要になるので残しておきましょう。
```