PDA

View Full Version : Net rendering a post render script help.


viro
12-10-2008, 04:39 PM
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 gracily written by Richard Annema in a previous thread http://forums.cgsociety.org/showthread.php?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 (http://forums.cgsociety.org/) 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

viro
12-10-2008, 10:14 PM
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 (http://forums.cgsociety.org/) 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

viro
12-11-2008, 06:25 PM
Got it sorted out. I was writing the directory string wrong. Here is the finished working script. Works with net rendering as well.

- 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 (http://forums.cgsociety.org/) 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

viro
12-15-2008, 11:20 PM
Went with a different option. the finished script is here.
http://forums.cgsociety.org/showthread.php?p=5563105#post5563105

viro
12-22-2008, 06:21 PM
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.

macroScript FLVrenderer
category:"Mikes"
toolTip:""
(
/* CONNECT TO THE NETWERK MANAGER */
m = netrender.getmanager()
c1 = m.connect #automatic "255.255.255.0"

-- Batch it max (PEN) runs through a folder of files opening them and submitting them via this script
localFileName = maxFilePath + maxFileName

--saves the settings
saveMaxFile localFileName

-- Will be used in the mxs submit and dosCommand dependencies!
jobName = (filterString maxFileName "." )[1] -- < add some extra string here to allow to sent unique jobs

/* WHEN CONNECTION AND FILE SUCCESFULLY COPIED */
if c1 then
(
/* SUBMIT JOB */
-- Easy BB submit
job = m.newjob file:localFileName
job.name = jobName
job.includeMaps = true --turn on "Include Maps"
job.submit() --this uses all servers for the job


/* FILE SETTINGS */
-- Set the parameters that ffmpeg needs
startTime = "%%04d"
fPath = getFilenamePath rendOutputFilename
s1 = toLower fpath
s2 = "\\\\tta_server\\3d (http://forums.cgsociety.org/) model library\\"
s3 = " z:\\"
filePath = substituteString s1 s2 s3

fileName = (getFilenameFile rendOutputFilename )
fileNameExt = getFilenameType rendOutputFilename

vInput = filePath + fileName + startTime + fileNameExt

ffmpeg = @"z:\ffmpeg.exe "
vScript1 = @"-f image2 -i " + vInput
vOutput1 = @" -b 700k -vcodec flv -y " + filePath + fileName + ".flv"
scriptJobName1 = jobName + "_FLV"

print ffmpeg + vScript1 + vOutput1

/* OUTPUT1 - UNCOMPRESSED AVI */
-- Build stringStream
jobString1 = stringStream ""

-- Create jobname
format "-jobName:% " scriptJobName1 to:jobString1

-- SET THE DEPENDENCY!
format "-dependencies:% " jobName to:jobString1

-- Add netmask
format "-netmask:255.255.255.0 " to:jobString1

-- Add execution string
format "% " (ffmpeg + vScript1 + vOutput1) to:jobString1

-- max root
maxRoot = pathConfig.GetDir #maxroot

-- Build command string
cmd = "cmdjob.exe " + (jobString1 as string)

-- Execute it
DOSCommand cmd

)
)

oshahrukho
12-30-2008, 10:15 AM
y r v using scripts?any 1 tell me???

viro
12-30-2008, 02:40 PM
To save my company time and money. My artists had to manually load up all the rendered frames in Photoshop just to export them to FLVs so we could put them in flash. When you add up all time its a lot. So now we have a 1 button click to render an FLV and can put it staright in flash after the render farm is done with it. JUst cutting steps in the pirpeline to save money.

viro
12-31-2008, 03:50 PM
Ok got another idea I am trying with this. I want to create a script that submits a job with low render settings no outpath, every nth set to 5 and a final gather map set to save. Then submit a job behind that one with the render setting set higher, an output path turned back on and the final gather map set to freeze. I have it working in a sense that the render settings are switching around ok. The problem I am having is with the dependant job. It is submiting but it can do anything becuse there is no max file. Any ideas?

--sets mentalray as renderer and puts it in renders.current
RendererClass.classes
renderers.current = mental_ray_renderer()

--set the render settings to lower and not to save anything but the fgm to the fgm location set the every nth to 5
--set save file to off
rendSaveFile = false
--set every nth to 5
nFrame = rendNThFrame = 5
--set min an max to 1/64
renderers.current.MinimumSamples = -3
renderers.current.MaximumSamples = -3
--set the noise filter to none.
renderers.current.FinalGatherFilter = 0
--set finalgathersettings
--enable final gather
renderers.current.FinalGatherEnable2 = true
--set the point density
renderers.current.FinalGatherDensity = 0.9
--sets the rays per final gather point
renderers.current.FinalGatherAccuracy = 120
--set the interopalation
renderers.current.FinalGatherInterpolationSamples = 30
--set the bounces
renderers.current.FinalGatherBounces = 1
--fgm location
loc = "\\\\Tta_server\\3d (http://forums.cgsociety.org/) model library\\sceneassets\\renderassets\\FGM"
fName = (filterString maxFileName "." )[1]
--fgm to enabled and set the save location
--enable the final gather map
renderers.current.UseFinalGatherFile = true
--set freeze final gather to false
renderers.current.FinalGatherFreeze = false
--Set the Filename and location of the FGM
renderers.current.FinalGatherFilename = loc + fName

--save a instanced file and submit the job to backburner
saveMaxFile maxFileName useNewFile: true

--Submit the job to the network with its current settings to render
m = netrender.getmanager()
c1 = m.connect #manual "tta11"

-- Batch it max (PEN) runs through a folder of files opening them and submitting them via this script
localFileName = maxFilePath + maxFileName

-- Will be used in the mxs submit and dosCommand dependencies!
jobName = (filterString maxFileName "." )[1] -- < add some extra string here to allow to sent unique jobs

/* WHEN CONNECTION AND FILE SUCCESFULLY COPIED */
if c1 then
(
/* SUBMIT JOB */
-- Easy BB submit
job = m.newjob file:localFileName
job.name = jobName
job.nthFrame = nFrame
job.includeMaps = true --turn on "Include Maps"
job.submit() --this uses all servers for the job

--pause here for 2 seconds
sleep 2
--set settings to highest
rendSaveFile = true
nFrame2 = rendNThFrame = 1
frames = "all"
renderers.current.MinimumSamples = 0
renderers.current.MaximumSamples = 2
renderers.current.FinalGatherFreeze = true
saveMaxFile maxFileName useNewFile: false

fPath = maxFilePath + maxFileName
s1 = toLower fpath
s2 = "\\\\tta_server\\3d (http://forums.cgsociety.org/) model library\\"
s3 = " z:\\"
filePath = substituteString s1 s2 s3

--set dependancy
--create string stream
jobString1 = stringStream ""

pFiles = "Program Files"

--create scriptJobName1
scriptJobName1 = jobName + "01"

-- job root
backRoot = jobName + ".max"


-- Create jobname
format "-jobName:% " scriptJobName1 to:jobString1

-- SET THE DEPENDENCY!
format "-dependencies:% " jobName to:jobString1

-- Add netmask
format "-netmask:255.255.255.0 " to:jobString1

-- --Submits the job to the manager
-- format "-s[:%] " "tta11" to:jobString1

-- --frames to render
-- format "-frames % " frames to:jobString1

-- --writes the xml job file
-- format "-attach " to:jobString1

--add max file
format "-tasklist% " filePath to:jobString1

-- Build command string
cmd = "cmdjob.exe " + (jobString1 as string) + backRoot

-- Execute it
DOSCommand cmd
)

CGTalk Moderation
12-31-2008, 03:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.