I used that RE before the padding match in case there was a non-alphanumeric character before the padding (. – _ etc.). If you know there will always be a period there, you can be a little more specific, but I was playing it safe. Otherwise, your MOV could come out with a name like myImageSequence-.mov
To get around paths with TCL expressions in them, you can use nuke.thisNode()['file'].evaluate(). The one minor issue with this is it will insert a frame and view into the path, so you’ll lose your padding notation. However, it should be trivial to pull the padding from the uneval’ed path and insert it into the evaluated one. -Nathan From: rsgca Sent: Thursday, April 19, 2012 10:27 PM To: [email protected] Subject: [Nuke-python] Re: How to Execute Shell FFmpeg Command inAfterRender Callback Nathan, This is fantastic, thanks! I've made a few changes: -- import os, re, shlex, subprocess def sendToFFmpeg(): # grabs the write node's file value and makes sure the path uses printf style filenames imgSeqPath = nukescripts.replaceHashes(nuke.thisNode()['file'].value()) # generate mov path base, ext = os.path.splitext(os.path.basename(imgSeqPath)) movPath = os.path.dirname(os.path.dirname(imgSeqPath)) + '/' + re.sub('\.?%0\d+d$', '', base) + '.mov' # make shell command enc = 'ffmpeg -y -r 24 -i \'%s\' -an -vcodec libx264 -vpre slow -crf 22 -threads 0 \'%s\'' % (imgSeqPath, movPath) subprocess.Popen(shlex.split(enc), stdout=subprocess.PIPE, stderr=subprocess.PIPE) -- Specifically, a.. Updated the mov path to write the mov one directory up from the image sequence b.. Added escaped quotations marks around the shell path c.. Updated the ffmpeg call for the default compile on ubuntu 11.10 It works well, though I have a couple questions: 1.. Why did you use [^A-Za-z0-9]? instead of just \. in the re.sub() call? 2.. If the file value passed from the Write node has any TCL, ffmpeg obviously fails. Is there a way around this? Lastly, for anyone else attempting this, remember that ffmpeg assumes the image sequence starts at frame 0. At some point, I'll have to work out a way to pass any offset to the command. - Richard -------------------------------------------------------------------------------- _______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
