One quick take:

import os
import re
import shlex
import subprocess

def sendToFFMPEG():
    outPath = nukescripts.replaceHashes(nuke.thisNode()['file'].value())
    base, ext = os.path.splitext(os.path.basename(outPath))
    enc = 'ffmpeg -y -r 24 -i %s -an -vcodec libx264 -preset slow -profile 
baseline -threads 0 ~/Desktop/%s.mov' % (outPath, 
re.sub('[^A-Za-z0-9]?%0\d+d$', '', base))
    subprocess.Popen(shlex.split(enc), stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)


Note that this doesn’t account for stereo output, but could be modified to do 
so without much trouble.

-Nathan



From: rsgca 
Sent: Wednesday, April 18, 2012 7:02 PM
To: [email protected] 
Subject: [Nuke-python] How to Execute Shell FFmpeg Command in 
AfterRenderCallback

Using a Write node's AfterRender callback, I want automate FFmpeg on Linux to 
make a movie from an image sequence rendered out of Nuke.

Typically, this is handled by a dedicated render manager, which we don't have 
in this case.

I think the callback function would look something like this but I'm not 
certain about the subprocess.Popen stuff:

      Code:  

      def ffmpeg(imageSequence, outputFilename):
         cmd = 'mkdir %s' % (imagePath)
         cmd = 'ffmpeg -y -r 24 -i %s -an -vcodec libx264 -preset slow -profile 
baseline -threads 0 ~/Desktop/%s.mov' % (imageSequence, outputFilename)
         print(cmd)
         retVal = subprocess.Popen(shlex.split(cmd), shell=True, 
stdout=subprocess.PIPE) 
         if retVal==['']:
            return(0)
         else:
            return(retVal)
     


What python code can I use in the function call to pass the output filename and 
output image sequence?

Any suggestions on the code above would be great!


--------------------------------------------------------------------------------
_______________________________________________
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

Reply via email to