Accessing Nuke’s Write node advanced Compression Settings dialog with Python.

Written by Gary Kelly on .

There are a couple different ways of working with the Compression Settings panel for setting up a Quicktime in Nuke’s Write node.

write node advanced

Setting fps, quality & keyframe rate.

Nuke adds 3 additional hidden knobs: ‘fps’, ‘quality’ & ‘keyframerate’ to the Write node after selecting ‘MOV’ as the file type. (it actually adds 4, but i’ll cover that in a second…)

You can set them the same way you would with other knobs:

w = nuke.createNode(‘Write’)
w.knob(‘file_type’).setValue(‘MOV’)
w.knob(‘codec’).setValue(‘avc1’)


w.knob(‘fps’).setValue(25)
w.knob(‘quality’).setValue(‘Normal’)
w.knob(‘keyframerate’).setValue(‘12’)

The ‘settings’ knob.

As well as the 3 above, an additional knob named ‘settings’ is available as a way to access the Compression Settings dialog.

By default, the ‘settings’ knob is a blank string. When you change the settings in the dialog though, this knob stores a serialized data string that can be used to reproduce those settings.

Start by opening the Compression Settings dialog and enter all the settings you want. When you’re done, click OK.

Either print the value of the knob in Nuke’s Script Editor, or copy and paste the Write node into a plain text editor. Either way you’re looking for the large string that the ‘settings’ knob is storing. So for example: Assuming you only have your Write node selected, with all the required settings applied, enter this into Nuke’s Script Editor…

i = nuke.selectedNode()

print i.knob(‘settings’).value()

This should return a big long string that looks something like this:

0000000000000000000000000000019a7365616e0000000100000001000000000000018676696465000000010000000e00000000000000227370746c0000000100000000000000006176633100000000001800000400000000207470726c00000001000000000000000000000400001e00000000000c000000246472617400000001000000000000000000465000000000530000010000000100000000156d70736f00000001000000000000000000000000186d66726100000001000000000000000000000000000000187073667200000001000000000000000000000000000000156266726100000001000000000000000001000000166d70657300000001000000000000000001000000002868617264000000010000000000000000000000000000000000000000000000000000000000000016656e647300000001000000000000000000000000001663666c67000000010000000000000000004400000018636d66720000000100000000000000006170706c00000014636c75740000000100000000000000000000001c766572730000000100000000000000000003001c00010000

You can now copy and store that string for use in your code to setup the advanced Compression Settings dialog.

w = nuke.createNode(‘Write’)
w.knob(‘file_type’).setValue(‘MOV’)
w.knob(‘codec’).setValue(‘avc1’)

w.knob(‘settings’).value(‘0000000000000000000000000000019a7365616e0000000100000001000000000000018676696465000000010000000e00000000000000227370746c0000000100000000000000006176633100000000001800000400000000207470726c00000001000000000000000000000400001e00000000000c000000246472617400000001000000000000000000465000000000530000010000000100000000156d70736f00000001000000000000000000000000186d66726100000001000000000000000000000000000000187073667200000001000000000000000000000000000000156266726100000001000000000000000001000000166d70657300000001000000000000000001000000002868617264000000010000000000000000000000000000000000000000000000000000000000000016656e647300000001000000000000000000000000001663666c67000000010000000000000000004400000018636d66720000000100000000000000006170706c00000014636c75740000000100000000000000000000001c766572730000000100000000000000000003001c00010000’)

Comments   

 
0 # Ezequiel Cesana 2014-02-17 21:44
Thanks!
 
 
0 # Tom Feist-Wilson 2015-04-13 13:35
unfortunately this didn't work for me :(

I've noted a small correction that needs to be made to the above, with Nuke 8 at least, that for setting the value of the file_type should be in lower case for the MOV

Quote:
w.knob(‘file_type’).setValue(‘MOV’)
should be
Quote:
w.knob(‘file_type’).setValue(‘mov’)
I saved my settings for the write file as a node pre-set and it's interesting the long coded value is listed as "mov.settings" rather than simply "settings". The fps and key frame rate are also handled as separate attributes "mov.fps" and "mov.keyframerate" respectively. However using these strings to set values hasn't been successful for me so far.

I also tried to load in the pre-set I'd made in the menu.py and then use:
Quote:
nuke.applyUserPreset("Write1", "MyWritePreset")
Where "MyWritePreset" is the name I've called my pre-set. The problem here though is that nuke won't accept a node in the first argument ("Write1") only a string...not very handy if you're trying to iterate over things.

If anyone can shed some light on this I'd love to hear it :)
 
 
0 # Tom Feist-Wilson 2015-04-13 14:12
Woop!

I managed to set my fps using the code below. Got stuck for a bit trying to figure out why it was coming up with errors about having two float values. I didn't know you have to use the float() fiction built in to python to do this!

Quote:

fpsValue = float(YourFPS)
w.knob("fps").setValue(fpsValue )
where YourFPS is a variable describing your desired fps. In my personal example I was actually just using a straight integer (25)
 
 
+1 # punit vishwkarma 2023-03-28 11:44
Im not getting AVID QT Format: DNx36 MXF(w/ALE) option in nuke 13 to render video file . can someone please help me out ?
 

You have no rights to post comments

We have 2234 guests and 73 members online