michel
michel

Reputation: 11

FFMPEG progress url to php script

I'm trying to save the information that ffmpeg sends to the php script but it doesn't work:

// progress.php

ignore_user_abort(true);

$json = file_get_contents('php://input');


if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1' || empty($_GET['stream_id']) || empty($json)) {
    die;
}

$stream_id = intval($_GET['stream_id']);
$data = array_filter(array_map('trim', explode(' ', $json)));
$output = array();
foreach ($data as $row) {
    list($key, $value) = explode('=', $row);
    $output[trim($key)] = trim($value);
}


    
$fp = fopen("/var/www/html/streams/{$stream_id}_.progress", 'w');
fwrite($fp, json_encode($output));
fclose($fp);

    
    
?>

file : 2_.progress

{"frame":"1\nfps","11x\nprogress":"continue\nframe","2.6x\nprogress":"continue\nframe","2x\nprogress":"continue\nframe","1.4x\nprogress":"continue\nframe","1.3x\nprogress":"continue\nframe","1.2x\nprogress":"continue\nframe"}

ffmpeg command :

ffmpeg -y -nostdin -hide_banner -loglevel info -err_detect ignore_err -fflags +genpts -async 1 -user-agent "Restream Panel" -probesize 5000000 -analyzeduration 5000000 -progress "http://127.0.0.1/progress.php?stream_id=2" -i "https://dmitnthvll.cdn.mangomolo.com/dubaisports/smil:dubaisports.smil/chunklist_b1600000.m3u8" -vcodec copy -scodec copy -acodec copy -map 0 -copy_unknown -individual_header_trailer 0 -f segment -segment_list /var/www/html/streams/2_.m3u8 -segment_list_flags +live -segment_list_size 6 -segment_format mpegts -segment_wrap 6 -segment_time 10 /var/www/html/streams/2_%03d.ts

I noticed that if i close ffmpeg it goes to write the .progress file, is there a way to get this info in real time?

Upvotes: 1

Views: 278

Answers (0)

Related Questions