0

I am trying to use proc_open to open an instance of ffmpeg. It works with popen without the title but I can't set the title as it needs another line or something I tried

popen("title $title \r start /min ffmpeg -loglevel quiet -re -i udp://$UIP:$UPort -codec: copy -f mpegts udp://$ip?pkt_size=1316", "r"); didnt work,

my working code is as follows

   $title=$_POST['title'];  
$ip=$_POST['IPtxt'];
$UIP=$_POST['UDPAddress'];
$UPort=$_POST['UDPPort'];
echo "Starting ffmpeg...\n\n";
popen("start /min ffmpeg -loglevel quiet -re -i udp://$UIP:$UPort -codec: copy -f mpegts udp://$ip?pkt_size=1316", "r");
echo "Done.\n";

I need to store a title or process id so i can stop the process when the stop button is clicked. I've looked at proc_open but I'm not sure the right syntax for it.

1 Answers1

0

popen("start /min ffmpeg

This doesn't run ffmpeg. It runs start.exe - and that runs ffmpeg. Try running ffmpeg directly, then you can use proc_get_status() to get the pid or proc_terminate() to kill it via the PHP resource.

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • I successfully got the PID in proc_get_status() but the PID is not correct, this seems to be a known issue, and setting the TITLE in the batch file also won't kill it because it is in the background. I've tested it by directly running batch files and but pushing variables into them, and when i push PHP variables into it the FFMPEG script runs correctly but I can't stop it , – Cameron Allen Nov 19 '21 at 01:59
  • "I successfully got the PID" - when you removed "start" ? – symcbean Nov 19 '21 at 20:18