Method | Description |
$frame = new ffmpeg_frame(Resource gd_image) | Create a frame object from a GD image. NOTE: This function will not be available if GD is not enabled. |
$frame->getWidth() | Return the width of the frame. |
$frame->getHeight() | Return the height of the frame. |
$frame->getPTS() alias $frame->getPresentationTimestamp() | Return the presentation time stamp of the frame. |
$frame->resize(Integer width, Integer height [, Integer crop_top [, Integer crop_bottom [, Integer crop_left [, Integer crop_right ]]]]) | Resize and optionally crop the frame. (Cropping is built into ffmpeg resizing so I'm providing it here for completeness.)
|
$frame->crop(Integer crop_top [, Integer crop_bottom [, Integer crop_left [, Integer crop_right ]]]) | Crop the frame.
|
$frame->toGDImage() | Returns a truecolor GD image of the frame. NOTE: This function will not be available if GD is not enabled. |
실제 사용의 예)
function screen_snapshot($fmv,$target,$time=0,$width=0,$height=0){
//동영상 파일의에서 스크린샷을 가져다 저장한다.
//동영상파일,저장할파일이름,폭,높이,초
$move = new ffmpeg_movie($fmv,false);
//시간을 프레임으로 바꾸기
if ($time > 0){$frnum = ceil($move->getFrameRate())*$time;}else{ $frnum=1;}
$frame = $move->getFrame($frnum);
//echo $move->getFrameNumber()."\n";
$filename = $target.'.png';
$width = ($width) ? $width : $frame->getWidth();
$height = ($height) ? $height : $frame->getHeight();
$gd_image = imagecreatetruecolor($width,$height);
imagecopyresized($gd_image,$frame->toGDImage(),0,0,0,0,$width,$height,$frame->getWidth(),$frame->getHeight());
imagepng($gd_image,$filename);
imagedestroy($gd_image);
}
댓글 없음:
댓글 쓰기