2012-08-28 86 views
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

+0

'14號線'實際上是哪條線? – pduersteler

+0

$ oldWid = $ mkNewImg-> getWidth(); – Arun

回答

0

你需要使用GD庫函數來顯示圖像$showImg = $img->toGDImage();後。 GD還支持調整大小:)