0

Hey there! I want to restart a live stream by hand via a php script. Everything works fine so far, but the following command causes that the script loads forever and the transcoding isn't working:

nohup openRTSP -v -c rtsp://*****.dyndns.org:665 | ffmpeg -r 5 -f mjpeg -i - http://127.0.0.1:8090/feed1.ffm > /dev/null &

Any ideas how to start that command e.g. without waiting for the output?

acy
  • 214
  • 1
  • 3
  • 16
  • You may also need to redirect stderr too, try adding `2> /dev/null` near the stdout redirect. (This is a blatant guess, which is why it's a comment. :) – sarnold Mar 07 '11 at 11:44

1 Answers1

0

Not that it will necessarily solve your problem, but it should answer your question, found in the PHP comments under "exec" in which several people came across similar situations.

I combined several efforts in this topic into one function: This will execute $cmd in the background (no cmd window) without PHP waiting for it to finish, on both Windows and Unix.

function execInBackground($cmd) { 
    if (substr(php_uname(), 0, 7) == "Windows"){ 
        pclose(popen("start /B ". $cmd, "r"));  
    } 
    else { 
        exec($cmd . " > /dev/null &");   
    } 
}
Jeff Parker
  • 7,367
  • 1
  • 22
  • 25