summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/helpers/movie.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/helpers/movie.php b/core/helpers/movie.php
index 93420509..67cce910 100644
--- a/core/helpers/movie.php
+++ b/core/helpers/movie.php
@@ -101,9 +101,11 @@ class movie_Core {
}
static function getmoviesize($filename) {
- if (!$ffmpeg = exec("which ffmpeg")) {
+ $ffmpeg = self::find_ffmpeg();
+ if (empty($ffmpeg)) {
throw new Exception("@todo MISSING_FFMPEG");
}
+
$cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($filename) . " 2>&1";
$result = `$cmd`;
if (preg_match("/Stream.*?Video:.*?(\d+)x(\d+).*\ +([0-9\.]+) (fps|tb).*/",
@@ -116,7 +118,8 @@ class movie_Core {
}
static function extract_frame($input_file, $output_file) {
- if (!$ffmpeg = exec("which ffmpeg")) {
+ $ffmpeg = self::find_ffmpeg();
+ if (empty($ffmpeg)) {
throw new Exception("@todo MISSING_FFMPEG");
}
@@ -125,4 +128,16 @@ class movie_Core {
" -y -f mjpeg " . escapeshellarg($output_file);
exec($cmd);
}
+
+ static function find_ffmpeg() {
+ if (!$ffmpeg_path = module::get_var("core", "ffmpeg_path")) {
+ if (function_exists("exec")) {
+ $ffmpeg_path = exec("which ffmpeg");
+ if ($ffmpeg_path) {
+ module::set_var("core", "ffmpeg_path", $ffmpeg_path);
+ }
+ }
+ }
+ return $ffmpeg_path;
+ }
}