More thumbnail fixes

This commit is contained in:
Brett Williams
2023-05-30 21:05:59 -05:00
parent 769611ba26
commit 22cfe9c24e
3 changed files with 13 additions and 6 deletions

View File

@@ -129,9 +129,9 @@ class BlenderRenderWorker(BaseRenderWorker):
image_sequence_to_video(source_glob_pattern=glob_pattern, image_sequence_to_video(source_glob_pattern=glob_pattern,
output_path=self.output_path + '.mp4', output_path=self.output_path + '.mp4',
framerate=self.scene_info['fps']) framerate=self.scene_info['fps'])
logger.info('Successfully generated preview image sequence') logger.info('Successfully generated preview video from image sequence')
except Exception as e: except Exception as e:
logger.error('Error generating image sequence') logger.error(f'Error generating video from image sequence: {e}')
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -78,14 +78,23 @@ def job_thumbnail(job_id):
thumb_video_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.mp4') thumb_video_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.mp4')
thumb_image_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.jpg') thumb_image_path = os.path.join(server.config['THUMBS_FOLDER'], found_job.id + '.jpg')
if not os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'): if not os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS') and \
found_job.render_status() not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
generate_thumbnail_for_job(found_job, thumb_video_path, thumb_image_path, max_width=240) generate_thumbnail_for_job(found_job, thumb_video_path, thumb_image_path, max_width=240)
if os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'): if os.path.exists(thumb_video_path) and not os.path.exists(thumb_video_path + '_IN-PROGRESS'):
return send_file(thumb_video_path, mimetype="video/mp4") return send_file(thumb_video_path, mimetype="video/mp4")
elif os.path.exists(thumb_image_path): elif os.path.exists(thumb_image_path):
return send_file(thumb_image_path, mimetype='image/jpeg') return send_file(thumb_image_path, mimetype='image/jpeg')
return send_file('static/images/spinner.gif', mimetype="image/gif") elif found_job.render_status() == RenderStatus.RUNNING:
return send_file('static/images/gears.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.CANCELLED:
return send_file('static/images/cancelled.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.SCHEDULED:
return send_file('static/images/scheduled.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.NOT_STARTED:
return send_file('static/images/not_started.png', mimetype="image/png")
return send_file('static/images/error.png', mimetype="image/png")
# Get job file routing # Get job file routing

View File

@@ -38,8 +38,6 @@ def generate_thumbnail_for_job(job, thumb_video_path, thumb_image_path, max_widt
# Determine best source file to use for thumbs # Determine best source file to use for thumbs
if job.render_status() == RenderStatus.COMPLETED: # use finished file for thumb if job.render_status() == RenderStatus.COMPLETED: # use finished file for thumb
source_path = job.file_list() source_path = job.file_list()
elif len(job.file_list()) > 1: # if image sequence, use second to last file (last may be in use)
source_path = [job.file_list()[-2]]
else: else:
source_path = [job.input_path] # use source if nothing else source_path = [job.input_path] # use source if nothing else