关注 README我通过 Composer 安装了 PHP FFmpeg,并从 https://ffmpeg.zeranoe.com/builds/ 下载了二进制文件
现在我正在尝试运行“基本用法”示例:
<?php
require("vendor/autoload.php");
$ffmpeg = FFMpeg\FFMpeg::create();
$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');
?>
但我收到“找不到可执行文件”错误,因为我不知道将它们放在哪里
我还尝试使用以下命令指定二进制文件 ffmpeg.exe 和 ffprobe.exe:
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/pathtobin/ffmpeg',
'ffprobe.binaries' => '/pathtobin/ffprobe',
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12 // The number of threads that FFMpeg should use
), $logger);
但仍然是同样的错误......我是在用鼹鼠山造山吗?任何帮助表示赞赏...谢谢
编辑 1
我将 ffmpeg\bin 文件夹添加到系统路径,我可以从任何地方从 cmd 运行可执行文件,但现在我收到此错误:
"Executable not found, proposed : avprobe, ffprobe"
...相反,如果我明确给出二进制路径,我会得到
'ffprobe failed to execute command "C:/FFmpeg/bin/ffprobe.exe" "-help" "-loglevel" "quiet"'
我究竟做错了什么?
编辑 2
网络服务器配置
站点根目录--->
C:\inetpub\wwwroot\site\
内容:- 索引.php
- 输入.mp4
- 供应商/(PHP-FFMpeg 库文件夹)
FFmpeg 二进制文件 --->
C:\inetpub\wwwroot\FFmpeg\
内容:- ffmpeg.exe
- ffplay.exe
- ffprobe.exe
index.php
<?php
ini_set('display_errors', 'On'); error_reporting(E_ALL);
require("vendor/autoload.php");
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => 'C:/inetpub/wwwroot/FFmpeg/ffmpeg.exe',
'ffprobe.binaries' => 'C:/inetpub/wwwroot/FFmpeg/ffprobe.exe',
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
));
$video = $ffmpeg->open('input.mp4');
?>
结果
Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffprobe failed to execute command "C:/inetpub/wwwroot/FFmpeg/ffprobe.exe" "-help" "-loglevel" "quiet" in C:\inetpub\wwwroot\site\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\ProcessRunner.php:100 Stack trace: #0 C:\inetpub\wwwroot\site\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure('"C:/inetpub/www...') #1 C:\inetpub\wwwroot\site\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner->run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) #2 C:\inetpub\wwwroot\site\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\AbstractBinary.php(137): Alchemy\BinaryDriver\AbstractBinary->run(Object(Symfony\Component\Process\Process), false, NULL) #3 C:\inetpub\wwwroot\site\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFProbe\OptionsTester.php(61): Alchemy\Binary in C:\inetpub\wwwroot\site\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFProbe\OptionsTester.php on line 63
最佳答案
docs说:
This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it. Be sure that these binaries can be located with system PATH to get the benefit of the binary detection, otherwise you should have to explicitly give the binaries path on load.
您需要将这些永久存储在某个地方,然后将此路径添加到您的系统或用户 PATH 变量中:
您可以将 ";c:\my\path\to\ffmpeg"添加到 PATH 值的末尾。
关于Windows问题上的PHP-FFMpeg安装和基本用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42521137/