2014-10-11 166 views
0

我正在使用ffmpeg从视频获取缩略图。它的工作正常。但是shell_exec函数返回null。shell_exec返回null ffmpeg用于生成视频缩略图

我的命令,

$return=shell_exec('C:\ffmpeg\bin\ffmpeg.exe -i D:\wamp\www\test\demo.mov -f image2 -vframes 1 D:\wamp\www\test\test.jpg'); 
var_dump($return); 

我可以从中得到的返回值?请帮我:)

回答

3

PHP documentation

从执行命令的输出或NULL,如果发生错误或 该命令不产生输出。

注意:当发生错误或程序不产生输出时,此函数可以返回NULL。使用此功能无法检测执行失败 。当需要访问 程序退出代码时,应使用exec()。

因此,无论你的程序失败,或者它是成功的,但没有输出。使用exec而不是shell_exec来帮助您区分这两种情况。 exec返回退出代码 - 如果它为0,则表示成功,非零表示失败。

exec('C:\ffmpeg\bin\ffmpeg.exe -i D:\wamp\www\test\demo.mov -f image2 -vframes 1 D:\wamp\www\test\test.jpg', $output, $exit_code); 
var_dump($output); 
var_dump($exit_code); 
+0

Thanks @Martin Konecny。它工作正常:) – Manu 2014-10-11 07:04:34