def framerate_init(): '''Set the initial framerate with the values set on the shot''' import ftrack shotId = os.getenv('FTRACK_SHOTID') shot = ftrack.Shot(id=shotId) try: fps = str(int(shot.get('fps'))) except: show = shot.getProject() fps = str(int(show.get('fps'))) mapping = { '15': 'game', '24': 'film', '25': 'pal', '30': 'ntsc', '48': 'show', '50': 'palf', '60': 'ntscf', } fpsType = mapping.get(fps, 'pal') cmds.warning('Setting current unit to {0}'.format(fps)) cmds.currentUnit(time=fpsType)
def getInputFilePath(shotid): baseDir = '/data/production/' shot = ftrack.Shot(id=shotid) shotName = '%s_%s' % (shot.getSequence().getName(), shot.getName()) hierarchy = reversed(shot.getParents()) imgDir = baseDir for p in hierarchy: if isinstance(p, ftrack.Project): pname = p.getName() if pname == 'willowstr': pname = 'ds_willowStreet' imgDir = os.path.join(imgDir, pname) imgDir = os.path.join(imgDir, 'shots') else: imgDir = os.path.join(imgDir, p.getName()) baseDir = os.path.join(imgDir, shotName) inputFile = '' imgDir = os.path.join(baseDir, 'img/comp') if os.path.exists(imgDir): verDirs = [ d for d in os.listdir(imgDir) if os.path.isdir(os.path.join(imgDir, d)) ] if verDirs: imgDir = os.path.join(imgDir, verDirs[-1]) files = [ f for f in os.listdir(imgDir) if os.path.isfile(os.path.join(imgDir, f)) ] if files: inputFile = files[0] return imgDir, inputFile
def setFrameRangeData(): start_frame = float(os.getenv('FS')) end_frame = float(os.getenv('FE')) shot_id = os.getenv('FTRACK_SHOTID') shot = ftrack.Shot(id=shot_id) fps = shot.get('fps') if 'handles' in shot.keys(): handles = float(shot.get('handles')) else: handles = 0.0 print 'setting timeline to %s %s ' % (start_frame, end_frame) # add handles to start and end frame hsf = (start_frame - 1) - handles hef = end_frame + handles hou.setFps(fps) hou.setFrame(start_frame) try: if start_frame != end_frame: hou.hscript("tset {0} {1}".format((hsf) / fps, hef / fps)) hou.playbar.setPlaybackRange(start_frame, end_frame) except IndexError: pass
def framerange_init(): import ftrack shotId = os.getenv('FTRACK_SHOTID') shot = ftrack.Shot(id=shotId) try: sf = int(shot.getFrameStart()) ef = int(shot.getFrameEnd()) cmds.playbackOptions(ast=sf, aet=ef, min=sf, max=ef) except: print 'only supported on shots'
def process(self, instance): import ftrack item = instance[0] # Get/Create shot shot = None for tag in item.tags(): if tag.name() == "ftrack": metadata = tag.metadata() if 'tag.id' in metadata: shot = ftrack.Shot(metadata["tag.id"]) else: shot = self.get_or_create_shot(instance) instance.data["ftrackShotId"] = shot.getId() instance.data["ftrackShot"] = shot # Store shot id on tag for tag in item.tags(): if tag.name() == "ftrack": tag.metadata().setValue("tag.id", shot.getId()) # Assign attributes to shot. sequence = item.parent().parent() shot.set("fstart", value=1) shot.set("fps", value=sequence.framerate().toFloat()) duration = item.sourceOut() - item.sourceIn() duration = abs(int(round((abs(duration) + 1) / item.playbackSpeed()))) shot.set("fend", value=duration) try: fmt = sequence.format() shot.set("width", value=fmt.width()) shot.set("height", value=fmt.height()) except Exception as e: self.log.warning("Could not set the resolution: " + str(e)) # Get handles. handles = 0 if "handles" in instance.data["families"]: for tag in instance.data["tagsData"]: if "handles" == tag.get("tag.family", ""): handles = int(tag["tag.value"]) instance.data["handles"] = handles shot.set("handles", value=handles)
def getOutputFilePath(shotid, taskid, inBaseDir): baseDir = '/data/production/' shot = ftrack.Shot(id=shotid) pname = shot.getProject().getName() if pname == 'willowstr': pname = 'ds_willowStreet' baseDir = os.path.join(baseDir, pname) today = datetime.today() day = str(today.day) if len(day) == 1: day = '0%s' % day datefolder = '%s-%s-%s' % (today.year, today.month, day) baseDir = os.path.join(baseDir, 'production/approvals') baseDir = os.path.join(baseDir, datefolder) if not os.path.exists(baseDir): os.mkdir(baseDir) sq = shot.getSequence().getName() task = ftrack.Task(taskid).getName() ver = inBaseDir.split('/')[-1] filename = '%s_%s_%s_%s.mov' % (sq, shot.getName(), task, ver) outputFile = os.path.join(baseDir, filename) outputFile = outputFile.replace(' ', '_') return outputFile