diff --git a/sigal/settings.py b/sigal/settings.py index 2272743..f47cf8b 100644 --- a/sigal/settings.py +++ b/sigal/settings.py @@ -62,6 +62,7 @@ _DEFAULT_CONFIG = { 'thumb_prefix': '', 'thumb_size': (200, 150), 'thumb_suffix': '', + 'thumb_video_delay': '0', 'title': '', 'use_orig': False, 'video_size': (480, 360), diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index 5188ed7..752e5b1 100644 --- a/sigal/templates/sigal.conf.py +++ b/sigal/templates/sigal.conf.py @@ -80,6 +80,9 @@ thumb_size = (280, 210) # Crop the image to fill the box # thumb_fit = True +# Delay in seconds to avoid black thumbnails in videos with fade-in +# thumb_video_delay = '0' + # ------------- # Album options # ------------- diff --git a/sigal/video.py b/sigal/video.py index e19f7ec..8d827eb 100644 --- a/sigal/video.py +++ b/sigal/video.py @@ -123,7 +123,7 @@ def generate_video(source, outname, size, options=None): check_subprocess(cmd, source, outname) -def generate_thumbnail(source, outname, box, fit=True, options=None): +def generate_thumbnail(source, outname, box, delay, fit=True, options=None): """Create a thumbnail image for the video source, based on ffmpeg.""" logger = logging.getLogger(__name__) @@ -131,7 +131,7 @@ def generate_thumbnail(source, outname, box, fit=True, options=None): # dump an image of the video cmd = ['ffmpeg', '-i', source, '-an', '-r', '1', - '-ss', '2', '-vframes', '1', '-y', tmpfile] + '-ss', delay, '-vframes', '1', '-y', tmpfile] logger.debug('Create thumbnail for video: %s', ' '.join(cmd)) try: @@ -162,7 +162,7 @@ def process_video(filepath, outpath, settings): thumb_name = os.path.join(outpath, get_thumb(settings, filename)) try: generate_thumbnail( - outname, thumb_name, settings['thumb_size'], + outname, thumb_name, settings['thumb_size'], settings['thumb_video_delay'], fit=settings['thumb_fit'], options=settings['jpg_options']) except Exception: return Status.FAILURE