summaryrefslogtreecommitdiffstats
path: root/lib/preview/movies.php
diff options
context:
space:
mode:
authorGeorg Ehrke <georg@ownCloud.com>2013-04-25 12:51:44 +0200
committerGeorg Ehrke <georg@ownCloud.com>2013-04-25 12:51:44 +0200
commit8c1925425b26d9b2889632c724ec455ceeed4dd4 (patch)
tree5755e4c45caee37bc06360dd769ae8a7933f2551 /lib/preview/movies.php
parentf02aca3f6ee295485d5bb9bc99b85b5573716f17 (diff)
downloadnextcloud-server-8c1925425b26d9b2889632c724ec455ceeed4dd4.tar.gz
nextcloud-server-8c1925425b26d9b2889632c724ec455ceeed4dd4.zip
save current work state
Diffstat (limited to 'lib/preview/movies.php')
-rw-r--r--lib/preview/movies.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/preview/movies.php b/lib/preview/movies.php
new file mode 100644
index 00000000000..afa27c0b143
--- /dev/null
+++ b/lib/preview/movies.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
+ * Copyrigjt (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+if(!is_null(shell_exec('ffmpeg'))){
+
+ class OC_Preview_Movie extends OC_Preview_Provider{
+
+ public function getMimeType(){
+ return '/video\/.*/';
+ }
+
+ public static function getThumbnail($path,$maxX,$maxY,$scalingup) {
+ $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);
+ }
+
+ }
+
+ OC_Preview::registerProvider('OC_Preview_Movie');
+} \ No newline at end of file