【问题标题】:PHP exec can't access FFMPEG. while I can in command promptPHP exec 无法访问 FFMPEG。虽然我可以在命令提示符下
【发布时间】:2018-05-29 20:50:44
【问题描述】:

我在 Windows 上安装了 FFMPEG。我将它添加到我的路径变量中。无论我在哪个文件夹中,我都可以在命令提示符下访问 ffmpeg(这告诉我 ffmpeg + 路径变量按预期工作)。

PHP

exec('ffmpeg -y -i C:/wamp64/test.mp4 -strict -2 -b:v 500k -vf scale=-2:123 C:/wamp64/test.mp4 2>&1', $output);
$output = implode(' -|- ', $output);
var_dump($output);

Var_dump

'ffmpeg' is not recognized as an internal or external command, -|- operable program or batch file.

当我在命令提示符中复制完全相同的突击队员 (ffmpeg -y -i C:/wamp64/test.mp4 -strict -2 -b:v 500k -vf scale=-2:123 C:/wamp64/test.mp4 2>&1) 时,它可以完美运行。无论文件夹位置如何。

我是否需要采取额外/不同的步骤才能让 PHP 找到 ffmpeg

【问题讨论】:

  • 看起来windows阻止了另一个应用程序访问终端,您是否尝试过像这样执行C:\ffmpeg\bin\ffmpeg.exe
  • @PutraPurba 是的,这行得通,但我也想使用一个不使用完整路径的库。
  • C:\ffmpeg\bin 是否已经添加到 PATH 变量中?

标签: php path command-line-interface exec command-prompt


【解决方案1】:

你可以尝试使用 PHP 定义的常量

DIRECTORY_SEPARATOR

而不是/?

此外,如果 ffmpeg.exe 程序不在您的 %PATH% 中,您必须使用完整路径,例如:

'C:' . DIRECTORY_SEPARATOR . 'Program Files' . DIRECTORY_SEPARATOR . 'ffmpeg' . DIRECTORY_SEPARATOR . 'bin'. DIRECTORY_SEPARATOR . 'ffmpeg.exe'

【讨论】:

    猜你喜欢
    • 2015-07-13
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多