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.label Use EXIF thumbs
span.result ? span.result ?
div.info PHP EXIF extension available div.info PHP EXIF extension available
li.test( data-id="ffmpeg" ) li.test( data-id="moviethumbs" )
span.label Movie thumbs span.label Movie thumbs
span.result ? span.result ?
div.info div.info
| Command line program | Command line program
code ffmpeg code ffmpeg
| or
code avconv
| available | available
li.test( data-id="convert" ) li.test( data-id="convert" )
span.label PDF thumbs span.label PDF thumbs

View file

@ -310,6 +310,7 @@ class App {
$zip = @preg_match("/zip(.exe)?$/i", exec_cmd($cmd . " zip")) > 0; $zip = @preg_match("/zip(.exe)?$/i", exec_cmd($cmd . " zip")) > 0;
$convert = @preg_match("/convert(.exe)?$/i", exec_cmd($cmd . " convert")) > 0; $convert = @preg_match("/convert(.exe)?$/i", exec_cmd($cmd . " convert")) > 0;
$ffmpeg = @preg_match("/ffmpeg(.exe)?$/i", exec_cmd($cmd . " ffmpeg")) > 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; $du = @preg_match("/du(.exe)?$/i", exec_cmd($cmd . " du")) > 0;
return array( return array(
@ -323,6 +324,8 @@ class App {
"zip" => $zip, "zip" => $zip,
"convert" => $convert, "convert" => $convert,
"ffmpeg" => $ffmpeg, "ffmpeg" => $ffmpeg,
"avconv" => $avconv,
"moviethumbs" => $ffmpeg || $avconv,
"du" => $du "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("[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); $cmd = str_replace("[FILES]", count($this->files) ? implode(" ", array_map("escapeshellarg", $this->files)) : "", $cmd);
try { try {
passthru($cmd); passthru_cmd($cmd);
} catch (Exeption $err) { } catch (Exeption $err) {
return 500; return 500;
} }

View file

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

View file

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