欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

PHP里做视频截图

shiping1 的头像
目前PHP里做视频截图的相关文章太少了,不知道有谁会这方面的知识,请给个帮助!
没有办法自己找了些资料!还在看中ing。。。。。。。。。。。。。。。。。。。



FFMPEG 和 FFMPEG-PHP 的安装
[编辑] 软件下载FFmpeg 官方主页: http://ffmpeg.sourceforge.net 
cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg 

FFmpeg-php 官方主页 http://ffmpeg-php.sourceforge.net 
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg-php login 
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg-php co ffmpeg-php 

Lame 下载地址:http:// www.linuxpackages.net/sea ... ;name=lame&ver= 

Apache v2.0.54 官方主页: http://www.apache.org 
http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz 

PHP v4.3.11 官方主页: http://www.php.net 
http://cn.php.net/distributions/php-5.0.4.tar.gz 

GD Library v2.0.33 官方主页: http://www.boutell.com/gd/ 
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz 

FreeType v2.1.10 官方主页: http://www.freetype.org 
http:// savannah.nongnu.org/downl ... etype-2.1.10.tar.gz 

Jpeg v6b 官方主页: http://www.ijg.org 
http://www.ijg.org/files/jpegsrc.v6b.tar.gz 

LibPNG v1.2.8 官方主页: http://sourceforge.net/project/showfiles.php?group_id=5624 
http:// voxel.dl.sourceforge.net/ ... 1.2.8-config.tar.gz 

zlib v1.2.2 官方主页: http://www.gzip.org/zlib/ 
http://www.zlib.net/zlib-1.2.2.tar.gz 
[编辑] 开始安装
  • 解压缩
把所有源码压缩包放在一个目录中,解压缩所有 .tar.gz 和 .tar.bz2压缩包 
for i in `ls *.gz`;do tar zxvf $i; done; 
for i in `ls *.bz2`;do tar jxvf $i; done; 

  • 安装
##### lame #####lame-CVS20050706-i686-1jto.tgz解压后复制lame中./usr/include ./usr/bin ./usr/lib 三个文件夹到服务器对应地方
##### ffmpeg #####cd ffmpeg./configure --prefix=/usr/local --enable-memalign-hack --enable-mp3lame --enable-sharedmakemake installcd..cp -r /usr/local/lib/libav*.so /usr/lib注:--prefix=/usr/local不得修改,否则ffmpeg-php安装不上运行/usr/local/bin/ffmpeg –v测试是否安装成功
##### Apache2 #####cd httpd-2.0.54./configure --enable-so --prefix=/server/httpd --with-config-file-path=/server/httpd/confmakemake installcd .. 注:运行/server/httpd/bin/httpd –k start http://192.168.1.xxx测试是否安装成功测试完后要关闭/server/httpd/bin/httpd –k stop
##### FreeType #####cd freetype-2.1.10./configure --prefix=/usr/local/freetypemakemake installcd ..
##### LibPNG #####cd libpng-1.2.8./configure --prefix=/usr/local/libpng --enable-shared --enable-staticmake testmake installcd ..
##### Jpeg #####cd jpeg-6bmkdir /usr/local/jpegmkdir /usr/local/jpeg/binmkdir /usr/local/jpeg/libmkdir /usr/local/jpeg/includemkdir /usr/local/jpeg/manmkdir /usr/local/jpeg/man/man1./configure --prefix=/usr/local/jpeg --enable-shared --enable-staticmakemake installcd ..
##### zlib #####cd zlib-1.2.2./configuremakemake installcd ..
##### GD Library #####cd gd-2.0.33./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlibmakemake installcd ..
##### ffmpeg-php #####按照官方的说法,可以在装php前安装ffmpeg-php但是我没成功运行不了phpize因此此步在装了php后再进行有点傻 
##### PHP #####cd php-4.3.11./configure --prefix=/server/php --with-apxs2=/server/httpd/bin/apxs --with-gd=/usr/local/gd --enable-gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local/jpeg --with-png --with-ttf --with-zlib --with-freetype-dir=/usr/local/freetype --with-config-file-path=/server/httpd/confmakemake installcp php.ini-dist /server/httpd/conf/php.inicd ..
##### ffmpeg-php #####mv ffmpeg-php /path/to/php_sources/ext/ffmpegcd /path/to/php_sourcesautoconf./configure --prefix=/server/php --with-apxs2=/server/httpd/bin/apxs --with-gd=/usr/local/gd --enable-gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local/jpeg --with-png --with-ttf --with-zlib --with-freetype-dir=/usr/local/freetype --with-config- file-path=/server/httpd/conf --with-ffmpeg=/user/local/includemakemake install
  • 安装完毕
运行 /server/httpd/bin/httpd –k start测试<?phpinfo();?>[编辑] 如何使PHP支持ffmpeg(ffmpeg-php模块的安装)下载ffmpeg安装包地址:http://ffmpeg.mplayerhq.hu/download.html使用该命令下载ffmpeg: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg./configure --enable-share --prefix=/usrmake clean && make && make install下载ffmpeg-php安装包地址:http://ffmpeg-php.sourceforge.net/tar -xvf ffmpeg-php-0.4.9.tarmv ffmpeg-php-0.4.9 php-4.3.6/ext/ffmpegcd php-4.3.6/ext/ffmpegphpizecd /opt/software/php-4.3.6rm configure./buildconf –force第二次编译php,让它支持ffmpeg-php 
./configure --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-freetype --without-gdbm --with-gettext --with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr --with-png --enable-ftp --enable-sockets -with-xml --with-dom --with-zlib --enable-track-vars --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs --with-ffmpeg=/user/local/includemake && make install加粗为需要注意的地方,路径或参数不同会造成无法加载ffmpeg.so的错误.错误提示如:Warning: dl(): Not supported in multithreaded Web servers - use extension statements in your php.ini加粗为需要注意的地方,路径或参数不同会造成无法加载ffmpeg.so的错误.错误提示如:Warning: dl(): Not supported in multithreaded Web servers - use extension statements in your php.ini有关该问题的讨论帖可参考ffmpeg工程组论坛中的相关讨论: 
FFMPEG 和 FFMPEG-PHP 的安装[编辑] 获取ffmpeg源代码 This tutorial is about transcoding video fom one codec into another using FFMPEG. I got deeper into FFMPEG when I wanted to transcode into FLV (Flash Video) and it works very well. I developed the Riva FLV Encoder, a GUI for FFMPEG. 
Update 26.10.2006: This tutorial is a little outdated as there were many changes in FFMPEG like the switch from CVS to Subversion and the workflow to compile FFMPEG under Windows has become more difficult. For the new tweaks check this tutorial. 
  • Download MinGW " MSYS current releases (Window Exe Binaries MSYS-1.0.10.exe & MinGW-3.1.0-1.exe)
Install MinGW Install MSYS HINT: During the Postinstall be sure to set the right path to MinGW with a "/" instead of a Windows-"". If you did it wrong anyway re-install MSYS to the same directory and do the postinstall right (I missed it a few times)
  • Download and compile Lame
Extract Lame to your MSYS home-directory Open MSYS and change to your lame-directory (cd ../lame-XXX) Enter the following commands: ./configure //(takes a few minutes)make //(lame is being comiled; takes a few minutes, too)make installAfter installing you will recognize that there are new directories and files in MSYS/local which we will use while compiling ffmpeg with mp3-supportCheck out the sourcecode from svn://svn.mplayerhq.hu/ffmpeg
  • Compile FFMPEG
Change the directory in MSYS to your ffmpeg-directory (cd ../ffmpeg) Enter the command: ./configure --enable-memalign-hack --enable-mingw32 --enable-mp3lame --extra-cflags=-I/local/include --extra-ldflags=-L/local/libHINT: you can paste into MSYS by pressing your center mouse-button 1. "--enabled-memalign-hack" is a Windows hack. Without this option ffmpeg always crashs with the message "removing common factors from framerate" when encoding AVIs. 2. "--enable-mingw32". I see no difference without it but we compile with MinGW and it would not do a harm when ffmpeg knows this 3. "--enable-mp3lame": Enable transcoding audio with the open-source mp3-lame-codec 4. "--extra-cflags=-I/local/include --extra-ldflags=-L/local/lib": The cflags- and ldflags-parameter sets the right path to your lame-installation which you did in step 3.d. Enter command: make (ffmpeg is being compiled; takes a few minutes) With "make install" you could now copy the ffmpeg.exe to c:Program Filesffmpeg. But there is no need to. 
MSYS是什么,他与CYGWIN有什么区别? 
[编辑] Use FFMPEG Copy your compiled ffmpeg.exe from your MSYS directory to the directory where you like to transcode with ffmpeg Open the Dos-Shell and change to the directory where you copied the ffmpeg.exe Copy a test.mpg into your directory and enter the following command: ffmpeg -i test.mpg -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flvYour first FLV should be encoded now 
[编辑] Render Images from a Video Enter command: 
ffmpeg -an -y -t 0:0:0.001 -i test.flv -f image2 test%d.jpgHINT: With -t you set the length of images to be extracted. Above we entered 1 millisecond the extract one image. If you miss this parameter all images of the video will be extracted 
[编辑] ZLib Support (e.g. for TSCC and Quicktime codecs). This should be compiled into FFMPEG. It is not an explicit compile in the configure statement. Do the following steps and after configure you should see that zlib is "on". 
Download and compile ZLib Extract the files to your mysys directory Change the directory in MSYS to that directory Enter command ./confuguremakemake install.[编辑] AC3 Support Add "--enable-a52 --enable-gpl" to your configure command 

[编辑] 3GP Support If you want to enable 3GP support you have to add the AMR audio codec. Download the TS26.104 REL-5 V5.1.0 26104-5??.zip here. Extract the codec into libavcodec/amr_float and add "--enable-amr_nb" to your configure command 

[编辑] XVID Support (thanks to garvin.thornten at datel.co.uk) Download and install the codec from www.xlib.org (see xvidcore-xxxx/doc/install). Add "--enable-xvid --enable-gpl" to your configure command. When compiling with xvid codec in MinGW or cygwin you will get a "mkstemp" error when compiling "xvidff.c". To fix this edit "libavcodec/xvidff.c" and add the following after the #includes. This will probably be fixed in a future ffmpeg release: &acute; 

/* Added for windows compile ----------------- */#include int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); void xvid_correct_framerate(AVCodecContext *avctx); int mkstemp(char* template)char temppath[512];if(GetTempPath(512,temppath)!=0){ if(GetTempFileName(temppath,"fil",0,template)!=0) {  FILE *pFile;  pFile=fopen(template,"w+");  if(pFile!=NULL)  return (int)pFile; }} return -1;}/* ------------------------------------------- */
来自  http://bbs.phpchina.com/forum.php?mod=viewthread&tid=45671

也有人说  安装个php的扩展就好了  php_ffmpeg
然后用它的函数操作即可
普通分类: