summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/movie.php
diff options
context:
space:
mode:
authormamouneyya <mamoun.diraneyya@gmail.com>2010-08-31 18:04:21 +0300
committermamouneyya <mamoun.diraneyya@gmail.com>2010-08-31 18:04:21 +0300
commit0b6664e8f9d19df025739bc4a0cf1821563d6b3d (patch)
tree5b1de2331d4a9d0eb8d97bbb74be6d794d6260a1 /modules/gallery/helpers/movie.php
parent0a128bab0a788288c5291491a68bd1c9ab432825 (diff)
parent23d59dec7240dfa4bffe9d88f46a848e76ce0134 (diff)
Merge remote branch 'gallery3/master'
Diffstat (limited to 'modules/gallery/helpers/movie.php')
-rw-r--r--modules/gallery/helpers/movie.php46
1 files changed, 28 insertions, 18 deletions
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index bbb5b66c..3e55eefe 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -57,23 +57,6 @@ class movie_Core {
return $form;
}
-
- static function getmoviesize($filename) {
- $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+)/", $result, $regs)) {
- list ($width, $height) = array($regs[1], $regs[2]);
- } else {
- list ($width, $height) = array(0, 0);
- }
- return array($width, $height);
- }
-
static function extract_frame($input_file, $output_file) {
$ffmpeg = self::find_ffmpeg();
if (empty($ffmpeg)) {
@@ -101,7 +84,7 @@ class movie_Core {
}
static function find_ffmpeg() {
- if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) {
+ if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
$graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
@@ -114,4 +97,31 @@ class movie_Core {
}
return $ffmpeg_path;
}
+
+
+ /**
+ * Return the width, height, mime_type and extension of the given movie file.
+ */
+ static function get_file_metadata($file_path) {
+ $ffmpeg = self::find_ffmpeg();
+ if (empty($ffmpeg)) {
+ throw new Exception("@todo MISSING_FFMPEG");
+ }
+
+ $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($file_path) . " 2>&1";
+ $result = `$cmd`;
+ if (preg_match("/Stream.*?Video:.*?(\d+)x(\d+)/", $result, $regs)) {
+ list ($width, $height) = array($regs[1], $regs[2]);
+ } else {
+ list ($width, $height) = array(0, 0);
+ }
+
+ $pi = pathinfo($file_path);
+ $extension = isset($pi["extension"]) ? $pi["extension"] : "flv"; // No extension? Assume FLV.
+ $mime_type = in_array(strtolower($extension), array("mp4", "m4v")) ?
+ "video/mp4" : "video/x-flv";
+
+ return array($width, $height, $mime_type, $extension);
+ }
+
}