php调用ffpmpeg解码

1、安装ffmpeg
centos5.4系统
添加源如下
root@localhost: /opt/php-5.3.5/ext/ffmpeg-php-0.6.0# cat /etc/yum.repos.d/dag.repo 
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1

安装
yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc

ffmpeg测试
root@localhost: /opt/php-5.3.5/ext/ffmpeg-php-0.6.0# ffmpeg 
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 23:55:02 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
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

安装ffmpeg-php扩展
http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download?use_mirror=jaist&use_mirror=ncu

bunzip2 -d ffmpeg-php-0.6.0.tbz2
tar xvf ffmpeg-php-0.6.0.tar 
/home/system/php/bin/phpize 
./configure --with-php-config=/home/system/php/bin/php-config --enable-shared --prefix=/usr
make
make  install

echo "extension=ffmpeg.so"  >> /home/system/php/lib/php.ini
如果发现错误提示:make: *** [ffmpeg_frame.lo] Error 1
在源码目录
mv ffmpeg_frame.loT ffmpeg_frame.lo 

如果有ffmepg-php模块错误提示:php: symbol lookup error: /home/system/php/lib/php/extensions/no-debug-zts-20090626/ffmpeg.so: undefined symbol: register_ffmpeg_frame_class
则修改ffmpeg_frame.c,将3处的PIX_FMT_RGBA32 更改为PIX_FMT_RGB32重新安装。

# /home/system/php/bin/php -m |grep ffmpeg
ffmpeg

# /home/system/php/bin/php -r 'phpinfo();' | grep ffmpeg
PHP Warning:  phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in Command line code on line 1
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Feb 22 2013 18:20:52
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc52.72.2
ffmpeg libavformat version => Lavf52.64.2
ffmpeg swscaler version => SwS0.11.0
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
PWD => /opt/php-5.3.5/ext/ffmpeg-php-0.6.0
_SERVER["PWD"] => /opt/php-5.3.5/ext/ffmpeg-php-0.6.0

One Reply to “php调用ffpmpeg解码”

发表评论

电子邮件地址不会被公开。 必填项已用*标注