Add passthru delegate and avconv support.

This commit is contained in:
Lars Jung 2014-05-09 21:56:12 +02:00
parent 365b6d8019
commit 08e18b40b5
5 changed files with 18 additions and 3 deletions

View File

@ -48,12 +48,14 @@ html.no-js.browser( lang="en" )
span.label Use EXIF thumbs
span.result ?
div.info PHP EXIF extension available
li.test( data-id="ffmpeg" )
li.test( data-id="moviethumbs" )
span.label Movie thumbs
span.result ?
div.info
| Command line program
code ffmpeg
| or
code avconv
| available
li.test( data-id="convert" )
span.label PDF thumbs

View File

@ -310,6 +310,7 @@ class App {
$zip = @preg_match("/zip(.exe)?$/i", exec_cmd($cmd . " zip")) > 0;
$convert = @preg_match("/convert(.exe)?$/i", exec_cmd($cmd . " convert")) > 0;
$ffmpeg = @preg_match("/ffmpeg(.exe)?$/i", exec_cmd($cmd . " ffmpeg")) > 0;
$avconv = @preg_match("/avconv(.exe)?$/i", exec_cmd($cmd . " avconv")) > 0;
$du = @preg_match("/du(.exe)?$/i", exec_cmd($cmd . " du")) > 0;
return array(
@ -323,6 +324,8 @@ class App {
"zip" => $zip,
"convert" => $convert,
"ffmpeg" => $ffmpeg,
"avconv" => $avconv,
"moviethumbs" => $ffmpeg || $avconv,
"du" => $du
);
}

View File

@ -48,7 +48,7 @@ class Archive {
$cmd = str_replace("[DIRS]", count($this->dirs) ? implode(" ", array_map("escapeshellarg", $this->dirs)) : "", $cmd);
$cmd = str_replace("[FILES]", count($this->files) ? implode(" ", array_map("escapeshellarg", $this->files)) : "", $cmd);
try {
passthru($cmd);
passthru_cmd($cmd);
} catch (Exeption $err) {
return 500;
}

View File

@ -3,6 +3,7 @@
class Thumb {
private static $FFMPEG_CMD = "ffmpeg -ss 0:01:00 -i [SOURCE] -an -vframes 1 [TARGET]";
private static $AVCONV_CMD = "avconv -ss 0:01:00 -i [SOURCE] -an -vframes 1 [TARGET]";
private static $CONVERT_CMD = "convert -strip [SOURCE][0] [TARGET]";
private static $THUMB_CACHE = "thumbs";
@ -36,6 +37,9 @@ class Thumb {
$capture_abs_path = $source_abs_path;
} else if ($type === "mov") {
$capture_abs_path = $this->capture(Thumb::$FFMPEG_CMD, $source_abs_path);
if ($capture_abs_path === null) {
$capture_abs_path = $this->capture(Thumb::$AVCONV_CMD, $source_abs_path);
}
} else if ($type === "doc") {
$capture_abs_path = $this->capture(Thumb::$CONVERT_CMD, $source_abs_path);
}

View File

@ -77,8 +77,14 @@ function exec_cmd($cmd) {
$lines = array();
$rc = null;
exec($cmd, $lines, $rc);
return implode("\n", $lines);
}
return implode('\n', $lines);
function passthru_cmd($cmd) {
$rc = null;
passthru($cmd, $rc);
return $rc;
}
?>