diff --git a/inc/core.php b/inc/core.php index 3278707..e43e21c 100644 --- a/inc/core.php +++ b/inc/core.php @@ -1,6 +1,7 @@ gifToMP4($gifpath,$mp4path); if(!file_exists($webmpath) && $data['webm'] && !$data['preview']) $pm->saveAsWebm($gifpath,$webmpath); + + if(!file_exists($oggpath) && $data['ogg'] && !$data['preview']) + $pm->saveAsOGG($gifpath,$oggpath); if($data['raw']) { if($data['webm']) serveFile($webmpath, $hash.'.webm','video/webm'); + if($data['ogg']) + serveFile($oggpath, $hash.'.ogg','video/ogg'); else serveFile($mp4path, $hash.'.mp4','video/mp4'); } @@ -208,6 +235,11 @@ function renderImage($data) { $pm->saveAsWebm(ROOT.DS.'upload'.DS.$hash.DS.$hash,$cachepath); } + + if($data['ogg']) + { + $pm->saveAsOGG(ROOT.DS.'upload'.DS.$hash.DS.$hash,$cachepath); + } if($data['raw']) { diff --git a/models/pictsharemodel.php b/models/pictsharemodel.php index b58d341..06edcae 100644 --- a/models/pictsharemodel.php +++ b/models/pictsharemodel.php @@ -4,6 +4,20 @@ class PictshareModel extends Model { function backend($params) { + switch($params[0]) + { + case 'mp4convert': + $hash = $params[1]; + $path = $params[2]; + $source = $path.$hash; + if(!$this->isImage($hash)) + exit('[x] Hash not found'."\n"); + echo "[i] Converting $hash to mp4\n"; + $this->saveAsMP4($source,$path.'mp4_1.'.$hash); + $this->saveAsMP4($source,$path.'ogg_1.'.$hash); + break; + } + return array('status'=>'ok'); } @@ -57,7 +71,7 @@ class PictshareModel extends Model if($this->isImage($el)) $data['hash']=$el; - else if($el=='mp4' || $el=='raw' || $el=='preview' || $el=='webm') + else if($el=='mp4' || $el=='raw' || $el=='preview' || $el=='webm' || $el=='ogg') $data[$el] = 1; else if($this->isSize($el)) $data['size'] = $el; @@ -705,7 +719,16 @@ class PictshareModel extends Model $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); $source = escapeshellarg($source); $target = escapeshellarg($target); - $h265 = "$bin -y -i $source -an -c:v libx264 -f mp4 $target"; + $h265 = "$bin -y -i $source -an -c:v libx264 -qp 0 -f mp4 $target"; + system($h265); + } + + function saveAsOGG($source,$target) + { + $bin = escapeshellcmd(ROOT.DS.'bin'.DS.'ffmpeg'); + $source = escapeshellarg($source); + $target = escapeshellarg($target); + $h265 = "$bin -y -i $source -an -codec:v libtheora -qp 0 -f ogg $target"; system($h265); } diff --git a/template_mp4.php b/template_mp4.php index b4776f8..37aa9d2 100644 --- a/template_mp4.php +++ b/template_mp4.php @@ -15,6 +15,8 @@ + + @@ -35,10 +37,11 @@
-