前提说明:我这里是缺省安装了xampp,在xampp的基础下安装插件ffmpeg
资源地址:http://download.csdn.net/detail/u012255016/9826369
1.安装ffmpeg-php插件
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz
tar xzvf yasm-0.7.0.tar.gz
cd yasm-0.7.0
./configure
make
make install
2. 安装autoconf
tar -xzvf autoconf-2.62.tar.gz
cdautoconf-2.62
./ configure
make
make install
3.svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --enable-shared
make
make install
4.wget http://nchc.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
tar -xvjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
(找到xampp中php的该文件路径, 如xampp缺省安装下/opt/lampp/bin/phpize )
[root@dvr ffmpeg-php-0.6.0]# /opt/lampp/bin/phpize
报错:cannot find config.m4
解决:
查看php版本,安装lampp集成环境,直接在终端输入
php -v,会提示未安装php5-cli,在/etc/profile中加入php环境变量路径
vim /etc/profile
在文件末尾加入
PATH="$PATH:/opt/lampp/bin" #lampp默认安装目录
export PATH
在终端执行 source /etc/profile
5.
将 "ffmpeg-php-0.6.0中更新"中的ffmpeg_movie.c更新进ffmpeg-php-0.6.0
(xampp中的/opt/lampp/bin/ php-config 代替下面)
./configure --with-php-config=/opt/lampp/bin/ php-config
6.make
报错:
make: *** [ffmpeg_movie.lo] Error 1
解决:
vim ffmpeg_movie.c
row 311: list_entry *le; 改为zend_rsrc_list_entry *le;
row 346: list_entry new_le;改为 zend_rsrc_list_entry new_le;
row 360: hashkey_length+1, (void *)&new_le, sizeof(list_entry),改为hashkey_length+1, (void *)&new_le,sizeof(zend_rsrc_list_entry),
重新编译,
7.make test
报错:
The test-suite requires that proc_open() is available.
Please check if you disabled it in php.ini.
解决:
编辑php.ini文件,找到disable_functions去掉proc_open。
8.make install
9.vim/opt/lampp/etc/php.ini
随便地方加入: extension=ffmpeg.so
运行ffmpeg报错如下:
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory
解决:
10.vim /etc/ld.so.conf
加入一行:/usr/local/lib
然后执行 ldconfig
[root@dvr ffmpeg-php-0.6.0]# ldconfig
11.重启xampp
cd /opt/lampp/
./xampp restart
12.验证
make ffmpeg-php时,出现error 'PIX_FMT_RGBA32' undeclared...
解决方法:
vi ffmpeg_frame.c, 替换PIX_FMT_RGBA32为/PIX_FMT_RGB32
:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32
执行/usr/local/php/sbin/php-fpm restart时报错:
/usr/local/php/bin/php-cgi: symbol lookup error: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined symbol: register_ffmpeg_frame_class
failed
解决方法同上,然后重编译安装ffmpeg-php