Home > Backend Development > PHP Tutorial > Example of using php5-ffmpeg to capture video images in PHP, _PHP tutorial

Example of using php5-ffmpeg to capture video images in PHP, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:09:57
Original
1025 people have browsed it

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 '
';
}

www.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...
Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template