PDA

View Full Version : Post render script


viro
12-04-2008, 06:15 PM
I am trying to create a post render script that opens ram player and loads the frames that where just rendered and saves out an .mov. Anyone have any ideas?

scrimski
12-04-2008, 06:41 PM
Try this as inspiration
http://www.scriptspot.com/3ds-max/ram-render

ZeBoxx2
12-04-2008, 07:01 PM
Can't save MOVs from the RAM player - you'd have to save it manually... can also do it by script but it's a bit slower.

The aforementioned script seems to take some predefined filenames... the below example should work with any project provided you name the output reasonably uniquely as it does use a wildcard to get the images rendered.. to get the exact frames that were actually rendered just before the postRender script is called you'd have to work with the render scene dialog settings (range, frame step, etc.).

Edit: For code - see attached files in later post(s)

viro
12-04-2008, 07:33 PM
Wow, thank you so much.

This is pretty close to exactly what we needed.
We are just trying to get rid of a step in our pipeline. We have to mamually open are rendered image sequences and encode them to flvs to be used inside flash.

So with this we can render our image sequence and max and flash can do the rest. So when the image sequence is done the script runs ram player and saves and .mov or .avi to a watch folder. When the adobe media encoder sees the .mov or .avi in the watch folder it will then encode it to an flv.
1 thing, it runs fine when I run the script but when it is in the post render sciprt section in the render dialog it dosent seem to run. Am I missing somthing?

ZeBoxx2
12-04-2008, 08:02 PM
So when the image sequence is done the script runs ram player and saves and .mov or .avi to a watch folder.
Won't need the RAM Player line, then :)

1 thing, it runs fine when I run the script but when it is in the post render sciprt section in the render dialog it dosent seem to run. Am I missing somthing?
Not that I can think of.. it's how I've been testing it. Does an error message appear in the Listener, perhaps? Is an output filename specified in the render scene dialog? if you *just* set that up, then perhaps maxscript isn't aware of it yet. may have to close the dialog first, although I would think the postRender scripts keep that in mind.

viro
12-04-2008, 09:50 PM
I think it is pulling undefined at this line

-- open the IFL as a bitmap
iflBitmap = openBitmap iflName

After that we get these errors
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\PostRenderScript.ms; position: 892
-- Unknown property: "filename" in <File:C:\Documents and Settings\Mike\My Documents\3dsmax\renderoutput\10000.ifl>
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\PostRenderScript.ms; position: 0
-- Unknown property: "filename" in <File:C:\Documents and Settings\Mike\My Documents\3dsmax\renderoutput\10000.ifl>

I replaced openBitmap with openFile and the undefined wht away but I still end up with these errors.

any Ideas

ZeBoxx2
12-04-2008, 10:15 PM
nope - no idea... openBitmap was correct.

I'm attaching the script as I'm using it (fresh max start.. no problems) as well as a debug version.. might give some more information to work with.

Edit: For the attachment - see later post(s).

viro
12-04-2008, 10:34 PM
Here is what I am getting from max. I think it might be somthing I am doing like file paths or somthing.

"autoQuicktime DEBUG"
"get the files rendered"
"C:\Transfer\test\10000.jpg"
"remove any still we might have rendered"
1
"deleting still"
"C:\Transfer\test\10000.jpg"
"make sure the frames are in the correct order"
"Sorted files:"
"Files section done"
""
"create an IFL"
"C:\Transfer\test\10000.ifl"
<File:C:\Transfer\test\10000.ifl>
"writing filenames to ifl file"
"closing ifl file"
"IFL section done"
""
"open the IFL as a bitmap"
undefined
"IFL opening section done"
"create an output bitmap"
undefined
"create a mov filename"
"C:\Transfer\test\10000.mov"
"delete pre-existing quicktime mov"
-- Error occurred during fileIn in <File:C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms>

ZeBoxx2
12-04-2008, 10:55 PM
ah - you're rendering a single image, looks like.. or, at least, getFiles is only getting that one single image. And that one single image is what your output filename is as well - which it deletes as it assumes that it was a still render that's not part of the animation.

Of course when it does that, there are no files left.. thus no frames.. whoops.

Attaching new files here...

Edit: For the attachment - see later post(s).

viro
12-04-2008, 11:22 PM
We are getting really close. The last problem was becuse I chose the #1 as my file name I have sence changed it to test me and the sequence loaded correctly. I still dont have a .mov in the output folder though. I am going to run the debuger script again and see if it might be somthing else I am doing wrong with the file name or path.

ZeBoxx2
12-04-2008, 11:29 PM
note that if you run it as a postRender script, error messages from maxscript are pretty... uninformative. Open it as a regular script and then evaulate it (after you render a sequence of images)... that should give better information if there's some error in the code itself. The path really shouldn't matter.. quicktime under 64bit might be an issue, but I presume you can save quicktime files manually so that shouldn't apply.

viro
12-04-2008, 11:34 PM
Here is what I am getting now. Looks pretty good until we get to "create an ouput bitmap".

"autoQuicktime DEBUG"
"autoQuicktime DEBUG"
"get the files rendered"
"get the files rendered"
#("C:\Transfer\test\TestMe0000.jpg", "C:\Transfer\test\TestMe0001.jpg", "C:\Transfer\test\TestMe0002.jpg", "C:\Transfer\test\TestMe0003.jpg", "C:\Transfer\test\TestMe0004.jpg", "C:\Transfer\test\TestMe0005.jpg", "C:\Transfer\test\TestMe0006.jpg", "C:\Transfer\test\TestMe0007.jpg", "C:\Transfer\test\TestMe0008.jpg", "C:\Transfer\test\TestMe0009.jpg", "C:\Transfer\test\TestMe0010.jpg", "C:\Transfer\test\TestMe0011.jpg", "C:\Transfer\test\TestMe0012.jpg", "C:\Transfer\test\TestMe0013.jpg", "C:\Transfer\test\TestMe0014.jpg", "C:\Transfer\test\TestMe0015.jpg", "C:\Transfer\test\TestMe0016.jpg", "C:\Transfer\test\TestMe0017.jpg", "C:\Transfer\test\TestMe0018.jpg", "C:\Transfer\test\TestMe0019.jpg", ...)
"C:\Transfer\test\TestMe0000.jpg"
"C:\Transfer\test\TestMe0001.jpg"
"C:\Transfer\test\TestMe0002.jpg"
"C:\Transfer\test\TestMe0003.jpg"
"C:\Transfer\test\TestMe0004.jpg"
"C:\Transfer\test\TestMe0005.jpg"
"C:\Transfer\test\TestMe0006.jpg"
"C:\Transfer\test\TestMe0007.jpg"
"C:\Transfer\test\TestMe0008.jpg"
"C:\Transfer\test\TestMe0009.jpg"
"C:\Transfer\test\TestMe0010.jpg"
"C:\Transfer\test\TestMe0011.jpg"
"C:\Transfer\test\TestMe0012.jpg"
"C:\Transfer\test\TestMe0013.jpg"
"C:\Transfer\test\TestMe0014.jpg"
"C:\Transfer\test\TestMe0015.jpg"
"C:\Transfer\test\TestMe0016.jpg"
"C:\Transfer\test\TestMe0017.jpg"
"C:\Transfer\test\TestMe0018.jpg"
"C:\Transfer\test\TestMe0019.jpg"
"C:\Transfer\test\TestMe0020.jpg"
"C:\Transfer\test\TestMe0021.jpg"
"C:\Transfer\test\TestMe0022.jpg"
"C:\Transfer\test\TestMe0023.jpg"
"C:\Transfer\test\TestMe0024.jpg"
"C:\Transfer\test\TestMe0025.jpg"
"C:\Transfer\test\TestMe0026.jpg"
"C:\Transfer\test\TestMe0027.jpg"
"C:\Transfer\test\TestMe0028.jpg"
"C:\Transfer\test\TestMe0029.jpg"
"C:\Transfer\test\TestMe0030.jpg"
"C:\Transfer\test\TestMe0031.jpg"
"C:\Transfer\test\TestMe0032.jpg"
"C:\Transfer\test\TestMe0033.jpg"
"C:\Transfer\test\TestMe0034.jpg"
"C:\Transfer\test\TestMe0035.jpg"
"C:\Transfer\test\TestMe0036.jpg"
"C:\Transfer\test\TestMe0037.jpg"
"C:\Transfer\test\TestMe0038.jpg"
"C:\Transfer\test\TestMe0039.jpg"
"C:\Transfer\test\TestMe0040.jpg"
"C:\Transfer\test\TestMe0041.jpg"
"C:\Transfer\test\TestMe0042.jpg"
"C:\Transfer\test\TestMe0043.jpg"
"C:\Transfer\test\TestMe0044.jpg"
"C:\Transfer\test\TestMe0045.jpg"
"C:\Transfer\test\TestMe0046.jpg"
"C:\Transfer\test\TestMe0047.jpg"
"C:\Transfer\test\TestMe0048.jpg"
"C:\Transfer\test\TestMe0049.jpg"
"C:\Transfer\test\TestMe0050.jpg"
"C:\Transfer\test\TestMe0051.jpg"
"C:\Transfer\test\TestMe0052.jpg"
"C:\Transfer\test\TestMe0053.jpg"
"C:\Transfer\test\TestMe0054.jpg"
"C:\Transfer\test\TestMe0055.jpg"
"C:\Transfer\test\TestMe0056.jpg"
"C:\Transfer\test\TestMe0057.jpg"
"C:\Transfer\test\TestMe0058.jpg"
"C:\Transfer\test\TestMe0059.jpg"
"C:\Transfer\test\TestMe0060.jpg"
"C:\Transfer\test\TestMe0061.jpg"
"C:\Transfer\test\TestMe0062.jpg"
"C:\Transfer\test\TestMe0063.jpg"
"C:\Transfer\test\TestMe0064.jpg"
"C:\Transfer\test\TestMe0065.jpg"
"C:\Transfer\test\TestMe0066.jpg"
"C:\Transfer\test\TestMe0067.jpg"
"C:\Transfer\test\TestMe0068.jpg"
"C:\Transfer\test\TestMe0069.jpg"
"C:\Transfer\test\TestMe0070.jpg"
"C:\Transfer\test\TestMe0071.jpg"
"C:\Transfer\test\TestMe0072.jpg"
"C:\Transfer\test\TestMe0073.jpg"
"C:\Transfer\test\TestMe0074.jpg"
"C:\Transfer\test\TestMe0075.jpg"
"C:\Transfer\test\TestMe0076.jpg"
"C:\Transfer\test\TestMe0077.jpg"
"C:\Transfer\test\TestMe0078.jpg"
"C:\Transfer\test\TestMe0079.jpg"
"C:\Transfer\test\TestMe0080.jpg"
"C:\Transfer\test\TestMe0081.jpg"
"C:\Transfer\test\TestMe0082.jpg"
"C:\Transfer\test\TestMe0083.jpg"
"C:\Transfer\test\TestMe0084.jpg"
"C:\Transfer\test\TestMe0085.jpg"
"C:\Transfer\test\TestMe0086.jpg"
"C:\Transfer\test\TestMe0087.jpg"
"C:\Transfer\test\TestMe0088.jpg"
"C:\Transfer\test\TestMe0089.jpg"
"C:\Transfer\test\TestMe0090.jpg"
"C:\Transfer\test\TestMe0091.jpg"
"C:\Transfer\test\TestMe0092.jpg"
"C:\Transfer\test\TestMe0093.jpg"
"C:\Transfer\test\TestMe0094.jpg"
"C:\Transfer\test\TestMe0095.jpg"
"C:\Transfer\test\TestMe0096.jpg"
"C:\Transfer\test\TestMe0097.jpg"
"C:\Transfer\test\TestMe0098.jpg"
"C:\Transfer\test\TestMe0099.jpg"
"C:\Transfer\test\TestMe0100.jpg"
OK
"remove any still we might have rendered"
0
"make sure the frames are in the correct order"
"Sorted files:"
"C:\Transfer\test\TestMe0000.jpg"
"C:\Transfer\test\TestMe0001.jpg"
"C:\Transfer\test\TestMe0002.jpg"
"C:\Transfer\test\TestMe0003.jpg"
"C:\Transfer\test\TestMe0004.jpg"
"C:\Transfer\test\TestMe0005.jpg"
"C:\Transfer\test\TestMe0006.jpg"
"C:\Transfer\test\TestMe0007.jpg"
"C:\Transfer\test\TestMe0008.jpg"
"C:\Transfer\test\TestMe0009.jpg"
"C:\Transfer\test\TestMe0010.jpg"
"C:\Transfer\test\TestMe0011.jpg"
"C:\Transfer\test\TestMe0012.jpg"
"C:\Transfer\test\TestMe0013.jpg"
"C:\Transfer\test\TestMe0014.jpg"
"C:\Transfer\test\TestMe0015.jpg"
"C:\Transfer\test\TestMe0016.jpg"
"C:\Transfer\test\TestMe0017.jpg"
"C:\Transfer\test\TestMe0018.jpg"
"C:\Transfer\test\TestMe0019.jpg"
"C:\Transfer\test\TestMe0020.jpg"
"C:\Transfer\test\TestMe0021.jpg"
"C:\Transfer\test\TestMe0022.jpg"
"C:\Transfer\test\TestMe0023.jpg"
"C:\Transfer\test\TestMe0024.jpg"
"C:\Transfer\test\TestMe0025.jpg"
"C:\Transfer\test\TestMe0026.jpg"
"C:\Transfer\test\TestMe0027.jpg"
"C:\Transfer\test\TestMe0028.jpg"
"C:\Transfer\test\TestMe0029.jpg"
"C:\Transfer\test\TestMe0030.jpg"
"C:\Transfer\test\TestMe0031.jpg"
"C:\Transfer\test\TestMe0032.jpg"
"C:\Transfer\test\TestMe0033.jpg"
"C:\Transfer\test\TestMe0034.jpg"
"C:\Transfer\test\TestMe0035.jpg"
"C:\Transfer\test\TestMe0036.jpg"
"C:\Transfer\test\TestMe0037.jpg"
"C:\Transfer\test\TestMe0038.jpg"
"C:\Transfer\test\TestMe0039.jpg"
"C:\Transfer\test\TestMe0040.jpg"
"C:\Transfer\test\TestMe0041.jpg"
"C:\Transfer\test\TestMe0042.jpg"
"C:\Transfer\test\TestMe0043.jpg"
"C:\Transfer\test\TestMe0044.jpg"
"C:\Transfer\test\TestMe0045.jpg"
"C:\Transfer\test\TestMe0046.jpg"
"C:\Transfer\test\TestMe0047.jpg"
"C:\Transfer\test\TestMe0048.jpg"
"C:\Transfer\test\TestMe0049.jpg"
"C:\Transfer\test\TestMe0050.jpg"
"C:\Transfer\test\TestMe0051.jpg"
"C:\Transfer\test\TestMe0052.jpg"
"C:\Transfer\test\TestMe0053.jpg"
"C:\Transfer\test\TestMe0054.jpg"
"C:\Transfer\test\TestMe0055.jpg"
"C:\Transfer\test\TestMe0056.jpg"
"C:\Transfer\test\TestMe0057.jpg"
"C:\Transfer\test\TestMe0058.jpg"
"C:\Transfer\test\TestMe0059.jpg"
"C:\Transfer\test\TestMe0060.jpg"
"C:\Transfer\test\TestMe0061.jpg"
"C:\Transfer\test\TestMe0062.jpg"
"C:\Transfer\test\TestMe0063.jpg"
"C:\Transfer\test\TestMe0064.jpg"
"C:\Transfer\test\TestMe0065.jpg"
"C:\Transfer\test\TestMe0066.jpg"
"C:\Transfer\test\TestMe0067.jpg"
"C:\Transfer\test\TestMe0068.jpg"
"C:\Transfer\test\TestMe0069.jpg"
"C:\Transfer\test\TestMe0070.jpg"
"C:\Transfer\test\TestMe0071.jpg"
"C:\Transfer\test\TestMe0072.jpg"
"C:\Transfer\test\TestMe0073.jpg"
"C:\Transfer\test\TestMe0074.jpg"
"C:\Transfer\test\TestMe0075.jpg"
"C:\Transfer\test\TestMe0076.jpg"
"C:\Transfer\test\TestMe0077.jpg"
"C:\Transfer\test\TestMe0078.jpg"
"C:\Transfer\test\TestMe0079.jpg"
"C:\Transfer\test\TestMe0080.jpg"
"C:\Transfer\test\TestMe0081.jpg"
"C:\Transfer\test\TestMe0082.jpg"
"C:\Transfer\test\TestMe0083.jpg"
"C:\Transfer\test\TestMe0084.jpg"
"C:\Transfer\test\TestMe0085.jpg"
"C:\Transfer\test\TestMe0086.jpg"
"C:\Transfer\test\TestMe0087.jpg"
"C:\Transfer\test\TestMe0088.jpg"
"C:\Transfer\test\TestMe0089.jpg"
"C:\Transfer\test\TestMe0090.jpg"
"C:\Transfer\test\TestMe0091.jpg"
"C:\Transfer\test\TestMe0092.jpg"
"C:\Transfer\test\TestMe0093.jpg"
"C:\Transfer\test\TestMe0094.jpg"
"C:\Transfer\test\TestMe0095.jpg"
"C:\Transfer\test\TestMe0096.jpg"
"C:\Transfer\test\TestMe0097.jpg"
"C:\Transfer\test\TestMe0098.jpg"
"C:\Transfer\test\TestMe0099.jpg"
"C:\Transfer\test\TestMe0100.jpg"
OK
"Files section done"
"Files section done"
""
""
"create an IFL"
"create an IFL"
"C:\Transfer\test\TestMe.ifl"
"C:\Transfer\test\TestMe.ifl"
"C:\Transfer\test\TestMe.ifl"
<File:C:\Transfer\test\TestMe.ifl>
<File:C:\Transfer\test\TestMe.ifl>
<File:C:\Transfer\test\TestMe.ifl>
"writing filenames to ifl file"
"writing filenames to ifl file"
OK
"closing ifl file"
"closing ifl file"
OK
"IFL section done"
"IFL section done"
""
""
"open the IFL as a bitmap"
"open the IFL as a bitmap"
BitMap:C:\Transfer\test\TestMe.ifl
BitMap:C:\Transfer\test\TestMe.ifl
BitMap:C:\Transfer\test\TestMe.ifl
"IFL opening section done"
"IFL opening section done"
"create an output bitmap"
"create an output bitmap"
** system exception **
undefined
undefined
"create a mov filename"
"create a mov filename"
"C:\Transfer\test\TestMe.mov"
"C:\Transfer\test\TestMe.mov"
"C:\Transfer\test\TestMe.mov"
"delete pre-existing quicktime mov"
"delete pre-existing quicktime mov"
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms; position: 1393
-- Unknown property: "filename" in undefined
"set its name to the mov filename"
"set its name to the mov filename"
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms; position: 1465
-- Unknown property: "filename" in undefined
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms; position: 1491
-- Unknown property: "filename" in undefined
"output bitmap section done"
"output bitmap section done"
"loop through its frames and create the quicktime file"
"loop through its frames and create the quicktime file"
101
101
-- Error occurred in i loop; filename: C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms; position: 1768
-- Frame:
-- i: 0
-- Type error: copy requires BitMap, got: undefined
"loop done"
"loop done"
"close the mov so it is finalized"
"close the mov so it is finalized"
-- Error occurred in anonymous codeblock; filename: C:\Documents and Settings\Mike\Desktop\autoquicktime_debug.ms; position: 2039
-- No ""close"" function for undefined
"quicktime section done"
"quicktime section done"
"open the IFL and the MOV in the RAM Player side-by-side (for quality comparison? who knows)"
"open the IFL and the MOV in the RAM Player side-by-side (for quality comparison? who knows)"

viro
12-04-2008, 11:42 PM
I just got some eroors trying to just save a .mov from ram player. So that might be the problem right there. I am going to try to update quicktime and see if that helps.

ZeBoxx2
12-04-2008, 11:47 PM
huh... I wonder if that's the jpg bitmap copy bug*...

... it's still there in 3ds Max 2009... what on Earth :o

Anyway - try the attached version - v0.03 / v0.03d

* for the curious... have a gander at this marvel:

a = openBitmap (getFiles "c:\\temp\\*.jpg")[1]
BitMap:c:\temp\DSC09834.jpg
b = copy a
** system exception **

c = openBitmap (getFiles "c:\\temp\\*.png")[1]
BitMap:c:\temp\kernels.png
d = copy c
BitMap:

viro
12-05-2008, 12:06 AM
Perfect. Works great. A few hicups with the .jpg files but I did finely get a .mov. I changed formats to .png and nothing but smooth sailing. Since we realy onling use .pngs we should be good. Thanks so much ZeBoxx2

viro
12-08-2008, 05:27 PM
Ok this is working great. I am just trying to edit a section so that I can save the mov to a different directory or the adobe watch folder. The green section is what I have been trying to edit with no luck. I cant seem to track down what script to use to set the new path to \\Tta_server\3d (file://tta_server/3d) model library\AdobeWatch\fliename.mov. I Basically just replaced the green txt below with the previous string with no luck. So would I do that or should I just write copyFile to move the mov to the new location. Neither have worked for me. Any help would be greatly appreciated.

-- create an output bitmap
movBitmap = bitmap iflBitmap.width iflBitmap.height
-- create a mov filename

Original script movName = getFilenamePath rendOutputFilename + getFilenameFile rendOutputFilename + ".mov"

My script movName = \\Tta_server\3d (file://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

viro
12-08-2008, 07:41 PM
Ok I have had some luck using this to save the mov. But I keep getting errors now. It worked once but it hasent worked sence then.

movName = getFilenamePath " \\\\Tta_server\3d (http://forums.cgsociety.org/) model library\AdobeWatch\ " + getFilenameFile rendOutputFilename + ".mov"

viro
12-08-2008, 08:01 PM
Ok no errors in the script now but I am getting a dialog that pops up and says error opening the mov and then one right after thats says error creating.

I am wondering if there is somthing I need to do becuse it is on the network.

viro
12-11-2008, 06:26 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

ZeBoxx2
12-11-2008, 06:46 PM
cool - glad you got it working :)

Note that you can remove the 'display' line, or wrap it in 'if (isnetserver()) then ( ... )', as otherwise I think the rendernodes will pop up the VFB showing the images.. something you'd typically not want on a node :) (doesn't do any harm, other than freak out sysadmins)

viro
12-15-2008, 02:38 PM
Yea I do comment out the display section when I use the netrendering.

I am having a new problem now though. It seems the first node to finish there assigned tasks runs the script and I need it to be the last node to run it or I need them to make sure the job is finished first. I am thinking that finding the number of frames to be rendered and then checking to makes sure they are all done before running the script might work. I am also trying some netrendering stuff to check to see if the job is complete before running. But I am having a hard time getting exactly what I want from either of them. Then nedrendering stuff only brings back an array finished jobs not the job that was submitted. And as for the frame numbers I cant seem to find a way to pull that number out and then check to see if there are that many frames. Anywone have any suggestions or ideas?

ZeBoxx2
12-15-2008, 02:52 PM
Yeah, figured you might run into that... your best bet is probably to submit another job that runs the script when the original job is done. Unfortunately, you can't easily set dependencies of one job or another via scripting. You can if you install third party external functionality, such as Python used in this thread:
http://forums.cgsociety.org/showthread.php?f=98&t=692735&highlight=dependency
Edit: err for existing jobs, anyway - for new jobs, you can submit it -with- the depencies using the command line utility

Alternatively, you could set it up by checking, after each rendered frame, whether all frames are present in the output folder.. and only continue if all frames are indeed present. There's a very, very small chance that a machine is actually in the process of writing out a frame, and an even smaller chance still that you would hit that frame in the quicktime generation in the middle of that process... but a sleep() might be a reasonable safeguard.

viro
12-15-2008, 08:19 PM
Here what I have come up with thanks to your link to another thread. The only issue I am having is attaching the script to the dependant job.

-- Created: 13-10-2008
-- Last Updated: 13-11-2008
-- Version: 0.14
--
-- Author : Johan Boekhoven / johan.boekhoven [at] gmail [dot] com / subd.nl
-- Version: 3ds max 2009 (11)
--
-- Discription: Submits scene to backburner
-- Usage: Just run to submit
--
-- Credits: Helpfile / cgtalk
--
--************************************************** *********************************************
-- MODIFY THIS AT YOUR OWN RISK
(
/* 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

-- Will be used in the mxs submit and dosCommand dependencies!
x = 1
jobName = (filterString maxFileName "." )[1] --+ execute "x += 1" as string

/* 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 */
scriptJobName1 = jobName + "_UncompressedMov"

/* OUTPUT1 - UNCOMPRESSED MOV */
-- 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 the render script
format "-scriptFile:\\\\Tta_server\\3d model library\\Scripts\\AutoQuickTIme\\autoquicktimeNetwork.ms " to:jobString1
print jobString1

-- cmdJob is in the backburner folder
maxRoot = "C:\\Program Files\\backburner 2\\"
-- Build command string
cmd = "cmdjob.exe " + (jobString1 as string) + " startpath:" + maxroot + " prompt:Submitted to backburner via commandprompt"
print cmd

-- Execute it
DOSCommand cmd

)
)

It seems like it should work becuse when it prints it looks good. I must be writing the -scriptfile section wrong.

viro
12-15-2008, 11:19 PM
on further thought I decided to go with the seep() option you mentioned. I will have wait and test it to know for sure though.

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

viro
12-17-2008, 12:13 AM
Wrong again. works great with one node on the farm but it still does nothing if there are more nodes. Any ideas? I am also trying some job submission with dependancies but cant get the script to attach to the dependancy.

/*get the number of frames to be rendered*/
--check to see what the time output is set to
reTime = rendTimeType
--if it is set to animation rage then get the number of frames
if (reTime == 3 ) then (
st = rendStart
en = rendEnd
numFrames = (en - st)
s1 = "0" + numFrames as string
s2 = "f"
s3 = ""
FrameNum = substituteString s1 s2 s3
)
--if it is set to active time segment then get the number of frames
else if (reTime == 2 ) then (
animS = animationRange.start
animE = animationRange.end
numFrames = (animE - animS)
s1 = "0" + numFrames as string
s2 = "f"
s3 = ""
FrameNum = substituteString s1 s2 s3
)

-- Get the files rendered
FileLoc = getFiles ((getFilenamePath rendOutputFilename) + (getFilenameFile rendOutputFilename) + "*" + (getFilenameType rendOutputFilename))
--get the amount of files done and convert it to a number minus one
FramesDone = FileLoc.count as integer - 1
NewFrameNum = FrameNum as integer

if (FramesDone == NewFrameNum) then (
--pause for 1 minute to make sure all the frames are done
sleep 60
--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
-- save out the mov bitmap (appends as new frame)
save movBitmap frame:i
)

-- close the mov so it is finalized
close movBitmap
)

viro
12-17-2008, 12:20 AM
Here is what I have for submiting a job and adding the dependancy. I got most of this code from another thread it was written by Johan Boekhoven / johan.boekhoven [at] gmail [dot] com / subd.nl


(
/* 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

-- 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 */

scriptJobName1 = jobName + "_UncompressedMov"

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

--attach the script pretty sure this is the wrong way to do this
files = getFiles "\\\\Tta_server\\3d model library\\Scripts\\AutoQuickTIme\\autoquicktimeFinale121608.ms"
for file in files do fileIn file

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

-- This is probably wrong since cmdJob is in the backburner folder, but it works.... I should check that out!
maxRoot = "C:\\Program Files\\Autodesk\\backburner\\jobs\\"

-- Build command string
cmd = "cmdjob.exe " + (jobString1 as string) + " startpath:" + maxroot + " prompt:Submitted to backburner via commandprompt"

-- Execute it
DOSCommand cmd

)
)

RobGalanakis
12-17-2008, 12:33 AM
I haven't read the thread so feel free to pay no attention if I'm way off base. Can't you just render frames to an uncompressed AVI and then use a command-line encoder (Mencoder or ffmpeg) to convert to a .mov/.mp4 file? Then again I haven't taken the time to read the thread to get context on what you have to do, but I thought I'd just throw that out there.

ZeBoxx2
12-17-2008, 02:57 AM
yes he could - which would take the minor part of loading the images and saving to quicktime, via script, out of the equation :)

viro
12-17-2008, 02:13 PM
That depends. We need to render through our render farm which has multiple nodes so I belive the only way to do this is to render an image sequence first. Unless I am mistken that is.


I also dont need .mov if I could get an uncompressed .avi that would be fine. I just need a file format that adobe media encoder can read.

The end result here is just to automate the process of convert image sequences to .flv files. Which is what all are work needs to be at the end of our pipline. So if there is a command line encoder that could do that I would need to write this script anymore. I know adobe has a solution for this but it is around $6,000. and my company is pretty small so I am just rying to find a workaround and save all the man hours we spend setting at our computers using photoshop to encode .flv's.

RobGalanakis
12-17-2008, 02:22 PM
Writing frames to an uncompressed avi is really easy, actually. You just need to render frames, and this is what I do:


fn createSequence animBmpFilename bmpArr width height =
(
local animBmp = bitmap width height filename:animBmpFilename
for i = 1 to bmpArr.count do
(
copy (openBitmap bmpArr[i]) animBmp
save animBmp frame:i
)
close animBmp
)


There's probably a way to get the width and height from the file without having to pass them in. animBmpFilename is something like "C:\\tempComp.avi" and bmpArr is an array of bitmap filenames. Make sure you have the save <bitmap> frame:<integer> in there or you will run into memory issues.

viro
12-17-2008, 02:25 PM
And you use this as a post render script with netrendering?

RobGalanakis
12-17-2008, 02:34 PM
No, I run this in my rendering utility (basically a wrapper and auto-setup for useful animation rendering things) after I render out frames and composite them together (can render from multiple views). We don't do any post or net rendering (we are in games). But I think the idea would be the same?

viro
12-17-2008, 02:35 PM
I will give it a try. Thanks

viro
12-22-2008, 06:18 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

)
)

CGTalk Moderation
12-22-2008, 06:18 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.