Blender image sequences now generate a preview mp4 on completion

This commit is contained in:
Brett Williams
2023-05-30 21:59:04 -05:00
parent 22cfe9c24e
commit 60eeb6d5e2
9 changed files with 64 additions and 34 deletions

View File

@@ -34,7 +34,7 @@ def sorted_jobs(all_jobs, sort_by_date=True):
sorted_job_list = []
if all_jobs:
for status_category in categories:
found_jobs = [x for x in all_jobs if x.render_status() == status_category.value]
found_jobs = [x for x in all_jobs if x.status == status_category.value]
if found_jobs:
sorted_found_jobs = sorted(found_jobs, key=lambda d: d.date_created, reverse=True)
sorted_job_list.extend(sorted_found_jobs)
@@ -61,11 +61,11 @@ def job_detail(job_id):
table_html = json2html.json2html.convert(json=found_job.json(),
table_attributes='class="table is-narrow is-striped is-fullwidth"')
media_url = None
if found_job.file_list() and found_job.render_status() == RenderStatus.COMPLETED:
if found_job.file_list() and found_job.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,
hostname=RenderQueue.hostname, job_status=found_job.render_status().value.title(),
hostname=RenderQueue.hostname, job_status=found_job.status.value.title(),
job=found_job, renderer_info=renderer_info())
@@ -79,20 +79,20 @@ 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') and \
found_job.render_status() not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
found_job.status not in [RenderStatus.CANCELLED, RenderStatus.ERROR]:
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")
elif os.path.exists(thumb_image_path):
return send_file(thumb_image_path, mimetype='image/jpeg')
elif found_job.render_status() == RenderStatus.RUNNING:
elif found_job.status == RenderStatus.RUNNING:
return send_file('static/images/gears.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.CANCELLED:
elif found_job.status == RenderStatus.CANCELLED:
return send_file('static/images/cancelled.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.SCHEDULED:
elif found_job.status == RenderStatus.SCHEDULED:
return send_file('static/images/scheduled.png', mimetype="image/png")
elif found_job.render_status() == RenderStatus.NOT_STARTED:
elif found_job.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")
@@ -329,8 +329,13 @@ def add_job(job_params, remove_job_dir_on_failure=False):
if client == RenderQueue.hostname:
logger.info(f"Creating job locally - {name if name else input_path}")
try:
render_job = ScheduledJob(renderer, input_path, output_path, args, priority, job_owner, client,
notify=False, custom_id=custom_id, name=name)
render_job = RenderWorkerFactory.create_worker(renderer=renderer, input_path=input_path,
output_path=output_path, args=args)
render_job.client = client
render_job.owner = job_owner
render_job.name = name
render_job.priority = priority
RenderQueue.add_to_render_queue(render_job, force_start=force_start)
return render_job.json()
except Exception as e:

View File

@@ -17,7 +17,7 @@
<br>Time Elapsed: <span id="time-elapsed">{{job.worker_data()['time_elapsed']}}</span>
</span>
<script>
var startingStatus = '{{job.render_status().value}}';
var startingStatus = '{{job.status.value}}';
function update_job() {
$.getJSON('/api/job/{{job.id}}', function(data) {
document.getElementById('progress-bar').value = (data.percent_complete * 100);