mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
121 lines
6.0 KiB
Python
121 lines
6.0 KiB
Python
#! /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) |