mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Misc Cleanup
This commit is contained in:
@@ -54,7 +54,8 @@ def index():
|
||||
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_html = json2html.json2html.convert(json=found_job.json(),
|
||||
table_attributes='class="table is-narrow is-striped"')
|
||||
media_url = None
|
||||
if found_job.file_list():
|
||||
media_basename = os.path.basename(found_job.file_list()[0])
|
||||
@@ -230,11 +231,12 @@ def add_job_handler():
|
||||
elif request.form.get('json', None):
|
||||
jobs_list = json.loads(request.form['json'])
|
||||
else:
|
||||
form_dict = dict(request.form)
|
||||
# Cleanup flat form data into nested structure
|
||||
form_dict = {k: v for k, v in dict(request.form).items() if v}
|
||||
args = {}
|
||||
arg_keys = [k for k in form_dict.keys() if '-arg_' in k]
|
||||
for key in arg_keys:
|
||||
if form_dict['renderer'] in key:
|
||||
if form_dict['renderer'] in key or 'AnyRenderer' in key:
|
||||
cleaned_key = key.split('-arg_')[-1]
|
||||
args[cleaned_key] = form_dict[key]
|
||||
form_dict.pop(key)
|
||||
@@ -285,7 +287,6 @@ def add_job_handler():
|
||||
|
||||
|
||||
def add_job(job_params, remove_job_dir_on_failure=False):
|
||||
|
||||
def remove_job_dir():
|
||||
if remove_job_dir_on_failure and job_dir and os.path.exists(job_dir):
|
||||
logger.debug(f"Removing job dir: {job_dir}")
|
||||
@@ -298,7 +299,7 @@ def add_job(job_params, remove_job_dir_on_failure=False):
|
||||
output_path = job_params.get("output_path", None)
|
||||
priority = int(job_params.get('priority', 2))
|
||||
args = job_params.get('args', {})
|
||||
client = job_params.get('client', RenderQueue.host_name)
|
||||
client = job_params.get('client', None) or RenderQueue.host_name
|
||||
force_start = job_params.get('force_start', False)
|
||||
custom_id = None
|
||||
job_dir = None
|
||||
@@ -448,4 +449,3 @@ def renderer_info():
|
||||
def upload_file_page():
|
||||
return render_template('upload.html', render_clients=RenderQueue.render_clients,
|
||||
supported_renderers=RenderWorkerFactory.supported_renderers())
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ class RenderJob:
|
||||
|
||||
def json(self):
|
||||
"""Converts RenderJob into JSON-friendly dict"""
|
||||
import numbers
|
||||
job_dict = None
|
||||
try:
|
||||
job_dict = self.__dict__.copy()
|
||||
@@ -91,6 +90,9 @@ class RenderJob:
|
||||
def frame_count(self):
|
||||
return self.worker.total_frames
|
||||
|
||||
def work_path(self):
|
||||
return os.path.dirname(self.worker.output_path)
|
||||
|
||||
def file_list(self):
|
||||
job_dir = os.path.dirname(self.worker.output_path)
|
||||
return glob.glob(os.path.join(job_dir, '*'))
|
||||
|
||||
@@ -39,8 +39,6 @@ class RenderQueue:
|
||||
cls.job_queue.append(render_job)
|
||||
if force_start:
|
||||
cls.start_job(render_job)
|
||||
else:
|
||||
cls.evaluate_queue()
|
||||
else:
|
||||
# todo: implement client rendering
|
||||
logger.warning('remote client rendering not implemented yet')
|
||||
@@ -88,7 +86,7 @@ class RenderQueue:
|
||||
cls.render_clients = saved_state.get('clients', {})
|
||||
|
||||
for job in saved_state.get('jobs', []):
|
||||
|
||||
try:
|
||||
render_job = RenderJob(renderer=job['renderer'], input_path=job['worker']['input_path'],
|
||||
output_path=job['worker']['output_path'], args=job['worker']['args'],
|
||||
priority=job['priority'], client=job['client'])
|
||||
@@ -117,6 +115,8 @@ class RenderQueue:
|
||||
|
||||
# finally add back to render queue
|
||||
cls.job_queue.append(render_job)
|
||||
except Exception as e:
|
||||
logger.error(f"Unable to load job: {job} - {e}")
|
||||
|
||||
cls.last_saved_counts = cls.job_counts()
|
||||
|
||||
|
||||
@@ -247,13 +247,22 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Checkboxes -->
|
||||
<!-- <div class="field">-->
|
||||
<!-- <div class="control">-->
|
||||
<!-- <label class="checkbox"><input type="checkbox" name="blender-arg_render_all_frames"> Render All Frames</label>-->
|
||||
<!-- <label class="checkbox"><input type="checkbox" name="blender-arg_multiple_cameras"> Multiple Cameras</label>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- Resolution -->
|
||||
<!-- <label class="label">Resolution</label>-->
|
||||
<!-- <div class="field is-grouped">-->
|
||||
<!-- <p class="control">-->
|
||||
<!-- <input class="input" type="text" placeholder="auto" maxlength="5" size="8" name="AnyRenderer-arg_x_resolution">-->
|
||||
<!-- </p>-->
|
||||
<!-- <label class="label"> x </label>-->
|
||||
<!-- <p class="control">-->
|
||||
<!-- <input class="input" type="text" placeholder="auto" maxlength="5" size="8" name="AnyRenderer-arg_y_resolution">-->
|
||||
<!-- </p>-->
|
||||
<!-- <label class="label"> @ </label>-->
|
||||
<!-- <p class="control">-->
|
||||
<!-- <input class="input" type="text" placeholder="auto" maxlength="3" size="5" name="AnyRenderer-arg_frame_rate">-->
|
||||
<!-- </p>-->
|
||||
<!-- <label class="label"> fps </label>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<label class="label">Command Line Arguments</label>
|
||||
<div class="field has-addons">
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#! /usr/bin/python
|
||||
from render_worker import *
|
||||
import glob
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
# Documentation
|
||||
# https://help.apple.com/compressor/mac/4.0/en/compressor/usermanual/Compressor%204%20User%20Manual%20(en).pdf
|
||||
|
||||
def compressor_path():
|
||||
return '/Applications/Compressor.app/Contents/MacOS/Compressor'
|
||||
|
||||
|
||||
class CompressorRenderWorker(RenderWorker):
|
||||
|
||||
renderer = 'Compressor'
|
||||
|
||||
# Usage: Compressor [Cluster Info] [Batch Specific Info] [Optional Info] [Other Options]
|
||||
#
|
||||
# -computergroup <name> -- name of the Computer Group to use.
|
||||
# --Batch Specific Info:--
|
||||
# -batchname <name> -- name to be given to the batch.
|
||||
# -priority <value> -- priority to be given to the batch. Possible values are: low, medium or high
|
||||
# Job Info: Used when submitting individual source files. Following parameters are repeated to enter multiple job targets in a batch
|
||||
# -jobpath <url> -- url to source file.
|
||||
# -- In case of Image Sequence, URL should be a file URL pointing to directory with image sequence.
|
||||
# -- Additional URL query style parameters may be specified to set frameRate (file:///myImageSequenceDir?frameRate=29.97) and audio file (e.g. file:///myImageSequenceDir?audio=/usr/me/myaudiofile.mov).
|
||||
# -settingpath <path> -- path to settings file.
|
||||
# -locationpath <path> -- path to location file.
|
||||
# -info <xml> -- xml for job info.
|
||||
# -jobaction <xml> -- xml for job action.
|
||||
# -scc <url> -- url to scc file for source
|
||||
# -startoffset <hh:mm:ss;ff> -- time offset from beginning
|
||||
# -in <hh:mm:ss;ff> -- in time
|
||||
# -out <hh:mm:ss;ff> -- out time
|
||||
# -annotations <path> -- path to file to import annotations from; a plist file or a Quicktime movie
|
||||
# -chapters <path> -- path to file to import chapters from
|
||||
# --Optional Info:--
|
||||
# -help -- Displays, on stdout, this help information.
|
||||
# -checkstream <url> -- url to source file to analyze
|
||||
# -findletterbox <url> -- url to source file to analyze
|
||||
#
|
||||
# --Batch Monitoring Info:--
|
||||
# Actions on Job:
|
||||
# -monitor -- monitor the job or batch specified by jobid or batchid.
|
||||
# -kill -- kill the job or batch specified by jobid or batchid.
|
||||
# -pause -- pause the job or batch specified by jobid or batchid.
|
||||
# -resume -- resume previously paused job or batch specified by jobid or batchid.
|
||||
# Optional Info:
|
||||
# -jobid <id> -- unique id of the job usually obtained when job was submitted.
|
||||
# -batchid <id> -- unique id of the batch usually obtained when job was submitted.
|
||||
# -query <seconds> -- The value in seconds, specifies how often to query the cluster for job status.
|
||||
# -timeout <seconds> -- the timeOut value, in seconds, specifies when to quit the process.
|
||||
# -once -- show job status only once and quit the process.
|
||||
#
|
||||
# --Sharing Related Options:--
|
||||
# -resetBackgroundProcessing [cancelJobs] -- Restart all processes used in background processing, and optionally cancel all queued jobs.
|
||||
#
|
||||
# -repairCompressor -- Repair Compressor config files and restart all processes used in background processing.
|
||||
#
|
||||
# -sharing <on/off> -- Turn sharing of this computer on or off.
|
||||
#
|
||||
# -requiresPassword [password] -- Sharing of this computer requires specified password. Computer must not be busy processing jobs when you set the password.
|
||||
#
|
||||
# -noPassword -- Turn off the password requirement for sharing this computer.
|
||||
#
|
||||
# -instances <number> -- Enables additional Compressor instances.
|
||||
#
|
||||
# -networkInterface <bsdname> -- Specify which network interface to use. If "all" is specified for <bsdname>, all available network interfaces are used.
|
||||
#
|
||||
# -portRange <startNumber> <count> -- Defines what port range use, using start number specifying how many ports to use.
|
||||
#
|
||||
# --File Modification Options (all other parameters ignored):--
|
||||
# -relabelaudiotracks <layout[1] layout[2]... layout[N]
|
||||
# Supported values:
|
||||
# Ls : Left Surround
|
||||
# R : Right
|
||||
# C : Center
|
||||
# Rs : Right Surround
|
||||
# Lt : Left Total
|
||||
# L : Left
|
||||
# Rt : Right Total
|
||||
# LFE : LFE Screen
|
||||
# Lc : Left Center
|
||||
# Rls : Rear Surround Left
|
||||
# mono : Mono
|
||||
# LtRt : Matrix Stereo (Lt Rt)
|
||||
# Rc : Right Center
|
||||
# stereo : Stereo (L R)
|
||||
# Rrs : Rear Surround Right
|
||||
# -jobpath <url> -- url to source file. - Must be a QuickTime Movie file
|
||||
# --Optional Info:--
|
||||
# -renametrackswithlayouts (Optional, rename the tracks with the new channel layouts)
|
||||
# -locationpath <path> -- path to location file. Modified movie will be saved here. If unspecified, changes will be saved in place, overwriting the original file.
|
||||
|
||||
def __init__(self, project, settings_path, output):
|
||||
super(CompressorRenderWorker, self).__init__(project=project, output=output)
|
||||
self.settings_path = settings_path
|
||||
|
||||
self.batch_name = os.path.basename(project)
|
||||
self.cluster_name = 'This Computer'
|
||||
|
||||
self.timeout = 5
|
||||
|
||||
# /Applications/Compressor.app/Contents/MacOS/Compressor -clusterid "tcp://192.168.1.148:62995" -batchname "My First Batch" -jobpath ~/Movies/MySource.mov -settingpath ~/Library/Application\ Support/Compressor/Settings/MPEG-4.setting -destinationpath ~/Movies/MyOutput.mp4 -timeout 5
|
||||
|
||||
def _generate_subprocess(self):
|
||||
x = [compressor_path(), '-batchname', datetime.now().isoformat(), '-jobpath', self.input, '-settingpath', self.settings_path, '-locationpath', self.output]
|
||||
print(' '.join(x))
|
||||
return x
|
||||
|
||||
def _parse_stdout(self, line):
|
||||
print(line)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.DEBUG)
|
||||
r = CompressorRenderWorker('/Users/brett/Desktop/drone_raw.mp4', '/Applications/Compressor.app/Contents/Resources/Settings/Website Sharing/HD720WebShareName.compressorsetting', '/Users/brett/Desktop/test_drone_output.mp4')
|
||||
r.start()
|
||||
while r.is_running():
|
||||
time.sleep(1)
|
||||
@@ -42,14 +42,17 @@ class FFMPEGRenderWorker(BaseRenderWorker):
|
||||
def _generate_subprocess(self):
|
||||
|
||||
cmd = [self.renderer_path(), '-y', '-stats', '-i', self.input_path]
|
||||
if self.args:
|
||||
cmd.extend([x for x in self.args if x != 'raw'])
|
||||
|
||||
# Resize frame
|
||||
if self.args.get('x_resolution', None) and self.args.get('y_resolution', None):
|
||||
cmd.extend(['-vf', f"scale={self.args['x_resolution']}:{self.args['y_resolution']}"])
|
||||
|
||||
# Convert raw args from string if available
|
||||
raw_args = self.args.get('raw', None)
|
||||
print(raw_args)
|
||||
if raw_args:
|
||||
cmd.extend(raw_args.split(' '))
|
||||
|
||||
# Close with output path
|
||||
cmd.append(self.output_path)
|
||||
return cmd
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class BaseRenderWorker(object):
|
||||
|
||||
renderer = 'BaseRenderWorker'
|
||||
render_engine = None
|
||||
render_engine_version = None
|
||||
supported_extensions = []
|
||||
install_paths = []
|
||||
supported_export_formats = []
|
||||
|
||||
Reference in New Issue
Block a user