从 PHP 向命令行程序发送输入
我希望能够从 PHP(在 Windows 上)停止 FFMPEG。
我现在正在做的是这样启动它:
pclose(popen("start ffmpeg -i rtmp://livestream -o a_file.mp4", "r"));
但是一旦我已经做到了,我已经失去了与该程序的所有连接(对吗?)。
我想向进程发送一个“q”来停止它。有什么办法可以做到这一点吗?
编辑:我可能应该解释一下,我使用 pclose 是因为我需要 PHP 脚本继续运行,从而关闭文件指针。也许问题应该是:如何保持脚本运行和文件指针打开?
I'd like to be able to stop FFMPEG from PHP (on Windows).
What I'm doing now is starting it as so:
pclose(popen("start ffmpeg -i rtmp://livestream -o a_file.mp4", "r"));
But as soon as I've done that I've lost all connection to the program (right?).
I would like to send a 'q' to the process to stop it. Is there any way to do this?
EDIT: I should probably explain that I use pclose because I need the PHP script to keep running and thus close the file pointer. Maybe the question should be: How can I keep the script running and the file pointer open?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
proc_open
为您提供一个文件指针这样您就可以写入程序的输入。文档页面上有示例。proc_open
gives you a file pointer so you can then write to the input of the program. There are examples on the doc page.