亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

FFmpegPHP的安裝使用詳解

系統(tǒng) 3071 0

http://blog.163.com/chenzhenhua_007/blog/static/128492649201182335633965/

FFmpegPHP的安裝使用詳解 ??

2011-09-23 16:30:53 |??分類: PHP+MySQL | 字號 ? 訂閱

?

FFmpegPHP 是一個純面向對象的 ffmpeg 的 PHP封裝。提供一些簡單易用、面向對象的API用以訪問視頻和音頻文件的信息,可直接從視頻中獲取幀的圖片,這常用來做視頻的縮略圖。支持的視頻格式包 括: MOV, AVI, MPG, 和 WMV.
FFmpegPHP封裝,沒有提供視頻轉換的接口。(至少我沒找到,如果大家知道還望賜教。)

我使用的集成環(huán)境APMServ。?

1.下載ffmpeg-php: http://sergey89.ru/files/ffmpeg-php-win32-all.zip

2. 解壓 ffmpeg-php-win32-all.zip 后有下面幾個文件:

???? avcodec-51.dll

???? avformat-51.dll

???? avutil-49.dll

???? php_ffmpeg.dll

???? pthreadGC2.dll

3. 將四個文件拷貝到windows/system32文件夾下面

???? avcodec-51.dll, avformat-51.dll, avutil-49.dll, pthreadGC2.dll

4.將php_ffmpeg.dll拷貝到php的ext目錄下。

5. 然后需要到apache/bin文件下找到php.ini文件下允許使用dll文件加入extension=php_ffmpeg.dll 并允許???? extension=php_gd2.dll,?extension=php_gettext.dll這兩個設置。(去掉前面的分號)

??? extension=php_gd2.dll
??? extension=php_gettext.dll
??? extension=php_ffmpeg.dll

6. 重新啟動APMServ后使用phpinfo()函數(shù)看到一下信息配置:

?

?

?以上就表明ffmpeg在php環(huán)境中配置成功了。

?

7. 下面我們建立一個php的頁面來測試是不是可以使用ffmpeg的一些函數(shù)功能。建立testvideo.php文件

?代碼如下:

<?php

extension_loaded('ffmpeg');

$ffmpegInstance = new ffmpeg_movie('D:\Program Files\APMServ5.2.6\www\htdocs\test.mpg');
echo "getDuration: " . $ffmpegInstance->getDuration()."<br>" .
"getFrameCount: " . $ffmpegInstance->getFrameCount()."<br>" .
"getFrameRate: " . $ffmpegInstance->getFrameRate()."<br>" .
"getFilename: " . $ffmpegInstance->getFilename()."<br>" .
"getComment: " . $ffmpegInstance->getComment()."<br>" .
"getTitle: " . $ffmpegInstance->getTitle()."<br>" .
"getAuthor: " . $ffmpegInstance->getAuthor()."<br>" .
"getCopyright: " . $ffmpegInstance->getCopyright()."<br>" .
"getArtist: " . $ffmpegInstance->getArtist()."<br>" .
"getGenre: " . $ffmpegInstance->getGenre()."<br>" .
"getTrackNumber: " . $ffmpegInstance->getTrackNumber()."<br>" .
"getYear: " . $ffmpegInstance->getYear()."<br>" .
"getFrameHeight: " . $ffmpegInstance->getFrameHeight()."<br>" .
"getFrameWidth: " . $ffmpegInstance->getFrameWidth()."<br>" .
"getPixelFormat: " . $ffmpegInstance->getPixelFormat()."<br>" .
"getBitRate: " . $ffmpegInstance->getBitRate()."<br>" .
"getVideoBitRate: " . $ffmpegInstance->getVideoBitRate()."<br>" .
"getAudioBitRate: " . $ffmpegInstance->getAudioBitRate()."<br>" .
"getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate()."<br>" .
"getVideoCodec: " . $ffmpegInstance->getVideoCodec()."<br>" .
"getAudioCodec: " . $ffmpegInstance->getAudioCodec()."<br>" .
"getAudioChannels: " . $ffmpegInstance->getAudioChannels()."<br>" .
"hasAudio: " . $ffmpegInstance->hasAudio();

?

8.執(zhí)行后如果拿到視頻的一些信息如下就表示環(huán)境配置成功了,那我們就可以開始開發(fā)我們的視頻操作。

執(zhí)行結果:

略....

9.實現(xiàn)視頻的截圖 。(接上面的php代碼)

$ff_frame = $ffmpegInstance->getFrame(20);//截取視頻第20幀的圖像
$gd_image = $ff_frame->toGDImage();
$img=$_SERVER['DOCUMENT_ROOT']."/test2.jpg";//要生成圖片的絕對路徑????
imagejpeg($gd_image, $img);//創(chuàng)建jpg圖像????
imagedestroy($gd_image);//銷毀一圖像

10.關于ffmpeg-php的API。

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.
==============================================================
ffmpeg_frame object methods
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.

==============================================================
ffmpeg_animated_gif object methods
Method Description
$gif = new ffmpeg_animated_gif(String output_file_path, Integer width, Integer height, Integer frame_rate, [Integer loop_count]) create a new ffmpeg_animated_gif object
  • output_file_path - Location in the filesystem where the animated gif will be written.
  • width - Width of the animated gif.
  • height - Height of the animated gif.
  • frame_rate - Frame rate of the animated gif in frames per second..
  • loop_count - Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
$frame->addFrame( ffmpeg_frame frame_to_add) Add a frame to the end of the animated gif.
  • frame_to_add - The ffmpeg_frame object to add to the end of the animated gif.

?

?

FFmpegPHP的安裝使用詳解


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 91精品全国免费观看青青 | 91九色首页 | 国产乱码精品一区二区三上 | 91破解版在线 | 亚洲 | 91大神在线精品视频一区 | 欧美日日干 | 久久99热久久精品 | 久草在线观看视频 | 久久免费精品视频在线观看 | 欧美一区二区三区视频 | 婷婷在线网 | 久久草在线视频 | 在线久久 | 久久99精品福利久久久 | 99精品视频在线视频免费观看 | 欧美精品另类 | 国产一级在线观看www色 | 久久国产热视频 | 男女精品视频 | 欧美成人怡红院在线观看 | 好吊妞在线成人免费 | 手机看片一区 | 四虎成人在线 | 国产亚洲欧美在线 | 久热这里只精品99re8久 | 国产综合成色在线视频 | 日本一片免费观看高清完整 | 亚洲视频精品在线观看 | 国产欧美日韩精品a在线观看高清 | 一级毛片在线免费观看 | 中文字幕在线精品视频万部 | 亚洲一级黄色 | 精品亚洲一区二区三区在线播放 | 一级毛片区| 狠狠色噜噜狠狠狠狠色综合久 | 番茄视频在线观看黄版本免费 | 九九在线观看精品视频6 | 国产欧美另类久久精品91 | 老子午夜伦影理论片 | 视频一区视频二区在线观看 | 我要看欧美一级毛片 |