2014-10-11 06:41
浏览 215

shell_exec返回null ffmpeg以生成视频缩略图

I'm using ffmpeg for getting thumbnail image from video. Its working fine. But the shell_exec function returns null.

My command is,

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

Can I get the return value from this? Kindly help me :)

图片转代码服务由CSDN问答提供 功能建议

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


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

我可以从中获得返回值吗? 请帮助我:)

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiong0668 2014-10-11 06:47

    From the PHP documentation:

    The output from the executed command or NULL if an error occurred or the command produces no output.

    Note: This function can return NULL both when an error occurs or the program produces no output. It is not possible to detect execution failures using this function. exec() should be used when access to the program exit code is required.

    So either your program is failing, or it is successful but there is no output. Use exec instead of shell_exec to help you differentiate between these two cases. exec returns an exit code - if it's 0, it means success, and non-zero means fail.

    exec('C:\ffmpeg\bin\ffmpeg.exe -i D:\wamp\www\test\ -f image2 -vframes 1 D:\wamp\www\test\test.jpg', $output, $exit_code);
    打赏 评论

相关推荐 更多相似问题