-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduplicateFrames.py
71 lines (62 loc) · 2.45 KB
/
duplicateFrames.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os.path
import sys
filePath = sys.argv[1]
#Importing Nuke as a Python Module on Windows
sys.path.insert(0, "C:/Program Files/Nuke11.3v1/lib/site-packages/")
import nuke
#Functions
def getLastFrame(filePath):
dirPath = filePath.rsplit("\\", 1)[0]
array = nuke.getFileNameList(dirPath+"\\")
print array
for i in array:
if ".tmp" in i:
array.remove(i)
elif ".mov" in i:
array.remove(i)
else:
pass
lastFrame = array[0].split("-")[-1]
return int(lastFrame)
def createNodes(readNode):
timeOffsetNode = nuke.createNode("TimeOffset")
timeOffsetNode["time_offset"].setValue(-1)
timeOffsetNode.setInput(0, readNode)
differenceNode = nuke.createNode("Difference")
differenceNode.setInput(0, readNode)
differenceNode.setInput(1, timeOffsetNode)
curveToolNode = nuke.createNode("CurveTool")
curveToolNode["channels"].setValue("alpha")
curveToolNode["ROI"].setValue([0,0,readNode.width(),readNode.height()])
curveToolNode.setInput(0, differenceNode)
return curveToolNode
def checkDifferenceValues(curveToolNode, lastFrame):
duplicatedFramesArray = []
for i in range(1,lastFrame):
value = curveToolNode["intensitydata"].getValueAt(i)[-1]
if value == 0.0:
duplicatedFramesArray.append(i)
return duplicatedFramesArray
def writeWarningFile(duplicatedFramesArray):
savePath = "D:/quality_check/failed_qc_shots" #VFX Co-ordinator has this folder setup as a watch folder for notifications of shots that fail QC
nameOfFile = filePath.split("\\")[-1]
shotName = nameOfFile.split(".")[0]
completePath = os.path.join(savePath, shotName+".txt")
fileContents = "Duplicate Frames detected on frames: " + str(duplicatedFramesArray)
file = open(completePath, "a+")
file.write(fileContents)
file.close()
pass
#Setup
if __name__ == "__main__":
readNode = nuke.createNode("Read")
readNode.knob("file").fromUserText(filePath)
readNode["colorspace"].setValue("AlexaV3LogC")
lastFrame = getLastFrame(filePath)
readNode["last"].setValue(lastFrame)
readNode["origlast"].setValue(lastFrame)
curveToolNode = createNodes(readNode)
nuke.execute(curveToolNode, 1, lastFrame)
duplicatedFramesArray = checkDifferenceValues(curveToolNode, lastFrame)
if duplicatedFramesArray:
writeWarningFile(duplicatedFramesArray)