检查 php exec 的输出始终返回空数组
我正在转换一些电影并希望确保转换顺利进行:
exec("ffmpeg -i ".$orgVideoFile." -vcodec libx264 -crf 21 -acodec aac -ac 2 -ab 192000 -strict experimental -vpre hq -vpre veryfast -refs 3 -threads 4 -s 320x240 ".$newVideoFile, $output);
echo "Output:";
var_dump($output);
但是在检查 $output 时它总是为空:
Output:array(0) { }
如何检查以确保一切正常?
I'm converting some movies and want to make sure the conversion went through without errors:
exec("ffmpeg -i ".$orgVideoFile." -vcodec libx264 -crf 21 -acodec aac -ac 2 -ab 192000 -strict experimental -vpre hq -vpre veryfast -refs 3 -threads 4 -s 320x240 ".$newVideoFile, $output);
echo "Output:";
var_dump($output);
but when checking $output its always empty:
Output:array(0) { }
How do I check to make sure everything went ok?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 PHP 的 proc_open 函数您将拥有更多的控制权。它允许您以非常受控的方式写入/读取标准输入/输出:
You will have much more control using PHP's proc_open function. It allows you to write/read standard input/output in a very controlled way:
使用php的函数
来代替。您可以将 ffmpeg 的输出与所需值进行比较,而不仅仅是退出代码。
use php's function
instead. Rather then just having exit code you'll may compare ffmpeg's output against desired value.