summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/graphics.php
diff options
context:
space:
mode:
authorshadlaws <shad@shadlaws.com>2012-12-18 15:58:13 +0100
committershadlaws <shad@shadlaws.com>2012-12-18 15:58:13 +0100
commitce68177ba0dc27010435e55b79cbea453751f8ee (patch)
tree90abf82dfadf5bf4c79233798efca1aaafb51963 /modules/gallery/helpers/graphics.php
parentf2a32526be0a307005052105ed09bc337e29d333 (diff)
[#1928 - Make thumbnail generation more flexible for movies (graphics and movie helpers)]
- graphics helper: add movie_extract_frame event to generate function (allows modules to add to the options sent to movie::extract_frame or to generate the thumbnail on their own without movie::extract_frame) - movie helper: add extra optional argument to movie::extract_frame (can add ffmpeg arguments and/or change the frame extract time) - gallery_installer: add movie_extract_time module variable, update to v53 - module.info: update to v53 - install.sql: update to v53
Diffstat (limited to 'modules/gallery/helpers/graphics.php')
-rw-r--r--modules/gallery/helpers/graphics.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index c19fbe6d..c7f87403 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -155,13 +155,27 @@ class graphics_Core {
try {
foreach ($ops as $target => $output_file) {
if ($input_item->is_movie()) {
- // Convert the movie to a JPG first
+ // Convert the movie filename to a JPG first, delete anything that might already be there
$output_file = legal_file::change_extension($output_file, "jpg");
- try {
- movie::extract_frame($input_file, $output_file);
- } catch (Exception $e) {
- // Assuming this is MISSING_FFMPEG for now
- copy(MODPATH . "gallery/images/missing_movie.jpg", $output_file);
+ unlink($output_file);
+ // Run movie_extract_frame events, which can either:
+ // - generate an output file, bypassing the ffmpeg-based movie::extract_frame
+ // - add to the options sent to movie::extract_frame (e.g. change frame extract time,
+ // add de-interlacing arguments to ffmpeg... see movie helper for more info)
+ // Note that the args are similar to those of the events in gallery_graphics
+ $movie_options_wrapper = new stdClass();
+ $movie_options_wrapper->movie_options = array();
+ module::event("movie_extract_frame", $input_file, $output_file,
+ $movie_options_wrapper, $input_item);
+ // If no output_file generated by events, run movie::extract_frame with movie_options
+ clearstatcache();
+ if (@filesize($output_file) == 0) {
+ try {
+ movie::extract_frame($input_file, $output_file, $movie_options_wrapper->movie_options);
+ } catch (Exception $e) {
+ // Didn't work, likely because of MISSING_FFMPEG - copy missing_movie instead
+ copy(MODPATH . "gallery/images/missing_movie.jpg", $output_file);
+ }
}
$working_file = $output_file;
} else {