#! /usr/bin/python from generic_renderer 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 CompressorRenderer(Renderer): renderer = 'Compressor' # Usage: Compressor [Cluster Info] [Batch Specific Info] [Optional Info] [Other Options] # # -computergroup -- name of the Computer Group to use. # --Batch Specific Info:-- # -batchname -- name to be given to the batch. # -priority -- 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 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 to settings file. # -locationpath -- path to location file. # -info -- xml for job info. # -jobaction -- xml for job action. # -scc -- url to scc file for source # -startoffset -- time offset from beginning # -in -- in time # -out -- out time # -annotations -- path to file to import annotations from; a plist file or a Quicktime movie # -chapters -- path to file to import chapters from # --Optional Info:-- # -help -- Displays, on stdout, this help information. # -checkstream -- url to source file to analyze # -findletterbox -- 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 -- unique id of the job usually obtained when job was submitted. # -batchid -- unique id of the batch usually obtained when job was submitted. # -query -- The value in seconds, specifies how often to query the cluster for job status. # -timeout -- 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 -- 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 -- Enables additional Compressor instances. # # -networkInterface -- Specify which network interface to use. If "all" is specified for , all available network interfaces are used. # # -portRange -- Defines what port range use, using start number specifying how many ports to use. # # --File Modification Options (all other parameters ignored):-- # -relabelaudiotracks -- url to source file. - Must be a QuickTime Movie file # --Optional Info:-- # -renametrackswithlayouts (Optional, rename the tracks with the new channel layouts) # -locationpath -- 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(CompressorRenderer, 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 = CompressorRenderer('/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)