diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-13 20:46:59 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-13 20:46:59 +0000 |
commit | 7ada2e7fe63a0d971c4cd24544a390cc2fee0980 (patch) | |
tree | 6f15e241c6f192e4da53a00658f66ef4f547d61b /core/helpers | |
parent | 07bf3e071e2c621526aa7d1dcf0b08826563c3d2 (diff) |
Store the ffmpeg path in a variable.
Diffstat (limited to 'core/helpers')
-rw-r--r-- | core/helpers/movie.php | 19 |
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; + } } |