2014-01-22 146 views
0

我試圖實現 https://github.com/PHP-FFMpeg/PHP-FFMpeg PHP-FFmpeg的先決條件

我複製的src/FFmpeg的文件夾,我的文件夾包括和努力讓我自動加載知道在哪裏可以找到一切。

的測試,我做了一個腳本,簡單地做:

$ffmpeg = FFMpeg\FFMpeg::create(); 
$video = $ffmpeg->open('video.mpg'); 

我得到:

Fatal error: Class 'Doctrine\Common\Cache\ArrayCache' not found in /var/www/php/include/FFMpeg/FFProbe.php on line 203 

我的問題是:PHP-ffmpeg的需要學說,因爲未在規定文檔。我需要什麼版本?是否有其他先決條件?

我可以爲此創建一個新問題,但我不確定是否應該。我現在已經實現了PHP-ffmpeg。我正在使用Laravel,但是這對於這個問題應該是無關緊要的。我正在嘗試啓用進度監控。它的工作原理,但我需要傳入一個ID,所以我可以更新memcache中正確的密鑰。

$id = 12345; 
$format->on('progress', function ($audio, $format, $percentage) { 
    //this works perfect, but doesn't tell me which item is being updated 
    Cache::put("progress", $percentage, .25); 

    //this does not work as I am unable to pass in $id, if I add it as the 4th argument above it will display the number of threads or something 
    //Cache::put("{$id}_progress", $percentage, .25);   
}); 

我需要澄清「on」方法。我查看了https://ffmpeg-php.readthedocs.org/en/latest/_static/API/,無法弄清楚這種方法的工作原理。任何幫助,將不勝感激。

+0

從[作曲家要求(https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/composer.json),它使用原則緩存組件等。 – Charles

回答

1

您應該按照recommended instructions in the README

Composer是安裝PHP-FFmpeg的最簡單的方法依賴關係

「關於」呼籲格式的方法是EventEmitter的實現。 正如你在這裏看到的那樣:https://ffmpeg-php.readthedocs.org/en/latest/_static/API/FFMpeg/Format/ProgressableInterface.html它擴展了https://github.com/igorw/evenement的EventEmitterInterface。

如果你它是如何工作的引擎蓋下真正感興趣的,在這裏看看: 進度偵聽器在這裏創建:https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Format/Audio/DefaultAudio.php#L96,並在執行此https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Media/Video.php#L151 加入這實際上是可能的,因爲FFMpegDriver擴展提供的驅動程序通過https://github.com/alchemy-fr/BinaryDriver

希望這有助於:)

+0

謝謝,我沒有使用作曲家的唯一原因是我不熟悉它,並不認爲這是必要的。我會閱讀它。 –

+0

我有它的工作,但我有一個關於進度監測的問題(我更新了上述問題) –