fork download
  1. <?php
  2.  
  3. $recordTime = 60*60;
  4. $startTime = time();
  5. set_time_limit($recordTime);
  6. $datetime = new DateTime('now', new DateTimezone('America/New_York'));
  7. $datetime = $datetime->format('Ymd-His');
  8.  
  9. $output = array();
  10. $responded = false;
  11. exec('ping 10.0.0.254 -n 1', $output, $return);
  12. foreach($output as $line){
  13. if(strstr($line, 'Reply from') !== false){
  14. $responded = true;
  15. break;
  16. }
  17. }
  18. if($responded == false){
  19. }
  20.  
  21. $cmd = "U:/secvid/ffmpeg-20190225-2e67f75-win64-static/bin/ffmpeg.exe -y -i rtsp://10.0.0.244:554/11 -c copy -an U:/secvid/".$datetime.".mkv 2>&1";
  22.  
  23. $logFile = "U:/secvid/".$datetime."_log.txt";
  24. $fp = fopen($logFile, 'a');
  25. fwrite($fp, $cmd . PHP_EOL);
  26.  
  27. $descriptorspec = array(
  28. 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
  29. 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
  30. 2 => array("pipe", "w") // stderr is a pipe that the child will write to
  31. );
  32.  
  33. $process = proc_open($cmd, $descriptorspec, $pipes);
  34. echo "<pre>";
  35. if (is_resource($process)) {
  36. while (!feof($pipes[1])) {
  37. if(time() > $startTime + $recordTime - 2){
  38. fwrite($pipes[0], 'q');
  39. //exec('taskkill /IM ffmpeg.exe', $output, $return);
  40. //proc_terminate($process, SIGTERM);
  41. break;
  42. }
  43. $s = fread($pipes[1],1);
  44. print $s;
  45. fputs($fp, $s);
  46. flush();
  47. }
  48. }
  49. fclose($fp);
  50. echo "Ended".PHP_EOL;
  51. echo "</pre>";
  52. ?>
Success #stdin #stdout #stderr 0s 82624KB
stdin
Standard input is empty
stdout
<pre>sh: 1: U:/secvid/ffmpeg-20190225-2e67f75-win64-static/bin/ffmpeg.exe: not found
Ended
</pre>
stderr
sh: 1: ping: not found
PHP Warning:  fopen(U:/secvid/20190616-104847_log.txt): failed to open stream: No such file or directory in /home/MecyE7/prog.php on line 24
PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 25
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fputs() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 45
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/MecyE7/prog.php on line 49