PHP中使用php5-ffmpeg撷取视频图片实例_php技巧

WBOY
Release: 2016-05-16 20:26:16
Original
1012 people have browsed it

前几天在玩 FFmpeg 的时后,突然发现 Ubuntu 上多了 php5-ffmpeg 这个扩充套件,就想来玩玩看,看好不好用,有两个结论:
读取影片取决于 FFmpeg 的支援性,如果想要什么格式都支援的话,建议自己重新编译 FFmpeg。
效率并没有我想像中的快,两分钟的影片取十张图,大约 30 秒。
安装方法:

复制代码 代码如下:

sudo apt-get install ffmpeg php5-ffmpeg php5-gd

撷图测试范例:
复制代码 代码如下:

$page = 10;   
$prefix = 'screencap';   
   
$mov = new ffmpeg_movie('gt.avi');   
$count = $mov->getFrameCount();   
$range = (int)round($count/($page+1));   
   
for($i=1; $i    $frameNum = $range*$i;   
   $imgFile = $prefix.'_'.$i.'.png';   
   
   $frame = $mov->getFrame($frameNum);   
   if(!$frame){ continue; }   
   
   $gdImage = $frame->toGDImage();   
   if(!$gdImage){ continue; }   
   
   imagepng($gdImage, $imgFile);   
   imagedestroy($gdImage);   
   
   echo 'PHP中使用php5-ffmpeg撷取视频图片实例_php技巧
';   
}  
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!