Here’s how to install it, based on Gutsy.
(Looks like hardy has a package here: http://packages.ubuntu.com/source/hardy/ffmpeg-php)
ffmpeg-php homepage: http://ffmpeg-php.sourceforge.net/
API docs: http://ffmpeg-php.sourceforge.net/doc/api/
php needs to be the dev build (php5-dev),
and assuming ffmpeg is already installed, install the needed packages:
apt-get install ffmpeg libavformat-dev libavcodev-dev liblame-dev
Then build and install:
phpize5
./configure
make
make install
Register the extension in php — add this at the end of php.ini:
extension=ffmpeg.so
As an example, here’s how to pull 6 thumbnails from a video:
$destination = 'video.avi';
$movie = new ffmpeg_movie($destination);
$total_frames = $movie->getFrameCount();
$per_frame = round($total_frames / 6);
$start_frame = $per_frame / 2;
$count = 0;
for($i = $start_frame; $i < $total_frames; $i = $i + $per_frame) {
if($count > 5) {
break;
}
$frame = $movie->getFrame($i);
if($frame) {
$frame->resize(400, 300);
$GDimage = $frame``->toGDImage();
$filename = sprintf("%04d", $count) . '.png';
imagepng($GDimage, $filename);
$count++;
}
}