Improvements to thumbnail generation and detail page

This commit is contained in:
Brett Williams
2022-12-12 21:45:46 -08:00
parent 9ac22a5555
commit 9a9b0304b9
11 changed files with 51 additions and 14 deletions

View File

@@ -55,12 +55,13 @@ def job_detail(job_id):
found_job = RenderQueue.job_with_id(job_id)
if found_job:
table_html = json2html.json2html.convert(json=found_job.json(),
table_attributes='class="table is-narrow is-striped"')
table_attributes='class="table is-narrow is-striped is-fullwidth"')
media_url = None
if found_job.file_list():
if found_job.file_list() and found_job.render_status() == RenderStatus.COMPLETED:
media_basename = os.path.basename(found_job.file_list()[0])
media_url = f"/api/job/{job_id}/file/{media_basename}"
return render_template('details.html', detail_table=table_html, media_url=media_url)
return render_template('details.html', detail_table=table_html, media_url=media_url,
job_status=found_job.render_status().value.title(), job=found_job)
return f'Cannot find job with ID {job_id}', 400
@@ -74,7 +75,7 @@ def job_thumbnail(job_id):
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'):
generate_thumbnail_for_job(found_job, thumb_video_path, thumb_image_path, max_width=120)
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'):
return send_file(thumb_video_path, mimetype="video/mp4")

View File

@@ -4,7 +4,7 @@ import os
import json
import threading
from utilities.render_worker import RenderStatus
from utilities.ffmpeg_presets import generate_fast_preview, save_first_frame
from utilities.ffmpeg_presets import generate_thumbnail, save_first_frame
def post_job_to_server(input_path, job_list, client, server_port=8080):
@@ -22,7 +22,7 @@ def generate_thumbnail_for_job(job, thumb_video_path, thumb_image_path, max_widt
def generate_thumb_thread(source):
in_progress_path = thumb_video_path + '_IN-PROGRESS'
subprocess.run(['touch', in_progress_path])
generate_fast_preview(source_path=source, dest_path=thumb_video_path, max_width=max_width)
generate_thumbnail(source_path=source, dest_path=thumb_video_path, max_width=max_width)
os.remove(in_progress_path)
# Determine best source file to use for thumbs

BIN
lib/static/cancelled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
lib/static/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

BIN
lib/static/gears.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
lib/static/not_started.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
lib/static/scheduled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 66 KiB