레이블이 ffmpeg인 게시물을 표시합니다. 모든 게시물 표시
레이블이 ffmpeg인 게시물을 표시합니다. 모든 게시물 표시

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

ffmpeg-php API documentation ffmpeg_movie object methods

ffmpeg-php API documentation



ffmpeg_movie object methods


Method

Description

$movie = new ffmpeg_movie(String path_to_media, boolean persistent)

Open a video or audio file and return it as an object.

  • path_to_media - File path of video or audio file to open.
  • persistent - Whether to open this media as a persistent resource. See the PHP documentation for more info about persistent resources


$movie->getDuration()

Return the duration of a movie or audio file in seconds.

$movie->getFrameCount()

Return the number of frames in a movie or audio file.

$movie->getFrameRate()

Return the frame rate of a movie in fps.

$movie->getFilename()

Return the path and name of the movie file or audio file.

$movie->getComment()

Return the comment field from the movie or audio file.

$movie->getTitle()

Return the title field from the movie or audio file.

$movie->getAuthor() alias $movie->getArtist()

Return the author field from the movie or the artist ID3 field from an mp3 file.

$movie->getCopyright()

Return the copyright field from the movie or audio file.

$movie->getArtist()

Return the artist ID3 field from an mp3 file.

$movie->getGenre()

Return the genre ID3 field from an mp3 file.

$movie->getTrackNumber()

Return the track ID3 field from an mp3 file.

$movie->getYear()

Return the year ID3 field from an mp3 file.

$movie->getFrameHeight()

Return the height of the movie in pixels.

$movie->getFrameWidth()

Return the width of the movie in pixels.

$movie->getPixelFormat()

Return the pixel format of the movie.

$movie->getBitRate()

Return the bit rate of the movie or audio file in bits per second.

$movie->getVideoBitRate()

Return the bit rate of the video in bits per second.

NOTE: This only works for files with constant bit rate.

$movie->getAudioBitRate()

Return the audio bit rate of the media file in bits per second.

$movie->getAudioSampleRate()

Return the audio sample rate of the media file in bits per second.

$movie->getFrameNumber()

Return the current frame index.

$movie->getVideoCodec()

Return the name of the video codec used to encode this movie as a string.

$movie->getAudioCodec()

Return the name of the audio codec used to encode this movie as a string.

$movie->getAudioChannels()

Return the number of audio channels in this movie as an integer.

$movie->hasAudio()

Return boolean value indicating whether the movie has an audio stream.

$movie->hasVideo()

Return boolean value indicating whether the movie has a video stream.

$movie->getFrame([Integer framenumber])

Returns a frame from the movie as an ffmpeg_frame object. Returns false if the frame was not found.

  • framenumber - Frame from the movie to return. If no framenumber is specified, returns the next frame of the movie.


$movie->getNextKeyFrame()

Returns the next key frame from the movie as an ffmpeg_frame object. Returns false if the frame was not found.0



실제 사용의 예)

    function move_check(&$config,$file){
        //동영상파일 정보를 환경설정파일에 입력한다.
        //파일의 fps,width,height,totaltime,bitrate
            $move = new ffmpeg_movie($file,false);
            $config['m_fps']=$move->getFrameRate();//초당 프레임개수
            $config['m_width']=$move->getFrameWidth();//폭
            $config['m_height']=$move->getFrameHeight();//높이
            $config['m_allframe']=$move->getFrameCount();//프레임개수
            $config['m_bitrate']=$move->getBitRate();//초당전송률
            $config['m_audioc']=$move->getAudioChannels();//오디오채널
            $config['m_audiobit']=$move->getAudioBitRate();//오디오전송률
            $config['m_duration']=$move->getDuration();//전체런타임
    }