gpt4 book ai didi

php - sh :/usr/bin/ffmpeg: not found

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:39:13 25 4
gpt4 key购买 nike

我正在尝试使用 shell_exec 或 exec 从 PHP 执行 ffmpeg,但它失败了。为什么会这样?命令 /usr/bin/ffmpeg 从终端运行,所以我尝试了

<?php
$cmd = "/usr/bin/ffmpeg";
exec($cmd." 2>&1", $out, $ret);
if ($ret){
echo "There was a problem!\n";
print_r($out);
}else{
echo "Everything went better than expected!\n";
}
?>

我一直在努力

There was a problem! Array ( [0] => sh: /usr/bin/ffmpeg: not found )

如有任何帮助,我们将不胜感激。

可执行文件的权限是

-rwxr-xr-x  1 root   root      106552 Jun 12 09:53 ffmpeg

在 $cmd 中运行 which/usr/local/bin/ffmpeg 返回一个空数组。

最佳答案

您问题的答案可能比预期的要简单。您正在检查 /usr/local/bin /usr/bin。对此有多种解决方案。

  1. 您可以运行 $ whereis ffmpeg 看看会得到什么。根据结果​​,更改您的 $cmd 变量。如果 whereis 没有返回任何内容,那么您的系统就不知道它在哪里。您可以将它添加到您的 $PATH 环境变量中,然后重试。

  2. 您可以尝试运行 $ find/usr -name "ffmpeg" 或类似的东西。通过确保安装此程序,它将帮助您更快地解决此问题。

  3. 如果有某种限制拒绝 apache 访问/使用 ffmpeg 的能力,您始终可以将它存储在文档根目录下的 bin 文件夹中。 (类似于 /path/to/doc/root/bin/ffmpeg)我以前做过,所以我知道它有效。


如果您发现 ffmpeg 实际上位于 /usr/local/bin 中,那么您应该尝试将 $cmd 更改为此:

$cmd = '/usr/local/bin/ffmpeg';

关于php - sh :/usr/bin/ffmpeg: not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13243759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com