From 951323abcf125ff938c9eb179950a5b0509a3cf0 Mon Sep 17 00:00:00 2001 From: Daku Date: Sat, 14 May 2016 23:39:45 +0100 Subject: [PATCH] default handle_video thumbgen to ffmpeg if ffmpeg in path & is_executable --- ext/handle_video/main.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 21585748..e2567412 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -19,23 +19,38 @@ 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', ''); - // By default we generate thumbnails ignoring the aspect ratio of the video file. - // - // Why? - This allows Shimmie to work with older versions of FFmpeg by default, - // rather than completely failing out of the box. If people complain that their - // thumbnails are distorted, then they can turn this feature on manually later. - $config->set_default_bool('video_thumb_ignore_aspect_ratio', true); + if($config->get_int("ext_handle_video_version") < 1) { + if($ffmpeg = shell_exec((PHP_OS == 'WINNT' ? 'where' : 'which') . ' ffmpeg')) { + //ffmpeg exists in PATH, check if it's executable, and if so, default to it instead of static + if(is_executable(strtok($ffmpeg, PHP_EOL))) { + $config->set_default_string('video_thumb_engine', 'ffmpeg'); + $config->set_default_string('thumb_ffmpeg_path', 'ffmpeg'); + } + } else { + $config->set_default_string('video_thumb_engine', 'static'); + $config->set_default_string('thumb_ffmpeg_path', ''); + } + + // By default we generate thumbnails ignoring the aspect ratio of the video file. + // + // Why? - This allows Shimmie to work with older versions of FFmpeg by default, + // rather than completely failing out of the box. If people complain that their + // thumbnails are distorted, then they can turn this feature on manually later. + $config->set_default_bool('video_thumb_ignore_aspect_ratio', TRUE); + + $config->set_int("ext_handle_video_version", 1); + log_info("pools", "extension installed"); + } } public function onSetupBuilding(SetupBuildingEvent $event) { //global $config; - - $thumbers = array(); - $thumbers['None'] = "static"; - $thumbers['ffmpeg'] = "ffmpeg"; + + $thumbers = array( + 'None' => 'static', + 'ffmpeg' => 'ffmpeg' + ); $sb = new SetupBlock("Video Thumbnail Options");