]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 15 Jul 2011 01:31:45 +0000 (01:31 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 15 Jul 2011 01:31:45 +0000 (01:31 +0000)
fluidbook/tools/webvideo
inc/ws/Util/class.ws.tools.php
inc/ws/Util/packager/class.ws.packager.php
inc/ws/Util/packager/html5/class.ws.packager.html5.links.php
inc/ws/Util/packager/html5/class.ws.packager.html5.php

index 08781a86257b07c1675a5a16403a906bf81c657a..18f401131a47c2763b382abf2ab2c25d68edf3ca 100644 (file)
@@ -5,5 +5,7 @@ extension=${filename##*.}
 filename=${filename%.*}
 
 
+/usr/local/bin/ffmpeg -i $1 -y -r 1 -ss 00:00:04 -t 00:00:01 -f image2 $2/$filename.jpg
+/usr/local/bin/ffmpeg -i $1 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -vcodec libvpx -b 614400 -acodec libvorbis -y $2/$filename.webm
 /usr/bin/ffmpeg -i $1 -y -acodec aac -ab 128k -vcodec libx264 -b 1200k -mbd 2 -cmp 2 -subcmp 2 -strict experimental $2/$filename.mp4
 /usr/local/bin/ffmpeg2theora $1 -o $2/$filename.ogv
\ No newline at end of file
index faf132aa92738708b23aabf8af752c7efdc53a6b..c1749b5ee10cb942ba86fbc8b76f1d24c2296f11 100644 (file)
@@ -8,7 +8,7 @@ class wsTools {
                }
                $log = $dir . '/' . cubeFiles::getName($file) . '.log';
 
-               if (!$force && file_exists($log)) {
+               if (!$force && file_exists($log) && filemtime($log) > filemtime($file)) {
                        return;
                }
 
@@ -17,7 +17,7 @@ class wsTools {
                if ($async) {
                        $webvideo->setNohup(true);
                }
-               $webvideo->setArg(null, $dest);
+               $webvideo->setArg(null, $file);
                $webvideo->setArg(null, $dir);
                $webvideo->execute();
        }
index 00543ecbbd7a6112f02a5d821b4e49da9d029dd1..16e254cb02a6cf19b41711d7fcb26101a7291940 100644 (file)
@@ -13,6 +13,7 @@ class wsPackager {
        protected $daoBook;\r
 \r
        public static function package($book_id, $version) {\r
+               cubePHP::neverStop();\r
                if ($version == 'html') {\r
                        $packager = new wsPackagerHTML($book_id);\r
                } elseif ($version == 'win-exe') {\r
index 1b68c923a0f7ca555dd5c5e0894e78be7c6e2a41..9a251946203c94e0e34a8ec2508928a59b6b9299 100644 (file)
@@ -35,14 +35,23 @@ class wsPackagerHTML5Link {
                        case 5:
                                return new internalLink($id, $init, $packager);
                        case 4:
-                               return new videoLink($id, $init, $packager);
+                               if ($init['inline']) {
+                                       return new videoLink($id, $init, $packager);
+                               } else {
+                                       return new videoPopupLink($id, $init, $packager);
+                               }
                        case 6:
+                               return new multimediaLink($id, $init, $packager);
                        case 7:
                        case 8:
                        case 9:
                                return null;
                        case 10:
-                               return new webVideoLink($id, $init, $packager);
+                               if ($init['inline']) {
+                                       return new webVideoLink($id, $init, $packager);
+                               } else {
+                                       return new webVideoPopupLink($id, $init, $packager);
+                               }
                        case 11:
                                return new actionLink($id, $init, $packager);
                        case 12:
@@ -76,8 +85,8 @@ class wsPackagerHTML5Link {
                return '';
        }
 
-       public function copyExternalFile($file) {
-               $this->packager->copyLinkFile($file, 'data/links/');
+       public function copyExternalFile($file, $video=false) {
+               $this->packager->copyLinkFile($file, 'data/links/', $video);
        }
 
        public function getCSSContainer() {
@@ -93,14 +102,17 @@ class wsPackagerHTML5Link {
                return 'border:1px dotter #ff0000;';
        }
 
-       public static function getUniversalLocation($loc) {
-               $target = null;
-               parse_url($loc);
+       public static function getUniversalLocation($loc, $css=false) {
+               $datas = parse_url($loc);
 
-               if (!is_null($loc['scheme'])) {
+               if (isset($datas['scheme']) && !is_null($datas['scheme'])) {
                        return $loc;
                } else {
-                       return 'data/links/' . $loc;
+                       if ($css) {
+                               return '../links/' . $loc;
+                       } else {
+                               return 'data/links/' . $loc;
+                       }
                }
        }
 
@@ -181,6 +193,11 @@ class internalLink extends normalLink {
 class videoLink extends wsPackagerHTML5Link {
 
        public function getHTMLContent() {
+               $file = $this->to;
+               $e = explode('.', $file);
+               $ext = array_pop($e);
+               $basename = implode('.', $e);
+
                $res = '<video width="' . $this->width . '" height="' . $this->height . '"';
                if ($this->video_auto_start) {
                        $res.=' autoplay="autoplay"';
@@ -194,17 +211,18 @@ class videoLink extends wsPackagerHTML5Link {
                if (!$this->video_sound_on) {
                        $res.=' audio="muted"';
                }
+               $res.=' poster="data/links/' . $basename . '.jpg"';
                $res.='>';
 
-               $file = $this->to;
-               $e = explode('.', $file);
-               $ext = array_pop($e);
-               $basename = implode('.', $e);
 
-               $types = array('mp4' => 'video/mp4; codecs=\'avc1.42E01E, mp4a.40.2\'', 'ogv' => 'video/ogg; codecs=\'theora, vorbis\'');
+
+               $this->copyExternalFile($this->to, true);
+               $types = array('mp4' => '', 'webm' => 'video/webm; codecs="vp8, vorbis"', 'ogv' => 'video/ogg; codecs="theora, vorbis"');
                foreach ($types as $ext => $type) {
-                       $res.='<source src="' . wsPackagerHTML5Link::getUniversalLocation($basename . '.' . $ext) . '" type="' . $type . '" />';
-                       $this->copyExternalFile($basename . '.' . $ext);
+                       if ($type != '') {
+                               $type = " type='" . $type . "'";
+                       }
+                       $res.='<source src="' . wsPackagerHTML5Link::getUniversalLocation($basename . '.' . $ext) . '"' . $type . '></source>';
                }
                $res.='</video>';
                return $res;
@@ -248,7 +266,7 @@ class basketLink extends wsPackagerHTML5Link {
 class colorLink extends contentLink {
 
        public function getCSS() {
-               return 'background-color:#' . $this->to . ';';
+               return 'background-color:' . wsPackagerHTML5::colorToCSS($this->to) . ';';
        }
 
 }
@@ -257,7 +275,7 @@ class imageLink extends contentLink {
 
        public function getCSS() {
                $this->copyExternalFile($this->to);
-               return 'background-image:url(../' . wsPackagerHTML5Link::getUniversalLocation($this->to) . ');background-size:100% 100%;background-repeat:no-repeat;';
+               return 'background-image:url(' . wsPackagerHTML5Link::getUniversalLocation($this->to, true) . ');background-size:100% 100%;background-repeat:no-repeat;';
        }
 
 }
@@ -275,4 +293,34 @@ class fileLink extends normalLink {
 
 }
 
+class multimediaLink extends wsPackagerHTML5Link {
+
+       public function getHTMLContent() {
+               return cubeMedia::flashObject(wsPackagerHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
+       }
+
+}
+
+class videoPopupLink extends normalLink {
+
+       public function getURL() {
+               $this->copyExternalFile($this->to, true);
+               return '#/video/' . $this->to;
+       }
+
+}
+
+class webVideoPopupLink extends videoPopupLink {
+
+       public function getURL() {
+               if ($this->video_service == 0) {
+                       $service = 'youtube';
+               } elseif ($this->video_service == 1) {
+                       $service = 'dailymotion';
+               }
+               return '#/webvideo/' . $service . '/' . $this->to;
+       }
+
+}
+
 ?>
index 3a4cc7170e6179fd4c3f20a6ecc4ad865fbaf3ef..7770b83c81b82ed01be362079e7710ccbeb6b133 100644 (file)
@@ -58,6 +58,7 @@ class wsPackagerHTML5 extends wsPackager {
                mkdir($this->vdir . '/data/images', 0777, true);\r
                mkdir($this->vdir . '/data/contents', 0777, true);\r
                mkdir($this->vdir . '/data/background', 0777, true);\r
+               mkdir($this->vdir . '/data/thumbnails', 0777, true);\r
                mkdir($this->vdir . '/data/style', 0777, true);\r
                mkdir($this->vdir . '/data/links/pages', 0777, true);\r
 \r
@@ -149,6 +150,7 @@ class wsPackagerHTML5 extends wsPackager {
                        foreach (self::$resolutions as $r) {\r
                                copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg');\r
                        }\r
+                       copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');\r
                }\r
        }\r
 \r
@@ -565,14 +567,35 @@ class wsPackagerHTML5 extends wsPackager {
                return $str;\r
        }\r
 \r
-       public function copyLinkFile($source, $dest) {\r
-               $s = WS_BOOKS . '/working/' . $this->book_id . '/' . $source;\r
-               if (file_exists($s)) {\r
-                       $d = $this->vdir . '/' . $dest . '/' . $source;\r
-                       if (!file_exists(dirname($d))) {\r
-                               mkdir(dirname($d), 0777, true);\r
+       public function copyLinkFile($source, $dest, $video=false) {\r
+\r
+               $origDir = WS_BOOKS . '/working/' . $this->book_id . '/';\r
+               $types = array('mp4', 'ogv', 'webm', 'jpg');\r
+               if ($video) {\r
+                       wsTools::encodeWebVideos($origDir . $source, null, false);\r
+                       $e = explode('.', $source);\r
+                       array_pop($e);\r
+                       $base = implode('.', $e);\r
+                       $source = array();\r
+                       foreach ($types as $type) {\r
+                               $source[] = $base . '.' . $type;\r
+                       }\r
+               }\r
+\r
+               if (!is_array($source)) {\r
+                       $source = array($source);\r
+               }\r
+\r
+               foreach ($source as $so) {\r
+                       $s = $origDir . $so;\r
+                       fb($s);\r
+                       if (file_exists($s)) {\r
+                               $d = $this->vdir . '/' . $dest . '/' . $so;\r
+                               if (!file_exists(dirname($d))) {\r
+                                       mkdir(dirname($d), 0777, true);\r
+                               }\r
+                               copy($s, $d);\r
                        }\r
-                       copy($s, $d);\r
                }\r
        }\r
 \r