This is my script:
# 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)
I'm basically reading a video and writing out an image sequence.
The problem is, this script renders 1 frame 91 times, it was expected to render 91 different frames.
When I tried to investigate, I found out, the problem is with Read node. I found that frame range was set to 1-1. Do I have to set the frame range manually? Because when I Read the same video file, on GUI, frame ranges are set correctly. This indicates GUI is depending on metadata, whereas my script is not, maybe?
How do I get rid of setting frame range manually?
The problem's contained in your Read node. You should assign a frame range manually:
FIRST METHOD
nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", first="1", last="91")
or just without a first argument:
nuke.nodes.Read(file="C:/Users/Santosh/Desktop/MVI_8411.MOV", last="91")
SECOND METHOD
Or if you don't know the frame range, you can read in QT file automatically using TCL-style:
autoFR = nuke.createNode("Read")
autoFR["file"].fromUserText("C:/Users/Santosh/Desktop/MVI_8411.MOV")
Also I suppose it may be possible with sys
module's functions but definitely not using ViewMetaData
node (in first method), 'cause it reads in only visible frame range when you use it in GUI mode or in CLI mode with already assigned frame range. The metadata()
method returns a python dictionary containing the metadata for your Nuke_Class1 node, for example:
node = nuke.toNode("Nuke_Class1")
print node.metadata()