37 lines
731 B
PHP
37 lines
731 B
PHP
<?php
|
|
chdir("..");
|
|
require_once "src/util.php";
|
|
|
|
$query = $_SERVER["QUERY_STRING"];
|
|
parse_str($query, $param);
|
|
|
|
$path = urlsafe_b64decode($param["file"]);
|
|
$path = "./" . $path;
|
|
$path = str_replace("..", "", $path);
|
|
|
|
$descSpec = [
|
|
0 => array("pipe", "r"),
|
|
1 => array("pipe", "w"),
|
|
2 => array("pipe", "w"),
|
|
];
|
|
$proc = proc_open(["ffprobe", "-show_streams", "-of", "json", $path], $descSpec, $pipes);
|
|
|
|
fclose($pipes[0]);
|
|
|
|
$stdout = stream_get_contents($pipes[1]);
|
|
$stderr = stream_get_contents($pipes[2]);
|
|
fclose($pipes[1]);
|
|
fclose($pipes[2]);
|
|
|
|
$code = proc_close($proc);
|
|
|
|
if ($code)
|
|
{
|
|
header("Content-Type: text/plain");
|
|
echo $stderr;
|
|
} else {
|
|
header("Content-Type: application/json");
|
|
echo $stdout;
|
|
}
|
|
?>
|