From 0539ec8377efb98f2dae91a609feec647c8c961b Mon Sep 17 00:00:00 2001 From: Christopher Latza Date: Fri, 12 Jun 2020 17:37:45 +0200 Subject: [PATCH] record video with ffmpeg --- start.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/start.php b/start.php index fa55740..86c33f2 100644 --- a/start.php +++ b/start.php @@ -12,13 +12,12 @@ while(TRUE) { if(($lastOnlineTime + 60) < time()) { - $fileName = "output-".md5(time().rand(11111,99999)).".mp4"; + $fileName = "output-".md5(time().rand(11111,99999)).".gif"; + $videoFileName = md5(time().rand(11111,99999)).".mp4"; echo "Checking stream and creating image...\n"; //system("ffmpeg -i ".$StreamURL." -vframes 1 -q:v 2 -vf scale=535:346 ".$fileName); - //system('ffmpeg -r 90 -t 4 -i '.$StreamURL.' -vf "fps=10,scale=350:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 '.$fileName); - //system('ffmpeg -r 90 -t 4 -i '.$StreamURL.' -vf "fps=8,scale=420:-1" -loop 0 -pix_fmt yuv420p '.$fileName); - system('ffmpeg -r 90 -t 6 -i '.$StreamURL.' -vf "fps=8,scale=420:-1" '.$fileName); + system('ffmpeg -r 90 -t 4 -i '.$StreamURL.' -vf "fps=10,scale=350:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 '.$fileName); if(is_file($fileName)) { @@ -55,7 +54,8 @@ while(TRUE) $result = file_get_contents($DiscordWebhook, false, stream_context_create($startOptions)); echo "done.\n"; - system("rtmpdump -r ".$StreamURL." -m 15 -o /dev/null"); + system("ffmpeg -rw_timeout 10000 -i ".$StreamURL." tmp/rtmp/".$videoFileName); + //system("rtmpdump -r ".$StreamURL." -m 15 -o /dev/null"); echo "Sending end info to discord..."; $result = file_get_contents($DiscordWebhook, false, stream_context_create($endOptions));