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
+ulimit -t 360;/usr/local/bin/ffmpeg -i $1 -y -r 1 -ss 00:00:04 -t 00:00:01 -f image2 $2/$filename.jpg
+ulimit -t 360;/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
+ulimit -t 360;/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
+ulimit -t 360;/usr/local/bin/ffmpeg2theora $1 -o $2/$filename.ogv
\ No newline at end of file
global $core;
$c = $core->con->openCursor('document_links_versions');
$c1 = $core->con->openCursor('document_links');
- $c1->document_id=$c->document_id=$document_id;
+ $c1->document_id = $c->document_id = $document_id;
$c1->links = $c->links = $links;
$c1->rulers = $c->rulers = $rulers;
$c->comments = $comments;
$core->con->execute('DELETE FROM document_links WHERE document_id=' . $document_id);
$c1->insert();
}
-
- public static function getLinksAndRulers($book_id, &$links, &$rulers, $time=null) {
+ public static function getDocumentLastLinks($document_id) {
+ global $core;
+
+ $r = $core->con->select('SELECT * FROM document_links WHERE document_id=\'' . $document_id . '\'');
+ if (!$r->count()) {
+ $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id . ' ORDER BY `update` DESC LIMIT 1');
+ $c = $core->con->openCursor('document_links');
+ $c->document_id = $document_id;
+ $c->links = $r->links;
+ $c->rulers = $r->rulers;
+ $c->insert();
+ }
+
+ return self::_recordToLinks($r);
+ }
+
+ public static function getDocumentVersionLinks($document_id, $time) {
global $core;
-
- if (is_null($time)) {
- $timeQuery = 'ORDER BY `update` DESC LIMIT 1';
+ $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id . ' AND `update`=' . $time);
+ return self::_recordToLinks($r);
+ }
+
+ protected static function _recordToLinks($r) {
+ if (mb_substr($r->links, 1, 1) == ':') {
+ $ll = unserialize($r->links);
+ $rr = unserialize($r->rulers);
} else {
- $timeQuery = 'AND `update`=' . $time;
+ $ll = json_decode($r->links, true);
+ $rr = json_decode($r->rulers, true);
}
+ return array('links' => $ll, 'rulers' => $rr);
+ }
+
+ public static function getLinksAndRulers($book_id, &$links, &$rulers, $time=null) {
+
+ global $core;
+
$daoBook = new wsDAOBook($core->con);
$pages = $daoBook->getPagesOfBookAt($book_id, $time);
$rulers = array();
foreach ($documents as $d) {
- $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $d . ' ' . $timeQuery);
-
- if (mb_substr($r->links, 1, 1) == ':') {
- $ll = unserialize($r->links);
- $rr = unserialize($r->rulers);
+ if (is_null($time)) {
+ $lr = self::getDocumentLastLinks($d);
} else {
- $ll = json_decode($r->links, true);
- $rr = json_decode($r->rulers, true);
+ $lr = self::getDocumentVersionLinks($d, $time);
}
- $tlinks[$d] = $ll;
- $trulers[$d] = $rr;
+ $tlinks[$d] = $lr['links'];
+ $trulers[$d] = $lr['rulers'];
}
$i = 1;