致命错误:未捕获的异常'Alchemy\BinaryDriver\Exception\ExecutableNotFoundException',消息为“找不到可执行文件”。

3
我已在Linux上安装了https://github.com/PHP-FFMpeg/PHP-FFMpeg
托管路径为:
/public_html/videoconversion/

我遇到了这个错误。
Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutableNotFoundException' with message 
'Executable not found, proposed : 
    public_html/videoconversion/' in 
        /home/deveducate/public_html/videoconversion/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php:160 Stack trace: 
        #0 /home/deveducate/public_html/videoconversion/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Driver/FFProbeDriver.php(48): 
            Alchemy\BinaryDriver\AbstractBinary::load('public_html/vid...', NULL, Object(Alchemy\BinaryDriver\Configuration)) 
        #1 /home/deveducate/public_html/videoconversion/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFProbe.php(226): FFMpeg\Driver\FFProbeDriver::create(Array, NULL) 
        #2 /home/deveducate/public_html/videoconversion/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFMpeg.php(117): FFMpeg\FFProbe::create(Array, NULL, NULL) 
        #3 /home/deveducate/public_html/videoconversion/convert_to_mp4.php(10): FFMpeg\FFMpeg::create(Array, NULL) 
        #4 {main} Next exception 'FFMpeg\Exception\ExecutableNotFoundException' with message 
           'U in /home/deveducate/public_html/videoconversion/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Driver/FFProbeDriver.php on line 50

文件

require 'vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries'  => '/opt/local/ffmpeg/bin/ffmpeg',
'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe',
'timeout'          => 3600, // The timeout for the underlying process
'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should 
 use
 ), $logger);
 $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')

请问有人知道在哪里更新路径吗?

谢谢。

3个回答

0
根据文档

FFMpeg将自动检测ffmpeg和ffprobe二进制文件。如果您想明确指定二进制路径,可以将数组作为配置传递。

示例:

$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => '/opt/local/ffmpeg/bin/ffmpeg',
    'ffprobe.binaries' => '/opt/local/ffmpeg/bin/ffprobe',
    'timeout'          => 3600, // The timeout for the underlying process
    'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
), $logger);

在你的代码中,看起来你需要在这个文件中进行更改:

/home/deveducate/public_html/videoconversion/convert_to_mp4.php

注意:文档中也有提到,因此您可能只需将它们添加到系统路径中:

此库需要一个可用的 FFMpeg 安装。您需要同时拥有 FFMpeg 和 FFProbe 二进制文件才能使用它。请确保这些二进制文件可以在系统 PATH 中被找到,以获得二进制检测的好处,否则您应该在加载时明确地给出二进制文件的路径。


它不起作用了,我在convert_to_mp4.php文件中添加了上述代码。 - arvindpundir
那是一个示例代码,我想你修改过以适应你的项目了吧? - Jeremy Harris

0

我曾遇到类似的问题,最终解决了:

  • 确保已安装ffmpeg (apt get install ffmpeg)
  • 如果你的PHP有openbasedir限制,请确保将ffmpeg和ffprobe添加进去: open_basedir="/tmp:/usr/share/php::/usr/bin/ffmpeg:/usr/bin/ffprobe"

0
我遇到了同样的问题,并通过以下步骤解决了它:
1. 需要在您的系统上安装ffmpeg。在Linux中使用以下命令安装ffmpeg: sudo apt install ffmpeg
2. 您需要修改您域名的PHP参数中的Open_basedir配置: {WEBSPACEROOT}{/}{:}{TMP}{/}:/usr/bin/ffmpeg:/usr/bin/ffprobe 3. 最后,您的php代码中需要有一个超时参数: $ffmpeg = FFMpeg\FFMpeg::create( array( 'timeout' => 0, ) );

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接