2017-06-21 141 views
0

我下載ffmpeg並安裝它作曲。當我嘗試使用基本使用代碼時,出現此錯誤。在bin文件夾中,我有ffmpeg,ffplayffprobe exe文件。另外,我爲c:ffmpeg\bin設置了環境變量。在窗口上安裝php ffmpeg

Fatal error: Uncaught exception
'Alchemy\BinaryDriver\Exception\ExecutableNotFoundException' with message 'Executable not found, proposed : c:\ffmpeg\bin\binffprobe.exe' in C:\xampp\htdocs\core\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\AbstractBinary.php:160 Stack trace: #0
C:\xampp\htdocs\core\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php(48): Alchemy\BinaryDriver\AbstractBinary::load('c:\ffmpeg\bin\b...', NULL, Object(Alchemy\BinaryDriver\Configuration)) #1 C:\xampp\htdocs\core\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFProbe.php(207): FFMpeg\Driver\FFProbeDriver::create(Array, NULL) #2 C:\xampp\htdocs\core\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFMpeg.php(117): FFMpeg\FFProbe::create(Array, NULL, NULL) #3 C:\xampp\htdocs\core\demo2.php(9): FFMpeg\FFMpeg::create(Array) #4 {main} Next exception 'FFMpeg\Exception\ExecutableNotFoundException' with message 'Unable to load FFProbe' in C:\xampp\htdocs\core\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php:50 Stack trace: #0 C: in C:\xampp\htdocs\core\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php on line 50

這是我的php代碼;

require_once 'vendor/autoload.php'; 
    $ffmpeg = \FFMpeg\FFMpeg::create([ 
'ffmpeg.binaries' => 'c:\ffmpeg\bin\binffmpeg.exe', 
'ffprobe.binaries' => 'c:\ffmpeg\bin\binffprobe.exe' 
    ]); 

    $video = $ffmpeg->open('video.mpg'); 
$video 
->filters() 
->resize(new FFMpeg\Coordinate\Dimension(320, 240)) 
->synchronize(); 
$video 
->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10)) 
->save('frame.jpg'); 
$video 
->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4') 
->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv') 
->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');` 

回答

0

確保你給的二進制文件的正確路徑,這個錯誤僅僅是因爲腳本是不是能找到二進制文件,

所以也許如果M沒有錯你給了錯誤的exe文件名

只是改變這個

$ffmpeg = \FFMpeg\FFMpeg::create([ 
    'ffmpeg.binaries' => 'c:\ffmpeg\bin\binffmpeg.exe', 
    'ffprobe.binaries' => 'c:\ffmpeg\bin\binffprobe.exe' 
]); 

到這一個

$ffmpeg = \FFMpeg\FFMpeg::create([ 
    'ffmpeg.binaries' => 'c:\ffmpeg\bin\ffmpeg.exe', 
    'ffprobe.binaries' => 'c:\ffmpeg\bin\ffprobe.exe' 
]); 

你重複斌\ BIN兩次,

c:\ffmpeg\bin\binffprobe.exe

好運,

這裏只是一個示例代碼將視頻轉換成MP3

require_once 'vendor/autoload.php'; 
$ffmpeg = \FFMpeg\FFMpeg::create([ 
    'ffmpeg.binaries' => 'ffmpeg\bin\ffmpeg.exe', 
    'ffprobe.binaries' => 'ffmpeg\bin\ffprobe.exe' 
]); 

$video = $ffmpeg->open('video.mp4'); 
//just in case you want to save thumbnail from video 
$video 
    ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(300)) 
    ->save('frame.jpg'); 
//extract audio 
$video->save(new FFMpeg\Format\Audio\Mp3, 'audio.mp3');