为什么 Read() 在 CLI 模式下不读取帧范围?

Why is Read() not reading the frame range in CLI mode?

这是我的脚本:

# 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 个不同的帧。

当我试图调查时,我发现问题出在读取节点上。我发现 frame range 被设置为 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")

第二种方法

或者如果你不知道帧范围,你可以使用TCL风格自动读入QT文件:

autoFR = nuke.createNode("Read") 
autoFR["file"].fromUserText("C:/Users/Santosh/Desktop/MVI_8411.MOV")

另外我认为 sys 模块的功能可能是可能的,但绝对不使用 ViewMetaData 节点(在第一种方法中),因为当你在已分配帧范围的 GUI 模式或 CLI 模式。 metadata() 方法 returns 包含 Nuke_Class1 节点元数据的 python 字典,例如:

node = nuke.toNode("Nuke_Class1")
print node.metadata()