2009년 9월 22일 화요일

ffmpeg-php API documentation ffmpeg_frame

ffmpeg-php API documentation
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.)
  • width - New width of the frame (must be an even number).
  • height - New height of the frame (must be an even number).
  • croptop - Remove [croptop] rows of pixels from the top of the frame.
  • cropbottom - Remove [cropbottom] rows of pixels from the bottom of the frame.
  • cropleft - Remove [cropleft] rows of pixels from the left of the frame.
  • cropright - Remove [cropright] rows of pixels from the right of the frame.
NOTE: Cropping is always applied to the frame before it is resized. Crop values must be even numbers.
$frame->crop(Integer crop_top [, Integer crop_bottom [, Integer crop_left [, Integer crop_right ]]]) Crop the frame.
  • croptop - Remove [croptop] rows of pixels from the top of the frame.
  • cropbottom - Remove [cropbottom] rows of pixels from the bottom of the frame.
  • cropleft - Remove [cropleft] rows of pixels from the left of the frame.
  • cropright - Remove [cropright] rows of pixels from the right of the frame.
NOTE: Crop values must be even numbers.
$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);       
    }

댓글 없음:

댓글 쓰기