Adds a thumb_video_delay parameter for the creation of thumbnails with fade-in videos
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
# -------------
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user