]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 12 May 2014 13:14:59 +0000 (13:14 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 12 May 2014 13:14:59 +0000 (13:14 +0000)
fluidbook/tools/webvideo
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/class.ws.exporter.php
inc/ws/Util/class.ws.tools.php

index 23f522acc5a3903e38287e06f2f390306d25b92d..162873d78d836ecec0559a714148121564155947 100644 (file)
@@ -5,67 +5,88 @@ extension=${filename##*.}
 filename=${filename%.*}
 mp4w=$3
 mp4h=$4
+jpg=$2/$filename.jpg
+mp4=$2/$filename.mp4
+ogv=$2/$filename.ogv
+webm=$2/$filename.webm
 
-echo 'making jpg'
-echo
-echo
+if [ ! -f $jpg ]
+then
+       echo
+       echo
+       echo 'making jpg'
+       echo
+       echo
 
-/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 -y -r 1 -ss 00:00:04 -t 00:00:01 -f image2 $jpg
+fi
 
-if [ extension != "mp4" ]
+if [ ! -f $mp4 ] && [ extension != "mp4" ]
 then
-echo 'making mp4'
-echo
-echo
-/usr/bin/ffmpeg -i $1 \
--y \
--acodec aac \
--vcodec libx264 \
--b 384k \
--ab 64k \
--mbd 2 \
--cmp 256 \
--subcmp 2 \
--subq 6 \
--strict experimental \
--vf scale="640:trunc(320/a)*2" \
--coder 0 \
--trellis 0 \
--bf 0 \
--refs 5 \
--flags +loop+mv4 \
--partitions +parti4x4+parti8x8+partp4x4+partp8x8 \
--flags2 +mixed_refs \
--me_range 16 \
--g 250 \
--keyint_min 25 \
--sc_threshold 40 \
--i_qfactor 0.71 \
--qmin 10 -qmax 51 \
--qdiff 4 \
--ac 2 \
--ar 44100 \
--r 13 \
-$2/$filename.mp4
+       echo 'making mp4'
+       echo
+       echo
+       /usr/bin/ffmpeg -i $1 \
+       -y \
+       -acodec aac \
+       -vcodec libx264 \
+       -b 384k \
+       -ab 64k \
+       -mbd 2 \
+       -cmp 256 \
+       -subcmp 2 \
+       -subq 6 \
+       -strict experimental \
+       -vf scale="640:trunc(320/a)*2" \
+       -coder 0 \
+       -trellis 0 \
+       -bf 0 \
+       -refs 5 \
+       -flags +loop+mv4 \
+       -partitions +parti4x4+parti8x8+partp4x4+partp8x8 \
+       -flags2 +mixed_refs \
+       -me_range 16 \
+       -g 250 \
+       -keyint_min 25 \
+       -sc_threshold 40 \
+       -i_qfactor 0.71 \
+       -qmin 10 -qmax 51 \
+       -qdiff 4 \
+       -ac 2 \
+       -ar 44100 \
+       -r 13 \
+       $mp4
 fi
-echo 'making webm'
-echo
-echo
-/usr/local/bin/ffmpeg -i $1 \
--keyint_min 0 \
--g 250 \
--skip_threshold 0 \
--qmin 1 \
--qmax 51 \
--vcodec libvpx \
--b 614400 \
--acodec libvorbis \
--ar 44100 \
--ac 2 \
--ab 64k \
--y $2/$filename.webm
 
-echo 'making ogv'
-echo
-echo
-/usr/local/bin/ffmpeg2theora $1 -o $2/$filename.ogv
+if [ ! -f $webm ]
+then
+       echo
+       echo
+       echo 'making webm'
+       echo
+       echo
+       /usr/local/bin/ffmpeg -i $1 \
+       -keyint_min 0 \
+       -g 250 \
+       -skip_threshold 0 \
+       -qmin 1 \
+       -qmax 51 \
+       -vcodec libvpx \
+       -b 614400 \
+       -acodec libvorbis \
+       -ar 44100 \
+       -ac 2 \
+       -ab 64k \
+       -y $webm
+fi
+
+
+if [ ! -f $ogv ]
+then
+       echo
+       echo
+       echo 'making ogv'
+       echo
+       echo
+       avconv  -i $1 -c:v libtheora -q:v 5 -c:a libvorbis -q:a 5 -y $ogv
+fi
\ No newline at end of file
index 7d0bcceb75d5aac31cc5d85d2ee682f65c765b73..d24960c16db0e1e006ccf153870f53468e943f83 100644 (file)
@@ -778,6 +778,7 @@ class wsMaintenance {
                cubePHP::neverStop();
 
                $book_id = $args[0];
+               $format = $args[1];
                $dir = WS_BOOKS . '/working/' . $book_id;
 
                wsLinks::getLinksAndRulers($book_id, $links, $rulers);
@@ -792,7 +793,7 @@ class wsMaintenance {
                                continue;
                        }
 
-                       wsTools::encodeWebVideos($file, null, false, true);
+                       wsTools::encodeWebVideos($file, null, false, true, $format);
                }
        }
 
@@ -893,4 +894,14 @@ class wsMaintenance {
                `rm -rf $i`;
        }
 
+       public static function _reencodeVideos($book_id, $format) {
+               wsLinks::getLinksAndRulers($book_id, $links, $rulers);
+               foreach ($links as $l) {
+                       if ($l['type'] == 10) {
+                               $to = $l['to'];
+                               fb($to);
+                       }
+               }
+       }
+
 }
index d2d868f1fb6581a008dad67ab72de3dd9a04183e..7ba4c55bd5506fb6b22e64a1432d038cab3c28e0 100644 (file)
@@ -312,10 +312,12 @@ class wsExporter {
 
 
                if ($this->action == 'references') {
-                       $root = 'fluidbook@www.fluidbook.com:/home/fluidbook/www/references/';
+                       //$root = 'fluidbook@www.fluidbook.com:/home/fluidbook/www/references/';
+                       $root = '/mnt/sshfs/fluidbook/www/references/';
                        $rootURL = 'http://www.fluidbook.com/references/';
                } else if ($this->action == 'hosting') {
-                       $root = 'fluidbook@hosting.fluidbook.com:/home/fluidbook/hosting/';
+                       //$root = 'fluidbook@hosting.fluidbook.com:/home/fluidbook/hosting/';
+                       $root = '/mnt/sshfs/fluidbook/hosting/';
                        $rootURL = 'http://hosting.fluidbook.com/';
                } else if ($this->action == 'ftp') {
                        $root = 'ftp://';
index 5f3b94ed3baab5560ae989ab5afba95030c3e195..27f0c7ef3c6214a0d2b1974af2ac896839f2b9ed 100644 (file)
@@ -2,11 +2,44 @@
 
 class wsTools {
 
-       public static function encodeWebVideos($file, $dir = null, $async = true, $force = false) {
+       public static function encodeWebVideos($file, $dir = null, $async = true, $force = false, $format = 'all') {
                if (is_null($dir)) {
                        $dir = dirname($file);
                }
-               $log = $dir . '/' . cubeFiles::getName($file) . '.log';
+
+               $videos = array('mp4', 'webm', 'ogv', 'jpg');
+
+
+               if (is_string($format)) {
+                       if ($format == 'none') {
+                               $format = array();
+                       } elseif ($format == 'all') {
+                               $format = $videos;
+                       } else {
+                               $format = array($format);
+                       }
+               }
+
+
+               if (!$force) {
+                       $format = array();
+               }
+
+               $base = $dir . '/' . cubeFiles::getName($file);
+               $log = $base . '.log';
+
+
+               foreach ($videos as $v) {
+                       $vfile = $base . '.' . $v;
+                       fb($vfile);
+                       if (!file_exists($vfile)) {
+                               $force = true;
+                       } else if (filemtime($file) > filemtime($vfile) || in_array($v, $format)) {
+                               $force = true;
+                               unlink($vfile);
+                               fb('unlink');
+                       }
+               }
 
                if (!$force && file_exists($log) && filemtime($log) > filemtime($file)) {
                        return;
@@ -20,6 +53,8 @@ class wsTools {
                $webvideo->setArg(null, $file);
                $webvideo->setArg(null, $dir);
                $webvideo->execute();
+               fb($webvideo->commande);
+               fb($webvideo->output);
        }
 
        public static function colorizeAndRasterizeIcon($iconSet, $icon, $colors, $dest, $scale, &$w, &$h, $makepng = true) {