class TranscodeJob: def __init__(self): self.l = MythLog('transcode.py', db=self.db()) def db(self): return MythDB() def log(self, message, level=LOGLEVEL.INFO, detail=None): return self.l.log(LOGMASK.GENERAL, level, message, detail) def logTB(self): return self.l.logTB(LOGMASK.GENERAL) def run(self, jobid=None, chanid=None, starttime=None): if jobid: job = Job(jobid, db=self.db()) chanid = job.chanid starttime = job.starttime rec = Recorded((chanid, starttime), db=self.db()) sg = mythproto.findfile(rec.basename, rec.storagegroup, db=self.db()) if sg is None: self.log('Local access to recording not found.', LOGLEVEL.ERR) sys.exit(1) infile = os.path.join(sg.dirname, rec.basename) #### list of segments to be cut # rec.markup.gencutlist() #### list of segments to keep # rec.markup.genuncutlist() del(rec) task = System(path=TRANSCODER, db=self.db()) try: outfile = task(infile).strip() if not os.path.exists(outfile): raise OSError('output file %s not found' % repr(outfile)) except MythError, e: self.log('Transcode failed with output:', LOGLEVEL.ERR, task.stderr) sys.exit(task.returncode) except OSError, e: self.log('Transcode failed to produce an output file:', LOGLEVEL.ERR, repr(e)) sys.exit(1)