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
cubePHP::neverStop();
$book_id = $args[0];
+ $format = $args[1];
$dir = WS_BOOKS . '/working/' . $book_id;
wsLinks::getLinksAndRulers($book_id, $links, $rulers);
continue;
}
- wsTools::encodeWebVideos($file, null, false, true);
+ wsTools::encodeWebVideos($file, null, false, true, $format);
}
}
`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);
+ }
+ }
+ }
+
}
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://';
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;
$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) {