CentOS 7にffmpeg, ffmpeg-phpをインストールしてみました。
FFmpeg
https://www.ffmpeg.org/
最新版は3.4.1です。
今回はRHEL/CentOSパッケージとして公式サイトからリンクされているRPM Fusion repositoryを使います。
RPM Fusion
https://rpmfusion.org/RPM%20Fusion
環境
・CentOS Linux release 7.4.1708 (Core)
・Kernel 3.10.0-693.11.6.el7.x86_64
- RPM Fusion free Repositoryのインストール
- FFmpegのインストール
- ffmpeg-phpのダウンロード
- ffmpeg-phpのインストール
- phpに組込み
RPM Fusionにはfreeとnonfreeがありました。
Installing Free and Nonfree Repositories
https://rpmfusion.org/Configuration
商用利用できないとかのライセンス関係だと思うのですが、無難にOSSのfree repositoryを使ってみます。
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 |
# rpm -ivh https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm Retrieving https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm warning: /var/tmp/rpm-tmp.AAF5oz: Header V4 RSA/SHA1 Signature, key ID f5cf6c1e: NOKEY Preparing... ################################# [100%] Updating / installing... 1:rpmfusion-free-release-7-1 ################################# [100%] # cat /etc/yum.repos.d/rpmfusion-free-updates.repo [rpmfusion-free-updates] name=RPM Fusion for EL 7 - Free - Updates #baseurl=http://download1.rpmfusion.org/free/el/updates/7/$basearch/ mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-el-updates-released-7&arch=$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-7 [rpmfusion-free-updates-debuginfo] name=RPM Fusion for EL 7 - Free - Updates Debug #baseurl=http://download1.rpmfusion.org/free/el/updates/7/$basearch/debug/ mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-el-updates-released-debug-7&arch=$basearch enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-7 [rpmfusion-free-updates-source] name=RPM Fusion for EL 7 - Free - Updates Source #baseurl=http://download1.rpmfusion.org/free/el/updates/7/SRPMS/ mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-el-updates-released-source-7&arch=$basearch enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-7 |
FFmpegをインストールします。Version 2.8.13でした。
また後ほどffmpeg-phpのインストールのためにffmpeg-develもインストールします。
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 |
# yum info ffmpeg Available Packages Name : ffmpeg Arch : x86_64 Version : 2.8.13 Release : 1.el7 Size : 1.3 M Repo : rpmfusion-free-updates/x86_64 Summary : Digital VCR and streaming server URL : http://ffmpeg.org/ License : GPLv3+ Description : FFmpeg is a complete and free Internet live audio and video : broadcasting solution for Linux/Unix. It also includes a digital : VCR. It can encode in real time in many formats including MPEG1 audio : and video, MPEG4, h263, ac3, asf, avi, real, mjpeg, and flash. # yum -y install ffmpeg ffmpeg-devel (snip) # ffmpeg -h ffmpeg version 2.8.13 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect 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 libavresample 2. 1. 0 / 2. 1. 0 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}... (snip) |
tony2001/ffmpeg-php
https://github.com/tony2001/ffmpeg-php
もともとはhttp://ffmpeg-php.sourceforge.netで開発されていたのですが停止してしまったので、Antony Dovgal氏が最近のPHPバージョンで動作させるために必要な最低限の変更をしたものです。
最近はPHP-FFmpegが使われることが多いのでしょうか?
PHP-FFMpeg/PHP-FFMpeg
https://github.com/PHP-FFMpeg/PHP-FFMpeg
1 2 3 4 5 6 7 8 |
# git clone https://github.com/tony2001/ffmpeg-php.git Cloning into 'ffmpeg-php'... remote: Counting objects: 1898, done. remote: Total 1898 (delta 0), reused 0 (delta 0), pack-reused 1898 Receiving objects: 100% (1898/1898), 2.48 MiB | 1.31 MiB/s, done. Resolving deltas: 100% (1491/1491), done. # cd ffmpeg-php/ |
1 2 3 |
# phpize Can't find PHP headers in /usr/include/php The php-devel package is required for use of this command. |
php-develがインストールされていなかったのでエラーになりました。
1 |
# yum -y install php-devel |
1 2 3 4 5 6 7 8 9 10 |
# phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 # ./configure checking for grep that handles long lines and -e... /usr/bin/grep (snip) checking for ffmpeg headers... configure: error: ffmpeg headers not found. Make sure ffmpeg is compiled as shared libraries using the --enable-shared option |
今度はconfigure: error: ffmpeg headers not found.です。
ffmepg-develもインストールしてあるのに…?
ありました。
configure: error: ffmpeg headers not found. #24
https://github.com/tony2001/ffmpeg-php/issues/24
ffmpeg-devel installs headers in /usr/include/ffmpeg and php-ffmpeg expects them in /usr/include.
Just copy or symlink all folders from within /usr/include/ffmpeg in /usr/include.
1 2 3 4 5 |
# ls /usr/include/ffmpeg/ libavcodec libavfilter libavresample libpostproc libswscale libavdevice libavformat libavutil libswresample # ln -s /usr/include/ffmpeg/* /usr/include/ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# ./configure checking for grep that handles long lines and -e... /usr/bin/grep (snip) configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands # make /bin/sh /root/ffmpeg-php/libtool --mode=compile cc -I. -I/root/ffmpeg-php -DPHP_ATOM_INC -I/root/ffmpeg-php/include -I/root/ffmpeg-php/main -I/root/ffmpeg-php -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/ffmpeg-php/ffmpeg-php.c -o ffmpeg-php.lo (snip) Build complete. Don't forget to run 'make test'. # make install Installing shared extensions: /usr/lib64/php/modules/ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 => Feb 1 2018 11:33:55 ffmpeg-php gd support => enabled ffmpeg libavcodec version => Lavc56.60.100 ffmpeg libavcodec license => GPL version 3 or later ffmpeg libavformat version => Lavf56.40.101 ffmpeg libavformat license => GPL version 3 or later ffmpeg swscaler version => SwS3.1.101 ffmpeg swscaler license => GPL version 3 or later ffmpeg codec_list => a64multi(v), a64multi5(v), (snip) |
今回はmake testで5つのエラーが出ていました(^^;
何かが不足しているんですね。
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# make test Build complete. Don't forget to run 'make test'. ===================================================================== PHP : /usr/bin/php PHP_SAPI : cli PHP_VERSION : 5.4.16 ZEND_VERSION: 2.4.0 PHP_OS : Linux - Linux centos7.rootlinks.net 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018 x86_64 INI actual : /root/ffmpeg-php/tmp-php.ini More .INIs : CWD : /root/ffmpeg-php Extra dirs : VALGRIND : Not used ===================================================================== TIME START 2018-02-02 02:34:48 ===================================================================== PASS ffmpeg getAudioBitRate test [tests/getAudioBitRate.phpt] PASS ffmpeg getAudioChannels test [tests/getAudioChannels.phpt] PASS ffmpeg getAudioCodec test [tests/getAudioCodec.phpt] PASS ffmpeg getAudioSampleRate test [tests/getAudioSampleRate.phpt] PASS ffmpeg getAudioStreamId test [tests/getAudioStreamId.phpt] FAIL ffmpeg getBitRate test [tests/getBitRate.phpt] FAIL ffmpeg getDuration test [tests/getDuration.phpt] PASS ffmpeg getFileName test [tests/getFileName.phpt] SKIP ffmpeg getFrame test [tests/getFrame.phpt] reason: gd extension not avaliable. FAIL ffmpeg getFrameCount test [tests/getFrameCount.phpt] PASS ffmpeg getFrameHeight test [tests/getFrameHeight.phpt] PASS ffmpeg getFrameNumber test [tests/getFrameNumber.phpt] PASS ffmpeg getFrameRate test [tests/getFrameRate.phpt] SKIP ffmpeg getFrameResampled test [tests/getFrameResampled.phpt] reason: gd extension not avaliable. PASS ffmpeg getFrameWidth test [tests/getFrameWidth.phpt] SKIP ffmpeg getFrames forward test [tests/getFramesForward.phpt] reason: gd extension not avaliable. SKIP ffmpeg getFrames forward test [tests/getFramesForwardPassedEnd.phpt] reason: gd extension not avaliable. SKIP ffmpeg getFrame in reverse order test [tests/getFramesInReverseOrder.phpt] reason: gd extension not avaliable. SKIP ffmpeg getFramesNoArg test [tests/getFramesNoArg.phpt] reason: gd extension not avaliable. FAIL ffmpeg getID3Info() test [tests/getID3Info.phpt] SKIP ffmpeg get key frames test [tests/getNextKeyFrame.phpt] reason: gd extension not avaliable. SKIP ffmpeg getPTS test (Fixme: This test is no good with robot.avi) [tests/getPTS.phpt] reason: because robot.avi doesn't have reasonable pts info PASS ffmpeg getPixelAspectRatio test [tests/getPixelAspectRatio.phpt] PASS ffmpeg getPixelFormat test [tests/getPixelFormat.phpt] PASS ffmpeg getVideoBitRate test [tests/getVideoBitRate.phpt] PASS ffmpeg getVideoCodec test [tests/getVideoCodec.phpt] PASS ffmpeg getVideoStreamId test [tests/getVideoStreamId.phpt] PASS ffmpeg hasAudio test [tests/hasAudio.phpt] SKIP ffmpeg test key frame [tests/isKeyFrame.phpt] reason: gd extension not avaliable. FAIL ffmpeg persistent movie test [tests/persistentMovie.phpt] ===================================================================== TIME END 2018-02-02 02:34:49 ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped : 0 Exts tested : 30 --------------------------------------------------------------------- Number of tests : 30 21 Tests skipped : 9 ( 30.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 5 ( 16.7%) ( 23.8%) Expected fail : 0 ( 0.0%) ( 0.0%) Tests passed : 16 ( 53.3%) ( 76.2%) --------------------------------------------------------------------- Time taken : 1 seconds ===================================================================== ===================================================================== FAILED TEST SUMMARY --------------------------------------------------------------------- ffmpeg getBitRate test [tests/getBitRate.phpt] ffmpeg getDuration test [tests/getDuration.phpt] ffmpeg getFrameCount test [tests/getFrameCount.phpt] ffmpeg getID3Info() test [tests/getID3Info.phpt] ffmpeg persistent movie test [tests/persistentMovie.phpt] ===================================================================== You may have found a problem in PHP. This report can be automatically sent to the PHP QA team at http://qa.php.net/reports and http://news.php.net/php.qa.reports This gives us a better understanding of PHP's behavior. If you don't want to send the report immediately you can choose option "s" to save it. You can then email it to qa-reports@lists.php.net later. Do you want to send this report now? [Yns]: |