From 6c9a4a3b8664eae3ac07578a4cf0979bbfd5f8be Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 10 Apr 2014 08:14:17 +0100 Subject: [PATCH] A start on video thumbnailing; see #400 Almost certainly not working yet; not tested, just committing so that other people have something to work with and we aren't duplicating effort --- ext/handle_video/main.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 9d34d436..a92418ff 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -18,7 +18,27 @@ class VideoFileHandler extends DataHandlerExtension { protected function create_thumb($hash) { - copy("ext/handle_video/thumb.jpg", warehouse_path("thumbs", $hash)); + global $config; + + $w = $config->get_int("thumb_width"); + $h = $config->get_int("thumb_height"); + $q = $config->get_int("thumb_quality"); + + $inname = warehouse_path("images", $hash); + $outname = warehouse_path("thumbs", $hash); + + switch($config->get_string("video_thumb_engine")) { + default: + case 'static': + copy("ext/handle_video/thumb.jpg", $outname); + break; + case 'ffmpeg': + $ffmpeg = $config->get_string("thumb_ffmpeg_path"); + $cmd = "$ffmpeg -i $inname -s {$w}x{$h} -ss 00:00:00.0 -f image2 -vframes 1 $outname" + exec($cmd, $output, $ret); + log_debug('handle_video', "Generating thumbnail with command `$cmd`, returns $ret"); + break; + } } protected function supported_ext($ext) {