Ubuntu 에서 FFMPEG-PHP 설치하기
일단 gusty 기준으로 설치법
(hardy 에는 http://packages.ubuntu.com/source/hardy/ffmpeg-php 패키지가 있는모양이다)
ffmpeg-php 홈페이지 http://ffmpeg-php.sourceforge.net/
API document http://ffmpeg-php.sourceforge.net/doc/api/
php는 dev버젼으로 설치되어있어야하고 (php5-dev)
ffmpeg은 설치되어있다는 가정하에 필요한 패키지를 설치하고
apt-get install ffmpeg libavformat-dev libavcodev-dev liblame-dev
빌드후 설치
phpize5
./configure
make
make install
php 에 확장 등록. php.ini 끝에
extension=ffmpeg.so
예시로 6장의 동영상 썸네일을 뽑아보기
$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++;
}
}