简体   繁体   中英

Sending input to a command line program from 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM