From 273d386d228247cc5914151ec34c6f53b04f7c57 Mon Sep 17 00:00:00 2001 From: jgen Date: Fri, 18 Apr 2014 01:37:27 -0400 Subject: [PATCH 1/4] Working on thumbnail support for video files. --- ext/handle_video/main.php | 43 ++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index a92418ff..122e9930 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -17,26 +17,59 @@ */ class VideoFileHandler extends DataHandlerExtension { - protected function create_thumb($hash) { + public function onInitExt(InitExtEvent $event) { + global $config; + $config->set_default_string('video_thumb_engine', 'static'); + $config->set_default_string('thumb_ffmpeg_path', ''); + } + + public function onSetupBuilding(SetupBuildingEvent $event) { + global $config; + + $thumbers = array(); + $thumbers['None'] = "static"; + $thumbers['ffmpeg'] = "ffmpeg"; + + $sb = new SetupBlock("Video Thumbnail Options"); + + $sb->add_choice_option("video_thumb_engine", $thumbers, "Engine: "); + + if($config->get_string("video_thumb_engine") == "ffmpeg") { + $sb->add_label("
Path to ffmpeg: "); + $sb->add_text_option("thumb_ffmpeg_path"); + } + $event->panel->add_block($sb); + } + + protected function create_thumb($hash) { global $config; $w = $config->get_int("thumb_width"); $h = $config->get_int("thumb_height"); - $q = $config->get_int("thumb_quality"); + // this is never used... + //$q = $config->get_int("thumb_quality"); $inname = warehouse_path("images", $hash); $outname = warehouse_path("thumbs", $hash); - switch($config->get_string("video_thumb_engine")) { + 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" + + $inname = escapeshellarg($inname); + $outname = escapeshellarg($outname); + + $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; } } @@ -47,7 +80,7 @@ class VideoFileHandler extends DataHandlerExtension { } protected function create_image_from_data($filename, $metadata) { - global $config; + //global $config; $image = new Image(); From 2f380f5d591c10779e7ecd61ac698b84c1550df4 Mon Sep 17 00:00:00 2001 From: jgen Date: Fri, 18 Apr 2014 02:06:12 -0400 Subject: [PATCH 2/4] Video thumbs are working for webm files now. --- ext/handle_video/main.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 122e9930..7766a30b 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -2,6 +2,7 @@ /* * Name: Handle Video * Author: velocity37 + * Modified By: Shish , jgen * License: GPLv2 * Description: Handle FLV, MP4, OGV and WEBM video files. * Documentation: @@ -44,8 +45,8 @@ class VideoFileHandler extends DataHandlerExtension { protected function create_thumb($hash) { global $config; - $w = $config->get_int("thumb_width"); - $h = $config->get_int("thumb_height"); + $w = (int)$config->get_int("thumb_width"); + $h = (int)$config->get_int("thumb_height"); // this is never used... //$q = $config->get_int("thumb_quality"); @@ -65,11 +66,9 @@ class VideoFileHandler extends DataHandlerExtension { $outname = escapeshellarg($outname); $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; } } From b5d005710c6996701e97af1b1db6b10b5d4ea5f9 Mon Sep 17 00:00:00 2001 From: jgen Date: Fri, 18 Apr 2014 02:10:10 -0400 Subject: [PATCH 3/4] Fix indentation (spaces -> tabs) --- ext/handle_video/main.php | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 7766a30b..b8d28e38 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -18,43 +18,43 @@ */ class VideoFileHandler extends DataHandlerExtension { - public function onInitExt(InitExtEvent $event) { - global $config; - $config->set_default_string('video_thumb_engine', 'static'); - $config->set_default_string('thumb_ffmpeg_path', ''); - } + public function onInitExt(InitExtEvent $event) { + global $config; + $config->set_default_string('video_thumb_engine', 'static'); + $config->set_default_string('thumb_ffmpeg_path', ''); + } - public function onSetupBuilding(SetupBuildingEvent $event) { - global $config; + public function onSetupBuilding(SetupBuildingEvent $event) { + global $config; - $thumbers = array(); - $thumbers['None'] = "static"; - $thumbers['ffmpeg'] = "ffmpeg"; + $thumbers = array(); + $thumbers['None'] = "static"; + $thumbers['ffmpeg'] = "ffmpeg"; - $sb = new SetupBlock("Video Thumbnail Options"); + $sb = new SetupBlock("Video Thumbnail Options"); - $sb->add_choice_option("video_thumb_engine", $thumbers, "Engine: "); + $sb->add_choice_option("video_thumb_engine", $thumbers, "Engine: "); - if($config->get_string("video_thumb_engine") == "ffmpeg") { - $sb->add_label("
Path to ffmpeg: "); - $sb->add_text_option("thumb_ffmpeg_path"); - } - $event->panel->add_block($sb); - } + if($config->get_string("video_thumb_engine") == "ffmpeg") { + $sb->add_label("
Path to ffmpeg: "); + $sb->add_text_option("thumb_ffmpeg_path"); + } + $event->panel->add_block($sb); + } protected function create_thumb($hash) { global $config; $w = (int)$config->get_int("thumb_width"); $h = (int)$config->get_int("thumb_height"); - // this is never used... + // this is never used... //$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); @@ -62,8 +62,8 @@ class VideoFileHandler extends DataHandlerExtension { case 'ffmpeg': $ffmpeg = $config->get_string("thumb_ffmpeg_path"); - $inname = escapeshellarg($inname); - $outname = escapeshellarg($outname); + $inname = escapeshellarg($inname); + $outname = escapeshellarg($outname); $cmd = "{$ffmpeg} -i {$inname} -s {$w}x{$h} -ss 00:00:00.0 -f image2 -vframes 1 {$outname}"; exec($cmd, $output, $ret); From 7fd655fc4e5803bc322d6ac94b3cc4761faffe06 Mon Sep 17 00:00:00 2001 From: jgen Date: Fri, 18 Apr 2014 18:47:14 -0400 Subject: [PATCH 4/4] Added conditional message for IE users to download plugin from Google for webm. --- ext/handle_video/theme.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index 3e584ce3..1542cea1 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -27,7 +27,8 @@ else { "; } elseif ($ext == "webm") { - $html = "Video not playing? Click here to download the file.