diff options
author | Georg Ehrke <georg@ownCloud.com> | 2013-05-17 15:06:37 +0200 |
---|---|---|
committer | Georg Ehrke <georg@ownCloud.com> | 2013-05-17 15:06:37 +0200 |
commit | d42aa6553286c6f7f2de1156da2a1f490479277e (patch) | |
tree | 037dd7c7d2233ed69b4b2b4dce3f49ff0bd6b883 /lib/preview | |
parent | 8b39a085121fae7823046f209eecc3484cf5c936 (diff) | |
download | nextcloud-server-d42aa6553286c6f7f2de1156da2a1f490479277e.tar.gz nextcloud-server-d42aa6553286c6f7f2de1156da2a1f490479277e.zip |
implement movie previews
Diffstat (limited to 'lib/preview')
-rw-r--r-- | lib/preview/movies.php | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 1f0ceb3ace3..868755a1205 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -7,7 +7,6 @@ * See the COPYING-README file. */ if(!is_null(shell_exec('ffmpeg -version'))){ - class OC_Preview_Movie extends OC_Preview_Provider{ public function getMimeType(){ @@ -15,28 +14,18 @@ if(!is_null(shell_exec('ffmpeg -version'))){ } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - - // is a preview already in the cache? - if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { - return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); - } - - // does the sourcefile exist? - if (!\OC_Filesystem::file_exists($path)) { - \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); - return false; - } - - // call ffmpeg to do the screenshot - shell_exec('ffmpeg -y -i {'.escapeshellarg($path).'} -f mjpeg -vframes 1 -ss 1 -s {'.escapeshellarg($maxX).'}x{'.escapeshellarg($maxY).'} {.'.$thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup).'}'); - - // output the generated Preview - $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); - unset($thumbnails_view); + $abspath = $fileview->getLocalfile($path); + + $tmppath = OC_Helper::tmpFile(); + + $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; + shell_exec($cmd); + + $image = new \OC_Image($tmppath); + if (!$image->valid()) return false; + + return $image; } - } - OC_Preview::registerProvider('OC_Preview_Movie'); }
\ No newline at end of file |