我正在使用此命令在ubuntu终端中检索视频信息:
ffprobe -show_streams sample.mp4
此命令显示终端中有关视频的所有信息,但是当我在php中使用此命令并使用exec函数检索结果时,返回
string(0) ""
{}
我如何在php中检索结果?
我的代码:
public function information($ffmpeg,$file)
{
$info = exec("$ffmpeg -show_streams $file");
return $info;
}
答案 0 :(得分:1)
您应该先阅读exec上的手册,看看是否需要指定第三个参数才能获得结果。但是,方式中有一些第二个参数,所以使用 shell_exec()
会更容易手册应该是你的朋友:
答案 1 :(得分:0)
我使用exec函数运行带有三个参数的命令,并使用第二个参数返回值:
$info = exec("$ffmpeg -show_streams $file",$output,$result);
return $output;
答案 2 :(得分: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/