1
這是我的PHP代碼來生成視頻幀的縮略圖。使用ffmpeg在PHP中創建縮略圖不起作用
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
$vid = realpath('./Wildlife.wmv');
header("Content-type: image/jpeg");
$moviefile = $vid;
$mov = new ffmpeg_movie($moviefile,false);
$img = $mov->getFrame(10);
$showImg = $img->toGDImage();
$mkNewImg = new ffmpeg_frame($showImg);
$maxWid = 150;
$oldWid = $mkNewImg->getWidth();
if($oldWid > $maxWid) {
$newWid = $maxWid;
}
$newHgt = $newWid/$movRatio;
$mkNewImg->resize($newWid,$newHgt);
$newImg = $mkNewImg->toGDImage();
imagejpeg($newImg,$mkThumbFile,40);
imagedestroy($newImg);
當我執行這個腳本我有錯誤,如
Fatal error: Unable to locate ffmpeg_frame resource in this object. in C:\xampp\htdocs\ffmpeg\ffmpeg.php on line 14
'14號線'實際上是哪條線? – pduersteler
$ oldWid = $ mkNewImg-> getWidth(); – Arun