Python 为什么Read()不在CLI模式下读取帧范围?
这是我的剧本:Python 为什么Read()不在CLI模式下读取帧范围?,python,nuke,Python,Nuke,这是我的剧本: # confirming the project dimension resolution projset = nuke.Root() projset["format"].setValue("HD_1080") # load video foot = nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", name="Nuke_Class1") # select read node and attach wr
# confirming the project dimension resolution
projset = nuke.Root()
projset["format"].setValue("HD_1080")
# load video
foot = nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", name="Nuke_Class1")
# select read node and attach write node to it
nuke.toNode("Nuke_Class1").setSelected(True)
wr = nuke.createNode("Write")
# specify the sequence path
wr["file"].setValue("C:/Users/Santosh/Desktop/nukke/nuke_API_###.jpg")
# connect to the first viewer, if many
nukescripts.connect_selected_to_viewer(0)
# perform the render, 50th to 140th frame
nuke.render(wr, 50, 140, 1)
我基本上是在读一段视频,然后写出一个图像序列
问题是,此脚本渲染1帧91次,预期会渲染91个不同的帧
当我试图调查时,我发现,问题在于读取节点。我发现帧范围设置为1-1。我必须手动设置帧范围吗?因为当我在GUI上读取相同的视频文件时,帧范围设置正确。这表明GUI依赖于元数据,而我的脚本可能不是
如何避免手动设置帧范围?问题包含在读取节点中。您应该手动指定帧范围: 第一种方法
nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", first="1", last="91")
或者只是没有第一个论点:
nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", last="91")
第二种方法
nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", first="1", last="91")
或者,如果您不知道帧范围,可以使用TCL样式自动读取QT文件:
autoFR = nuke.createNode("Read")
autoFR["file"].fromUserText("C:/Users/Santosh/Desktop/MVI_8411.MOV")
另外,我认为可以使用sys
模块的功能,但绝对不能使用viewmatadata
节点(在第一种方法中),因为当您在GUI模式下使用它或在CLI模式下使用已经分配的帧范围时,它只能在可见帧范围内读取。metadata()
方法返回一个python字典,其中包含Nuke_Class1节点的元数据,例如:
node = nuke.toNode("Nuke_Class1")
print node.metadata()