0

我正在使用此命令在 ubuntu 终端中检索视频信息:

ffprobe -show_streams sample.mp4

此命令在终端中显示有关视频的所有信息,但是当我在 php 中使用此命令并使用 exec 函数检索结果时,返回

string(0) ""
{}

我如何在 php 中检索结果?

我的代码:

    public function information($ffmpeg,$file)
    {
      $info = exec("$ffmpeg -show_streams $file");
      return $info;
    }
4

3 回答 3

1

我使用 exec 函数用三个参数运行我的命令,并用第二个参数返回值:

$info = exec("$ffmpeg -show_streams $file",$output,$result);
return $output;
于 2014-07-15T07:31:24.470 回答
0

您应该首先阅读 exec 手册,了解您需要指定第三个参数才能获得结果。但是有一些第二个参数,所以使用shell_exec()会容易得多

手册将是您的朋友:

http://php.net/exec

于 2014-07-15T06:46:15.930 回答
0

第一次找到完整路径:命令:

whereis ffmpeg

我的结果:/usr/bin/ffprobe

echo exec('/usr/bin/ffprobe -show_format YOURINPUT ', $output, $result);    
var_dump($output);

$result=1 或 0.......[1 错误发生或 0 输入正常。]

或使用命令ffmpeg
请查看http://www.stoimen.com/blog/2011/04/12/an-ffmpeg-question-why-phps-exec-doesnt-return-the-command-output/

于 2017-08-17T12:08:43.477 回答