搜尋
首頁後端開發php教程ubuntu 装配 ffmpeg php-ffmpeg

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

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
您如何修改PHP會話中存儲的數據?您如何修改PHP會話中存儲的數據?Apr 27, 2025 am 12:23 AM

tomodifyDataNaphPsession,startTheSessionWithSession_start(),然後使用$ _sessionToset,修改,orremovevariables.1)startThesession.2)setthesession.2)使用$ _session.3)setormodifysessessvariables.3)emovervariableswithunset()

舉一個在PHP會話中存儲數組的示例。舉一個在PHP會話中存儲數組的示例。Apr 27, 2025 am 12:20 AM

在PHP會話中可以存儲數組。 1.啟動會話,使用session_start()。 2.創建數組並存儲在$_SESSION中。 3.通過$_SESSION檢索數組。 4.優化會話數據以提升性能。

垃圾收集如何用於PHP會議?垃圾收集如何用於PHP會議?Apr 27, 2025 am 12:19 AM

PHP會話垃圾回收通過概率機制觸發,清理過期會話數據。 1)配置文件中設置觸發概率和會話生命週期;2)可使用cron任務優化高負載應用;3)需平衡垃圾回收頻率與性能,避免數據丟失。

如何在PHP中跟踪會話活動?如何在PHP中跟踪會話活動?Apr 27, 2025 am 12:10 AM

PHP中追踪用戶會話活動通過會話管理實現。 1)使用session_start()啟動會話。 2)通過$_SESSION數組存儲和訪問數據。 3)調用session_destroy()結束會話。會話追踪用於用戶行為分析、安全監控和性能優化。

如何使用數據庫存儲PHP會話數據?如何使用數據庫存儲PHP會話數據?Apr 27, 2025 am 12:02 AM

利用數據庫存儲PHP會話數據可以提高性能和可擴展性。 1)配置MySQL存儲會話數據:在php.ini或PHP代碼中設置會話處理器。 2)實現自定義會話處理器:定義open、close、read、write等函數與數據庫交互。 3)優化和最佳實踐:使用索引、緩存、數據壓縮和分佈式存儲來提升性能。

簡單地說明PHP會話的概念。簡單地說明PHP會話的概念。Apr 26, 2025 am 12:09 AM

phpsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIdStoredInAcookie.here'showtomanageThemeffectionaly:1)startAsessionWithSessionWwithSession_start()和stordoredAtain $ _session.2)

您如何循環中存儲在PHP會話中的所有值?您如何循環中存儲在PHP會話中的所有值?Apr 26, 2025 am 12:06 AM

在PHP中,遍歷會話數據可以通過以下步驟實現:1.使用session_start()啟動會話。 2.通過foreach循環遍歷$_SESSION數組中的所有鍵值對。 3.處理複雜數據結構時,使用is_array()或is_object()函數,並用print_r()輸出詳細信息。 4.優化遍歷時,可採用分頁處理,避免一次性處理大量數據。這將幫助你在實際項目中更有效地管理和使用PHP會話數據。

說明如何使用會話進行用戶身份驗證。說明如何使用會話進行用戶身份驗證。Apr 26, 2025 am 12:04 AM

會話通過服務器端的狀態管理機制實現用戶認證。 1)會話創建並生成唯一ID,2)ID通過cookies傳遞,3)服務器存儲並通過ID訪問會話數據,4)實現用戶認證和狀態管理,提升應用安全性和用戶體驗。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。