[ 'method' => 'POST', 'header' => 'Content-Type: application/json', 'timeout' => 5, 'content' => $jsonStartMessage ] ]; $endOptions = [ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/json', 'timeout' => 5, 'content' => $jsonEndMessage ] ]; echo "Sending start info to discord..."; $result = file_get_contents($DiscordWebhook, false, stream_context_create($startOptions)); echo "done.\n"; $lastOnlineTime = time(); system("rtmpdump -r ".$StreamURL." -m 15 -o tmp/rtmp/".$videoFileName); if(($lastOnlineTime + 10) < time()) { echo "Sending end info to discord..."; $result = file_get_contents($DiscordWebhook, false, stream_context_create($endOptions)); echo "done.\n"; }else{ $lastOnlineTime = $lastOnlineTime + 3600; } }else{ echo "ERROR: Image not generated!\n"; } }else{ echo "Wait for next check ... ( ".(($lastOnlineTime + 60) - time()).")\n"; sleep(5); } } ?>