I am trying to write a script that runs on completion of a network rendered job. When the job is finished it will run and compile all the rendered frames into an .mov and save it in a watch folder for adobe media encoder. Then adobe media encoder will then encode the .mov into a .flv ready to be put into flash.
Most of this script was graciously written by Richard Annema in a previous thread on cgsociety http://forums.cgsociety.org/showthr...p?f=98&t=704301. I am just having some problems getting it to run with backburner. Here is the script I have modified to run at the completion of a job. It still dosent work right though any help would be greatly appreciated.
--connect to manager
manager = NetRender.GetManager()
--get the name of the job
myJob = manager.getJobs #name
--check to see if the job is done
myJobComplete = myJob.notifyCompletion
--if the job is done then run the script
if myJobComplete == true then
-- begining of script written by Richard Annema
-- get the files rendered
files = getFiles ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + "*" + (getFilenameType rendOutputFilename))
-- remove any still we might have rendered
if (files.count > 1) then (
stillIndex = findItem files rendOutputFilename
if (stillIndex != 0) then ( deleteItem files stillIndex )
-- make sure the frames are in the correct order
sort files
)
-- create an IFL
iflName = getFilenamePath rendOutputFilename + getFilenameFile rendOutputFilename + ".ifl"
iflFile = createFile iflName
for f in files do ( format "%\n" f to:iflFile )
close iflFile
-- open the IFL as a bitmap
iflBitmap = openBitmap iflName
-- create an output bitmap
movBitmap = bitmap iflBitmap.width iflBitmap.height
-- create a mov filename
movName = "\\\Tta_server\3d model library\AdobeWatch\\" + getFilenameFile rendOutputFilename + ".mov"
-- delete pre-existing quicktime mov
deleteFile movBitmap.filename
-- set its name to the mov filename
movBitmap.filename = movName
-- loop through its frames
for i = 0 to (iflBitmap.numFrames - 1) do (
iflBitmap.frame = i
-- get the ifl's frame into the mov bitmap
copy iflBitmap movBitmap
-- display as we go over each frame - just so you can see something's happening
display movBitmap
-- save out the mov bitmap (appends as new frame)
save movBitmap frame:i
)
-- close the mov so it is finalized
close movBitmap
By
Comments (10)
Comment policy
Don't know why I didn't think of this right away...
I think the better way to approach this would be to create a blank job that runs the frame stitch and set it to be dependent on the first job. That way you have control in backburner of the original job and the compile frames job.
As to exactly what code you should use to accomplish that - sorry don't think I have the time to take care of that for you...
Actully that dependencies thing works great thanks a lot. Now I just need to find a way to script it.
Well turns out fixing the directory portion this thing runs just fine for network rendering without a dependancy or some fancy network comuniction. SO problem solved thanks for your help.
Got the dependency working but was unable to attach a script. So on input from another thread I decided to get the number of frames that need to be rendered and make sure they are done before running the script.
here is the thread
http://forums.cgsociety.org/showthread.php?p=5563105#post5563105
Here is the script:
/*get the number of frames to be rendered*/
--check to see what the time output is set to
reTime = rendTimeType
--if it is sent to animation rage then get the number of frames
if (reTime == 3 ) then (
numFrames = rendEnd
s1 = "000" + numFrames as string
s2 = "f"
s3 = ""
FrameNum = substituteString s1 s2 s3
)
--if it is sent to active time segment then get the number of frames
if (reTime == 2 ) then (
numFrames = AnimationRange.end
s1 = "000" + numFrames as string
s2 = "f"
s3 = ""
FrameNum = substituteString s1 s2 s3
)
-- if the file exists then run
LastFrame = doesFileExist ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + FrameNum as String + (getFilenameType rendOutputFilename))
if( LastFrame == true) then (
--pause for 1 minute to make sure all the frames are done
Print "sleeping"
sleep 10
-- get the files rendered
files = getFiles ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + "*" + (getFilenameType rendOutputFilename))
-- remove any still we might have rendered
if (files.count > 1) then (
stillIndex = findItem files rendOutputFilename
if (stillIndex != 0) then ( deleteItem files stillIndex )
-- make sure the frames are in the correct order
sort files
)
-- create an IFL
x = 01
iflName = getFilenamePath rendOutputFilename + getFilenameFile rendOutputFilename + execute "x += 1" as string + ".ifl"
iflFile = createFile iflName
for f in files do ( format "%\n" f to:iflFile )
close iflFile
-- open the IFL as a bitmap
iflBitmap = openBitmap iflName
-- create an output bitmap
movBitmap = bitmap iflBitmap.width iflBitmap.height
-- create a mov filename
movName = "\\\\Tta_server\\3d model library\\AdobeWatch\\" + getFilenameFile rendOutputFilename + execute "x += 1" as string + ".mov"
-- delete pre-existing quicktime mov
deleteFile movBitmap.filename
-- set its name to the mov filename
movBitmap.filename = movName
-- loop through its frames
for i = 0 to (iflBitmap.numFrames - 1) do (
iflBitmap.frame = i
-- get the ifl's frame into the mov bitmap
copy iflBitmap movBitmap
-- save out the mov bitmap (appends as new frame)
save movBitmap frame:i
)
-- close the mov so it is finalized
close movBitmap
)
Ok finally done. I ended up using the dependancy script written by Johan Boekhoven mentioned in a previous thread. I just modified it to work with ffmpeg. It is now a 1 button press to an FLV on are render farm. Here is the script.
Just a shot in the dark here since I haven't ever worked with post-render scripts before...
Is your script network accessible? I'm not sure but I'd assume that a post-render script would need to be put on a network drive that all render nodes would have access to... Just a thought.
...
Unfortunately the answer to your other question regarding whether post-render scripts are per frame probably isn't the answer you want... According to the info on this page http://area.autodesk.com/index.php/forums_archive/thread_index/594759/ post-render scripts are evaluated at the end of every render process (typically a small chunk of frames the manager assigns to a server) so who knows how many times it'd be called on a farm.
I know I've heard many times of people setting up automated scripts to compile frames after backburner - I'm going to look around a bit more and see what I find.
How do post render scripts work with netrendering? Are scripts executed after every frame or at the end of a job? Because now this script works perfectly as a post render script but when I use it for net rendering nothing happens.
Here is the post render script minus the network comunication.
-- get the files rendered
files = getFiles ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + "*" + (getFilenameType rendOutputFilename))
-- remove any still we might have rendered
if (files.count > 1) then (
stillIndex = findItem files rendOutputFilename
if (stillIndex != 0) then ( deleteItem files stillIndex )
-- make sure the frames are in the correct order
sort files
)
-- create an IFL
iflName = getFilenamePath rendOutputFilename + getFilenameFile rendOutputFilename + ".ifl"
iflFile = createFile iflName
for f in files do ( format "%\n" f to:iflFile )
close iflFile
-- open the IFL as a bitmap
iflBitmap = openBitmap iflName
-- create an output bitmap
movBitmap = bitmap iflBitmap.width iflBitmap.height
-- create a mov filename
movName = "\\\\Tta_server\\3d model library\\AdobeWatch\\" + getFilenameFile rendOutputFilename + ".mov"
-- delete pre-existing quicktime mov
deleteFile movBitmap.filename
-- set its name to the mov filename
movBitmap.filename = movName
-- loop through its frames
for i = 0 to (iflBitmap.numFrames - 1) do (
iflBitmap.frame = i
-- get the ifl's frame into the mov bitmap
copy iflBitmap movBitmap
-- display as we go over each frame - just so you can see something's happening
display movBitmap
-- save out the mov bitmap (appends as new frame)
save movBitmap frame:i
)
-- close the mov so it is finalized
close movBitmap
Ahh, thank you.
Viro - when you use a \ in maxscript that signifies you're about to use a special character (ie \n for newline) so you've got to use double \\ for directories and quad \\\\ for drives.
So, your path line should read like this:
Ok I can talk to the manager now and grab a array of names. I just can get back that the job is complete so that the script will be triggered. Here is the updated script.
manager = NetRender.GetManager()
--connecting manager
manager.connect #automatic "255.255.255.0" port:3234
--get que control
manager.wantControl=true
--get job names
myJob = manager.getJobs filter:#name key:"name"
--check to see if the job is done
myJobComplete = myJob.state
--if the job is done then run the script
if myJobComplete == #complete then
-- get the files rendered
files = getFiles ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + "*" + (getFilenameType rendOutputFilename))
-- remove any still we might have rendered
if (files.count > 1) then (
stillIndex = findItem files rendOutputFilename
if (stillIndex != 0) then ( deleteItem files stillIndex )
-- make sure the frames are in the correct order
sort files
)
-- create an IFL
iflName = getFilenamePath rendOutputFilename + getFilenameFile rendOutputFilename + ".ifl"
iflFile = createFile iflName
for f in files do ( format "%\n" f to:iflFile )
close iflFile
-- open the IFL as a bitmap
iflBitmap = openBitmap iflName
-- create an output bitmap
movBitmap = bitmap iflBitmap.width iflBitmap.height
-- create a mov filename
movName = "\\\Tta_server\3d model library\AdobeWatch\\" + getFilenameFile rendOutputFilename + ".mov"
-- delete pre-existing quicktime mov
deleteFile movBitmap.filename
-- set its name to the mov filename
movBitmap.filename = movName
-- loop through its frames
for i = 0 to (iflBitmap.numFrames - 1) do (
iflBitmap.frame = i
-- get the ifl's frame into the mov bitmap
copy iflBitmap movBitmap
-- display as we go over each frame - just so you can see something's happening
display movBitmap
-- save out the mov bitmap (appends as new frame)
save movBitmap frame:i
)
-- close the mov so it is finalized
close movBitmap
--give back que control
manager.wantControl=false
--disconnect from manager
manager.disconnect