3 $exe_ffprobe='ffprobe';
4 $exe_imagemagick='convert';
5 $docroot='/'; # must be identical to ardour3->Edit->Preferences->Video->Docroot
8 if (isset($_SERVER['PATH_INFO'])) {
9 switch($_SERVER['PATH_INFO']) {
12 echo 'status: ok, online.';
24 $infile='/tmp/test.avi';
30 if (isset($_REQUEST['format'])) {
31 switch ($_REQUEST['format']) {
50 if (isset($_REQUEST['w']))
51 $w=intval(rawurldecode($_REQUEST['w']));
52 if (isset($_REQUEST['h']))
53 $h=intval(rawurldecode($_REQUEST['h']));
54 if (isset($_REQUEST['frame']))
55 $f=intval(rawurldecode($_REQUEST['frame']));
56 if (isset($_REQUEST['file']))
57 $infile=rawurldecode($_REQUEST['file']);
59 if (!is_readable($docroot.$infile)) {
60 header('HTTP/1.0 404 Not Found', true, 404);
64 $fn=escapeshellarg($docroot.$infile);
66 #$fr=`$exe_ffprobe $fn 2>&1 | awk '/Video:/{printf "%f\\n", $11}'`;
67 $nfo=shell_exec("$exe_ffprobe $fn 2>&1");
68 if (preg_match('@Video:.* ([0-9.]+) tbr,@m',$nfo, $m))
72 if (preg_match('@Duration: ([0-9:.]+),@m',$nfo, $m)) {
73 $d=preg_split('@[\.:]@',$m[1]);
75 $dr+=intval($d[0])*3600;
76 $dr+=intval($d[1])*60;
78 $dr+=floatval($d[3]) / pow(10,strlen($d[3]));
81 if (preg_match('@start: ([0-9:.]+),@m',$nfo, $m)) {
84 if (preg_match('@DAR ([0-9:]+)\]@m',$nfo, $m)) {
85 $d=explode(':',$m[1]);
86 $ar=floatval($d[0]/$d[1]);
88 else if (preg_match('@Video:.* ([0-9]+x[0-9]+),@m',$nfo, $m)) {
89 $d=explode('x',$m[1]);
90 $ar=floatval($d[0]/$d[1]);
94 # Protocol Version number
96 # duration (in frames)
97 # start-offset (in seconds)
99 echo "1\n$fr\n$df\n$so\n$ar\n";
103 if ($df<1 || $f>$df ) exit;
104 $st=floor(1000.0*$f/$fr)/1000.0;
106 $wh=escapeshellarg($w.'x'.$h);
107 $ss=escapeshellarg($st);
109 header('Content-Type: image/'.$fmt);
110 passthru($exe_ffmpeg.' -loglevel quiet'
111 .' -i '.$fn.' -s '.$wh.' -ss '.$ss.' -vframes 1 '
112 .'-f image2 -vcodec png - 2>/dev/null'
113 .'| '.$exe_imagemagick.' - '.$fmt.':-');