Fix video thumbnail creation when delay > video length
This commit is contained in:
@@ -136,10 +136,21 @@ def generate_thumbnail(source, outname, box, delay, fit=True, options=None,
|
||||
|
||||
# dump an image of the video
|
||||
cmd = [converter, '-i', source, '-an', '-r', '1',
|
||||
'-ss', delay, '-vframes', '1', '-y', tmpfile]
|
||||
'-ss', str(delay), '-vframes', '1', '-y', tmpfile]
|
||||
logger.debug('Create thumbnail for video: %s', ' '.join(cmd))
|
||||
check_subprocess(cmd, source, outname)
|
||||
|
||||
# Sometimes ffmpeg fails with returncode zero but without producing an
|
||||
# output file Thus, we need to check if an output file was created. If
|
||||
# not, assume ffmpeg failed
|
||||
if not os.path.isfile(tmpfile):
|
||||
logger.debug('Thumbnail generation failed. Likely due to very short '
|
||||
'video length.')
|
||||
cmd = [converter, '-i', source, '-an', '-r', '1',
|
||||
'-ss', '0', '-vframes', '1', '-y', tmpfile]
|
||||
logger.debug('Retry to create thumbnail for video: %s', ' '.join(cmd))
|
||||
check_subprocess(cmd, source, outname)
|
||||
|
||||
# use the generate_thumbnail function from sigal.image
|
||||
image.generate_thumbnail(tmpfile, outname, box, fit=fit, options=options)
|
||||
# remove the image
|
||||
|
||||
@@ -3,6 +3,7 @@ title = 'Sigal test gallery ☺'
|
||||
source = 'pictures'
|
||||
thumb_suffix = '.tn'
|
||||
keep_orig = True
|
||||
thumb_video_delay = 5
|
||||
|
||||
links = [('Example link', 'http://example.org'),
|
||||
('Another link', 'http://example.org')]
|
||||
|
||||
Reference in New Issue
Block a user