<?php include 'playlist.class.php'; $SAVEPATH = "settings"; $query_str = $_GET; if (array_key_exists('command', $query_str)) { $command = $query_str["command"]; } else { $command = ""; } if (array_key_exists('seek', $query_str)) { $seek = $query_str["seek"]; } else { $seek = 0; } if (array_key_exists('channel', $query_str)) { $channel = $query_str["channel"]; } else { $channel = "10"; } $myparsedlist = new FflistClass(file_get_contents($SAVEPATH . '/' . $channel . "-playlist.json")); // $myparsedlist->fromJSON(file_get_contents($channel . "-playlist.json")); $stream = $myparsedlist->toFFCONCAT($seek); echo $stream["concat"];
function isffconcat1($input, $seek = 0) { $ext = explode("?", strtolower(pathinfo($input)['extension']))[0]; // file_put_contents('ext.log', $ext); if (in_array($ext, ["php"])) { return " -f concat -i '" . $input . "&seek=" . $seek . "'"; } elseif (in_array($ext, ["ffconcat", "ffcat", "txt", "lst"])) { return " -f concat -i '{$input}'"; } else { return " -i '{$input}'"; } } $seek = $argv[3]; if (Conf::FFMPEGLEGACY) { $myparsedlist = new FflistClass(file_get_contents(Conf::SAVEPATH . '/' . $argv[2] . "-playlist.json")); $ss = " -ss " . $myparsedlist->toFFCONCAT($seek)["ss"]; if (intval($myparsedlist->toFFCONCAT($seek)["t"]) !== 0) { $t = " -t " . $myparsedlist->toFFCONCAT($seek)["t"]; } else { $t = " "; } } else { $ss = " "; $t = " "; } exec("pkill -f '^ffmpeg.*rtmp://127.0.0.1/wrapper/" . $argv[2] . "\$' &"); define("OUTPUT", " -c:v:0 copy -c:a copy -f flv -flags +global_header rtmp://127.0.0.1/wrapper/"); $input = isffconcat1($argv[1], intval($seek)); $output = OUTPUT . $argv[2]; $log = ">{$logfile} 2>&1"; file_put_contents(Conf::LOGDIR . "/seek.log", "ffmpeg -re -hide_banner -loglevel info -nostats -nostdin" . $ss . $t . $input . $output . $log . " & echo \$!");