CentOS 7にffmpeg, ffmpeg-phpをソースからインストールしてみました。
ffmpeg-phpをインストールするにはshared libraryが必要そうなのでオプションを変更しています。
- 開発環境
- Yasm
- libx264
- libx265
- libfdk_aac
- libmp3lame
- libopus
- libogg
- libvorbis
- libvpx
- ffmpeg
- ffmpeg shared library path
- ffmpeg-php
- phpにffmpeg.soの組込み
最初に下記を実行して必要な開発環境を導入しておきます。
1 |
# yum install autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel |
Yasmはx264とFFmpegをコンパイルする時に必要になります。
1 2 3 4 5 6 7 8 9 |
# mkdir /usr/local/src/ffmpeg_sources/ # cd /usr/local/src/ffmpeg_sources/ # git clone --depth 1 https://github.com/yasm/yasm.git # cd yasm/ # autoreconf -fiv # ./configure # make # make install # make distclean |
1 2 3 4 5 6 7 |
# cd /usr/local/src/ffmpeg_sources/ # git clone http://git.videolan.org/git/x264.git # cd x264/ # ./configure --enable-shared # make # make install # make distclean |
1 2 3 4 5 6 |
# cd /usr/local/src/ffmpeg_sources/ # hg clone https://bitbucket.org/multicoreware/x265 # cd x265/build/linux/ # cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=on ../../source # make # make install |
1 2 3 4 5 6 7 8 |
# cd /usr/local/src/ffmpeg_sources/ # git clone git://git.code.sf.net/p/opencore-amr/fdk-aac # cd fdk-aac/ # autoreconf -fiv # ./configure --enable-shared # make # make install # make distclean |
1 2 3 4 5 6 7 8 |
# 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 --enable-shared --enable-nasm # make # make install # make distclean |
1 2 3 4 5 6 7 8 |
# cd /usr/local/src/ffmpeg_sources/ # git clone git://git.opus-codec.org/opus.git # cd opus/ # autoreconf -fiv # ./configure --enable-shared # make # make install # make distclean |
1 2 3 4 5 6 7 8 9 10 |
# yum -y install libtheora # yum -y install libvorbis # cd /usr/local/src/ffmpeg_sources/ # curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz # tar xzvf libogg-1.3.2.tar.gz # cd libogg-1.3.2 # ./configure --enable-shared # make # make install # make distclean |
1 2 3 4 5 6 7 8 |
# cd /usr/local/src/ffmpeg_sources/ # curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz # tar xvfz libvorbis-1.3.5.tar.gz # cd libvorbis-1.3.5 # ./configure --enable-shared # make # make install # make distclean |
1 2 3 4 5 6 7 |
# cd /usr/local/src/ffmpeg_sources/ # git clone https://chromium.googlesource.com/webm/libvpx.git # cd libvpx # ./configure --enable-shared --disable-examples # make # make install # make clean |
1 2 3 4 5 6 7 8 |
# cd /usr/local/src/ffmpeg_sources/ # curl -O http://ffmpeg.org/releases/ffmpeg-2.8.6.tar.bz2 # tar xvfj ffmpeg-2.8.6.tar.bz2 # cd ffmpeg-2.8.6 # PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --enable-shared --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 # make # make install # make distclean |
このままではshared libraryが見当たらなくてエラーになります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# ffmpeg ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory # ldd `which ffmpeg` linux-vdso.so.1 => (0x00007ffffc25a000) libavdevice.so.56 => not found libavfilter.so.5 => not found libavformat.so.56 => not found libavcodec.so.56 => not found libpostproc.so.53 => not found libswresample.so.1 => not found libswscale.so.3 => not found libavutil.so.54 => not found libm.so.6 => /lib64/libm.so.6 (0x00007f45fc901000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f45fc6e5000) libc.so.6 => /lib64/libc.so.6 (0x00007f45fc323000) /lib64/ld-linux-x86-64.so.2 (0x00007f45fcc0e000) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# vi /etc/ld.so.conf # cat /etc/ld.so.conf include ld.so.conf.d/*.conf /usr/local/lib # ldconfig # ldd `which ffmpeg` linux-vdso.so.1 => (0x00007ffee4b47000) libavdevice.so.56 => /usr/local/lib/libavdevice.so.56 (0x00007f99567ef000) libavfilter.so.5 => /usr/local/lib/libavfilter.so.5 (0x00007f9956472000) libavformat.so.56 => /usr/local/lib/libavformat.so.56 (0x00007f9956089000) libavcodec.so.56 => /usr/local/lib/libavcodec.so.56 (0x00007f9954d44000) libpostproc.so.53 => /usr/local/lib/libpostproc.so.53 (0x00007f9954b24000) libswresample.so.1 => /usr/local/lib/libswresample.so.1 (0x00007f9954909000) libswscale.so.3 => /usr/local/lib/libswscale.so.3 (0x00007f9954683000) libavutil.so.54 => /usr/local/lib/libavutil.so.54 (0x00007f995441b000) libm.so.6 => /lib64/libm.so.6 (0x00007f9954118000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f9953efc000) libc.so.6 => /lib64/libc.so.6 (0x00007f9953b3b000) libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f9953894000) libz.so.1 => /lib64/libz.so.1 (0x00007f995367e000) libx265.so.81 => /usr/local/lib/libx265.so.81 (0x00007f99530c5000) libx264.so.148 => /usr/local/lib/libx264.so.148 (0x00007f9952d2a000) libvpx.so.3 => /usr/local/lib/libvpx.so.3 (0x00007f995294a000) libvorbisenc.so.2 => /usr/local/lib/libvorbisenc.so.2 (0x00007f995269f000) libvorbis.so.0 => /usr/local/lib/libvorbis.so.0 (0x00007f9952468000) libopus.so.0 => /usr/local/lib/libopus.so.0 (0x00007f995221f000) libmp3lame.so.0 => /usr/local/lib/libmp3lame.so.0 (0x00007f9951f90000) libfdk-aac.so.1 => /usr/local/lib/libfdk-aac.so.1 (0x00007f9951cdd000) /lib64/ld-linux-x86-64.so.2 (0x00007f9956a06000) librt.so.1 => /lib64/librt.so.1 (0x00007f9951ad5000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f99518d0000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f99515c8000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f99513b2000) libogg.so.0 => /usr/local/lib/libogg.so.0 (0x00007f99511aa000) # ffmpeg ffmpeg version 2.8.6 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --enable-shared --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.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' |
1 2 3 4 5 6 7 8 9 |
# cd /usr/local/src/ffmpeg_sources/ # git clone https://github.com/tony2001/ffmpeg-php.git # cd ffmpeg-php/ # yum -y install php-devel # phpize # ./configure # make # make install # make distclean |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# php -i | grep ffmpeg OLDPWD => /usr/local/src/ffmpeg_sources PWD => /usr/local/src/ffmpeg_sources/ffmpeg-php _SERVER["OLDPWD"] => /usr/local/src/ffmpeg_sources _SERVER["PWD"] => /usr/local/src/ffmpeg_sources/ffmpeg-php # vi /etc/php.d/ffmpeg.ini # cat /etc/php.d/ffmpeg.ini ; Enable ffmpeg extension module extension=ffmpeg.so # php -m | grep ffmpeg ffmpeg # php -i | grep ffmpeg /etc/php.d/ffmpeg.ini, ffmpeg ffmpeg-php version => 0.7.0 ffmpeg-php built on => Mar 1 2016 12:04:19 ffmpeg-php gd support => enabled (snip) |
これでいいのかな。