def setSlugLabel(self, session, filename): ''' Sets the slug label based on input file name. :param filename: Name of the input file ''' inputFolder = os.path.dirname(str(filename)) imageExt = str(filename).split('.')[-1] if inputFolder: if os.environ.has_key('FTRACK_SHOTID'): project = ftrackUtils.getProjectFromShot(session, os.environ['FTRACK_SHOTID']) else: project = utils.getProjectName(inputFolder) if imageExt.lower() == 'avi' or imageExt.lower() == 'mov': inputFolder = '%s/tiffSeq' % os.environ['TEMP'] result = utils.extractTiffToTmp(filename, inputFolder) if result != 0: QtGui.QMessageBox.warning(self, "Error", "Error while extracting images from input file!") shotName = filename.split('/')[-1].split('.')[0] from datetime import datetime d = datetime.now() date = '%s/%s/%s' % (d.day, d.month, d.year) else: shotName, firstFrame,lastFrame, date, firstFrameStr = utils.getShotInfo(str(inputFolder), str(imageExt)) label = '%s %s %s Frame#' % (project, date, shotName) else: label = 'Customize Slug Label' self.slugTextBox.setText(label)
def createMovie(self): frameRate = self.frameDrop.currentText() self.movieWidget.setFrameRate(frameRate) self.pBar.setVisible(True) self.pLabel.setVisible(True) self.pBar.setValue(0) self.pBar.setMinimum(0) self.pBar.setMaximum(100) self.createButton.setDisabled(True) inputFile = self.inputWidget.getFilePath() outputFile = str(self.outputWidget.getFilePath()) slugChoice = self.slugBox.checkState() if 'Select' in inputFile or 'Select' in outputFile or inputFile == '' or outputFile == '': QtGui.QMessageBox.warning(self, 'Warning', 'Please select input and output folder') return inputFolder = os.path.dirname(str(inputFile)) imageExt = str(inputFile).split('.')[-1] if not outputFile.endswith('.mov'): outputFile = '%s.mov' % outputFile if imageExt.lower() == 'avi' or imageExt.lower() == 'mov': inputFolder = '%s/tiffSeq' % os.environ['TEMP'] imageExt = 'tiff' if not os.path.exists(inputFolder): result = utils.extractTiffToTmp(inputFile, inputFolder) if result != 0: QtGui.QMessageBox.warning(self, "Error", "Error while extracting images from input file!") return shotName, firstFrame, lastFrame, date, firstFrameStr = utils.getShotInfo(inputFolder, imageExt) self.movieWidget.setFrameCount(firstFrame, lastFrame) if slugChoice == 2: self.pLabel.setText("Creating slug files") tmpDir = '%s\\tmp' % os.environ['TEMP'] if not os.path.exists(tmpDir): os.mkdir(tmpDir) slugResult = utils.generateSlugImages(tmpDir, self.slugTextBox.text(), firstFrame, lastFrame, date, firstFrameStr, self.pBar) if slugResult != 0: QtGui.QMessageBox.warning(self, 'Error', "Error while creating slug images!") self.createButton.setEnabled(True) return slugMovResult = utils.generateSlugMovie(tmpDir, firstFrame, firstFrameStr) if slugMovResult != 0: QtGui.QMessageBox.warning(self, 'Error', "Error while creating slug movie!") self.createButton.setEnabled(True) return self.pBar.reset() finalMovCmd = utils.generateFileMovie(inputFolder, tmpDir, outputFile, firstFrame, shotName, imageExt, lastFrame, firstFrameStr) else: finalMovCmd = utils.generateFileMovieNoSlug(inputFolder, outputFile, firstFrame, shotName, imageExt, lastFrame, firstFrameStr) threading.Thread( None, self.movieProgress, args=[finalMovCmd]).start()
def getFrameCount(self): infile = str(self.inputWidget.getFilePath()) if infile: inputFolder = os.path.dirname(str(infile)) imageExt = str(infile).split('.')[-1] if imageExt.lower() == 'avi' or imageExt.lower() == 'mov': inputFolder = '%s/tiffSeq' % os.environ['TEMP'] imageExt = 'tiff' shotName, firstFrame, lastFrame, date, firstFrameStr = utils.getShotInfo(str(inputFolder), str(imageExt)) self.movieWidget.setFrameCount(firstFrame, lastFrame)