关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。
此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。
2年前关闭。
Improve this question
我正在尝试运行它,但变量 $new
当我运行它时是空的。当我通过命令行运行 ffmpeg 命令时,它给了我所需的输出,事实上,当我在 php 中运行它时,我看到了来自 ffmpeg 的输出,我希望将其放入 $new
变量,但它是空的。任何人都可以帮我解释原因吗?
谢谢。
<?php
$new = shell_exec('ffmpeg -t 10 -i http://audiostream.com -af "volumedetect" -f null /dev/null');
file_put_contents('output.txt', $new);
?>
最佳答案
奇怪,我确定我试过这个但它没有用,但只是再试一次,它确实......
<?php
$new = shell_exec('ffmpeg -t 10 -i http://audiostream.com -af "volumedetect" -f null /dev/null 2>&1');
file_put_contents('output.txt', $new);
?>
关于php - 为什么使用 PHP 将 shell_exec 转换为变量不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57480496/