Centos5.5 下安装ffmpeg-php笔记

来源:互联网 发布:用启动盘安装mac 编辑:程序博客网 时间:2024/05/20 09:08


因为PHP项目需要取得mp3和m4a的时长和比特率,所以折腾ffmpeg-php,记录如下:


一 安装步骤

1. 安装必须的环境yasm

yum -y install yasm
或者
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz

tar zxvf yasm-0.7.0.tar.gz

cd yasm-0.7.0

./configure

make && make install


2. 安装ffmpeg (官方地址:http://www.ffmpeg.org/)

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd  ffmpeg
./configure --enable-shared
make
make install


3. 安装ffmpeg-php

下载地址:http://ffmpeg-php.sourceforge.net/
tar jxvf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make &&make install
vi /usr/local/php/etc/php.ini

    加入: extension=ffmpeg.so

/usr/local/php/sbin/php-fpm restart

[完成]

二 错误解决

1. 运行ffmpeg出现的异常:ffmpeg: error while loading shared libraries: libavdevice.so.52 : cannot open shared object file: No such file or directory

解决方法:

vi /etc/ld.so.conf
加入一行:/usr/local/lib
然后执行 ldconfig

2. 运行ffmpeg出现的类似异常:ffmpeg: error while loading shared libraries: /usr/local/lib/libx264.so.107: cannot restore segment prot after reloc: Permission denied

解决方法:
chcon -t texrel_shlib_t /usr/local/lib/libavutil.so.50
chcon -t texrel_shlib_t /usr/local/lib/libavcore.so.0
chcon -t texrel_shlib_t /usr/local/lib/libswscale.so.0
chcon -t texrel_shlib_t /usr/local/lib/libavcodec.so.52
chcon -t texrel_shlib_t /usr/local/lib/libavformat.so.52
chcon -t texrel_shlib_t /usr/local/lib/libavfilter.so.1
chcon -t texrel_shlib_t /usr/local/lib/libavdevice.so.52

---以上是旧版,以下是新版---------

chcon -t texrel_shlib_t /usr/local/lib/libavutil.so.51
chcon -t texrel_shlib_t /usr/local/lib/libswscale.so.2
chcon -t texrel_shlib_t /usr/local/lib/libswresample.so.0
chcon -t texrel_shlib_t /usr/local/lib/libavcodec.so.54
chcon -t texrel_shlib_t /usr/local/lib/libavformat.so.54
chcon -t texrel_shlib_t /usr/local/lib/libavfilter.so.2
chcon -t texrel_shlib_t /usr/local/lib/libavdevice.so.53


3.make ffmpeg-php时,出现make: *** [ffmpeg_frame.lo] Error 1

解决方法:

mv ffmpeg_frame.loT ffmpeg_frame.lo


4.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  


5. 执行/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
解决方法同4,然后重编译安装ffmpeg-php


三 参考资料

1.CentOS 5.5安装FFmpeg、Mencoder、FFmpeg-PHP、Flvtool2

http://www.grapenvine.cn/?post=17

2.ffmpeg-php在CentOS上的快速安装

http://www.coolni.cn/me/?post=56

3.CENTOS Apache 2 + PHP 5.3 + Mysql5 installation (additional: for gallery3 prepare)

http://blog.csdn.net/totogogo/article/details/6224095

4.ffmpeg编译

http://lishuangxing06.blog.163.com/blog/static/93197189201011138131792/

5.ffmpeg命令详解

http://www.coolni.cn/me/?post=57

6.ffmpeg-php api

http://ffmpeg-php.sourceforge.net/doc/api/ffmpeg_movie.php

7.ffmpeg-php 安装及出错解决办法

http://blog.sina.com.cn/s/blog_55768a1c0100jfct.html

8.centos 5.6 安装 ffmpeg

http://www.freebsdsystem.org/centos_install_ffmpeg/


原创粉丝点击