1

This is my php code to generate thumbnail of a video frame.

    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);

When i execute this script i got error like

Fatal error: Unable to locate ffmpeg_frame resource in this object. in C:\xampp\htdocs\ffmpeg\ffmpeg.php on line 14

4

1 回答 1

0

之后$showImg = $img->toGDImage();需要使用GD库函数来显示图像。GD 也支持调整大小 :)

于 2012-09-22T21:46:57.637 回答