diff options
author | Andy Staudacher <andy.st@gmail.com> | 2010-02-06 20:07:58 -0800 |
---|---|---|
committer | Andy Staudacher <andy.st@gmail.com> | 2010-02-06 20:07:58 -0800 |
commit | 2c3c126aafaa4d7ed86075927887636042117a1c (patch) | |
tree | 83af1ca12f75a4b108546526524811d145109ba6 /modules/gallery | |
parent | a6170dc065856c6c4b6f69a4571fe19dee87d0ee (diff) |
Fix ticket 930: Use the first frame as video thumbnail if the video is shorter than 3 seconds. And fall back to the default thumbnail if that operation fails.
Thanks to lsowen for providing a patch!
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/helpers/movie.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 7033b7da..3c494e96 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -84,6 +84,20 @@ class movie_Core { " -an -ss 00:00:03 -an -r 1 -vframes 1" . " -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1"; exec($cmd); + + clearstatcache(); // use $filename parameter when PHP_version is 5.3+ + if (filesize($output_file) == 0) { + // Maybe the movie is shorter, fall back to the first frame. + $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($input_file) . + " -an -an -r 1 -vframes 1" . + " -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1"; + exec($cmd); + + clearstatcache(); + if (filesize($output_file) == 0) { + throw new Exception("@todo FFMPEG_FAILED"); + } + } } static function find_ffmpeg() { |