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.';
21 # TODO proper CSV encode (possible quotes in docroot)
22 # TODO support optional plain text version
23 echo '"'.$docroot.'",'.$_SERVER['SERVER_ADDR'].','.$_SERVER['SERVER_PORT'].',0,"/info /rc /status",""'."\n";
24 echo 'status: ok, online.';
32 $infile='/tmp/test.avi';
38 if (isset($_REQUEST['format'])) {
39 switch ($_REQUEST['format']) {
61 if (isset($_REQUEST['w']))
62 $w=intval(rawurldecode($_REQUEST['w']));
63 if (isset($_REQUEST['h']))
64 $h=intval(rawurldecode($_REQUEST['h']));
65 if (isset($_REQUEST['frame']))
66 $f=intval(rawurldecode($_REQUEST['frame']));
67 if (isset($_REQUEST['file']))
68 $infile=rawurldecode($_REQUEST['file']);
70 if (!is_readable($docroot.$infile)) {
71 header('HTTP/1.0 404 Not Found', true, 404);
75 $fn=escapeshellarg($docroot.$infile);
77 #$fr=`$exe_ffprobe $fn 2>&1 | awk '/Video:/{printf "%f\\n", $11}'`;
78 $nfo=shell_exec("$exe_ffprobe $fn 2>&1");
79 if (preg_match('@Video:.* ([0-9.]+) tbr,@m',$nfo, $m))
83 if (preg_match('@Duration: ([0-9:.]+),@m',$nfo, $m)) {
84 $d=preg_split('@[\.:]@',$m[1]);
86 $dr+=intval($d[0])*3600;
87 $dr+=intval($d[1])*60;
89 $dr+=floatval($d[3]) / pow(10,strlen($d[3]));
92 if (preg_match('@start: ([0-9:.]+),@m',$nfo, $m)) {
95 if (preg_match('@DAR ([0-9:]+)\]@m',$nfo, $m)) {
96 $d=explode(':',$m[1]);
97 $ar=floatval($d[0]/$d[1]);
99 else if (preg_match('@Video:.* ([0-9]+x[0-9]+),@m',$nfo, $m)) {
100 $d=explode('x',$m[1]);
101 $ar=floatval($d[0]/$d[1]);
105 if (isset($_REQUEST['format'])) {
106 switch ($_REQUEST['format']) {
108 # protocol, width, height, aspect, fps, fps, duration
109 echo "1,0,0,$ar,$fr,$df\n";
116 # Protocol Version number
118 # duration (in frames)
119 # start-offset (in seconds)
121 echo "1\n$fr\n$df\n$so\n$ar\n";
125 if ($df<1 || $f>$df ) exit;
126 $st=floor(1000.0*$f/$fr)/1000.0;
128 $wh=escapeshellarg($w.'x'.$h);
129 $ss=escapeshellarg($st);
131 header('Content-Type: image/'.$fmt);
132 passthru($exe_ffmpeg.' -loglevel quiet'
133 .' -i '.$fn.' -s '.$wh.' -ss '.$ss.' -vframes 1 '
134 .'-f image2 -vcodec png - 2>/dev/null'
135 .'| '.$exe_imagemagick.' - '.$fmt.':-');