ubuntu 裝配 ffmpeg php-ffmpeg

來源:互聯網
上載者:User
ubuntu 安裝 ffmpeg php-ffmpeg

?? 最近在做一個視頻網站安裝本地環境費了不少時間。本地是ubuntu 9.10 而伺服器是redhat as4 所以到時候本人會把伺服器安裝過程和大家分享出來。

本人環境如下

  • php —- 5.210
  • apache 2.2
  • ubuntu 9.10
  1. ffmpeg 功能很強大包括視頻抓圖,視頻資訊,視頻轉換,線上視頻錄製,而且是免費的。所有一般的視頻網站都會採用他。
  2. 本人首先是採用編譯安裝,但是一直都沒有成功。編譯過程中出現了很多問題。安裝要使用ffmpeg往往需要編譯很多包。感覺很麻煩。這些包又依賴於很多其他包。安裝順序也有要求。所以放棄了。
  3. 最終採用ubuntu 強大的 apt-get (使用dpkg進行安裝) 進行安裝(當然cenos,red hat這類使用rpm的系統都可以使用yum進行安裝,具體的安裝方法可以在本站進行尋找).
  4. apt-get 安裝步驟如下:
    sudo apt-get update ##更新以下源
    sudo apt-get install ffmpeg
    sudo apt-get install php5-ffmpeg
    sudo apt-get install mencoder
    sudo apt-get install flvtool2 ##視頻轉換flv
    sudo apt-get install lame ##音頻
    sudo apt0get install yasm
  5. 編譯安裝ffmpeg 如下:
    從 http://ffmpeg.mplayerhq.hu 下載
    ./configure –help ##查看有那些參數
    ./configure–prefix=/usr–enable-gpl–enable-shared–enable-libmp3lame–enable-libamr_nb–enable-libogg–enable-libvorbis–enable-libxvid–enable-liba52–enable-liba52bin–enable-pp–enable-libfaad–enable-libfaadbin–enable-libfaac–enable-pthreads–disable-ffserver–enable-x11grab
    如果報錯則安裝該包,或者直接去掉該參數,只需要配置自己使用過程中需要使用到的就行了。
    make & make install
    其他的則一個一個的下載解壓在編譯就是了。
  • 下面是php-ffmpeg 使用的api。功能是很少了。
    $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.
    ?
  • 如果需要給視頻抓圖擇需要使用shell指令碼。也就是用到php當中的(system,exec,passthru)這類執行外部命令函數。
    往往很多伺服器都將種類函數視為危險函數屏蔽掉了。所以想做視頻網站對伺服器的配置要求比較高。
    當然最好是自己的獨立伺服器。vps 也可以。隨便你怎麼整都可以。
View Code PHP

?

測試案例:ffmpeg-execute.php

本文連結地址: ubuntu 安裝 ffmpeg php-ffmpeg

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.