gpt4 book ai didi

php - shell_exec 返回 null ffmpeg 用于生成视频缩略图

转载 作者:行者123 更新时间:2023-12-04 23:06:31 25 4
gpt4 key购买 nike

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

我的命令是,

$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);

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

最佳答案

来自 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.



因此,您的程序要么失败,要么成功但没有输出。使用 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);

关于php - shell_exec 返回 null ffmpeg 用于生成视频缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26311888/

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