PHP完全自学手册(珍藏版) 中文pdf扫描版下载
安装 ffmpeg-php 截取视频缩略图
vim /etc/yum.repos.d/dag.repo
安装ffmpeg-php
首先make clean

/usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

执行
echo "extension=ffmpeg.so" >> /usr/local/php/etc/php.ini
重启service php-fpm restart

就完美的安装成功了
具体查看手册
http://ffmpeg-php.sourceforge.net/doc/api/
获取视频截图
Windows 系统
-
下载
ffmpeg-php
:http://sergey89.ru/files/ffmpeg-php/ -
解压
ffmpeg-php-win32-all.zip
后有下面几个文件:
- avcodec-51.dll
- avformat-51.dll
- avutil-49.dll
- php_ffmpeg.dll
- pthreadGC2.dll
将四个文件拷贝到
windows/system32
文件夹下面:
- avcodec-51.dll, avformat-51.dll, avutil-49.dll, pthreadGC2.dll
将
php_ffmpeg.dll
拷贝到php
的ext
目录下。
然后需要到apache/bin
文件下找到php.ini
文件下允许使用dll
文件加入extension=php_ffmpeg.dll
并允许extension=php_gd2.dll
,extension=php_gettext.dll
这两个设置。(去掉前面的分号)
- extension=php_gd2.dll
- extension=php_gettext.dll
- extension=php_ffmpeg.dll
-
重新启动
apache
后使用phpinfo()
函数看到一下信息配置,搜索页面中的ffmpeg
,如果有就表明ffmpeg在php环境中配置成功了。 -
更多的使用请参考API
Linux下安装
vim /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
下载这个版本,己修改了bug
http://img.kuitao8.com/uploads/2016/0225/20160225105634202.zip
先解压

#安装 Install ffmpeg 等模块
yum -y install ffmpeg ffmpeg-devel
测试看安装好没

下载ffmpeg-php
测试看安装好没

下载ffmpeg-php
http://img.kuitao8.com/uploads/2016/0225/20160225105634202.zip
先解压

安装ffmpeg-php
首先make clean

/usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

执行
echo "extension=ffmpeg.so" >> /usr/local/php/etc/php.ini
重启service php-fpm restart

就完美的安装成功了
具体查看手册
http://ffmpeg-php.sourceforge.net/doc/api/
获取视频截图
- <?php
- $movie = new ffmpeg_movie('4.mp4');
- $width=$movie->getFrameWidth();
- $height=$movie->getFrameHeight();
- $count= $movie->getFrameCount();
- print $count . '<br />';
- $n = round ( $count/16 );
- print $n . '<br />';
- for ( $i = 1; $i <= 16; $i ++ ) {
- $img = 'screencap' . $i . '.png';
- $x = $n * $i;
- $f = $movie->getFrame($x);
- $gd_image = $f->toGDImage();
- imagepng($gd_image, $img);
- imagedestroy($gd_image);
- echo "<center><img src=\"$img\" border=\"1\" alt=\"Scrren Capture\" /></center>\n";
- }
- ?>
转载请注明:谷谷点程序 » php获取视频截图的方法