From 0ea515cf00ff45e3c606ba93c0da35e97ec014f2 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 12 May 2014 13:14:59 +0000 Subject: [PATCH] --- fluidbook/tools/webvideo | 137 +++++++++++--------- inc/ws/Controlleur/class.ws.maintenance.php | 13 +- inc/ws/Util/class.ws.exporter.php | 6 +- inc/ws/Util/class.ws.tools.php | 39 +++++- 4 files changed, 132 insertions(+), 63 deletions(-) diff --git a/fluidbook/tools/webvideo b/fluidbook/tools/webvideo index 23f522acc..162873d78 100644 --- a/fluidbook/tools/webvideo +++ b/fluidbook/tools/webvideo @@ -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 diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 7d0bcceb7..d24960c16 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -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); + } + } + } + } diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index d2d868f1f..7ba4c55bd 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -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://'; diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 5f3b94ed3..27f0c7ef3 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -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) { -- 2.39.5