Example of using php5-ffmpeg to capture video images in PHP,
When I was playing with FFmpeg a few days ago, I suddenly discovered that there is an extension package called php5-ffmpeg on Ubuntu. I wanted to play with it and see if it works. I came to two conclusions:
Reading videos depends on the support of FFmpeg. If you want to support all formats, it is recommended to recompile FFmpeg yourself.
The efficiency is not as fast as I thought. It takes ten pictures for a two-minute video, which takes about 30 seconds.
Installation method:
Copy code The code is as follows:
sudo apt-get install ffmpeg php5-ffmpeg php5-gd
Image capture test example:
Copy code The code is as follows:
$page = 10;
$prefix = 'screencap';
$mov = new ffmpeg_movie('gt.avi');
$count = $mov->getFrameCount();
$range = (int)round($count/($page+1));
for($i=1; $i<=$page; $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 '
';
}
http://www.bkjia.com/PHPjc/939418.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/939418.htmlTechArticleExample of using php5-ffmpeg to capture video images in PHP. When I was playing with FFmpeg a few days ago, I suddenly discovered There is an extension package called php5-ffmpeg on Ubuntu, so I wanted to play it and see if it is good...
Statement: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