frame by frame command line rendering

david | mentalray,rendering,tutorials | Wednesday, February 17th, 2010

If you don't have access to a render manager, or even if you do, you might want to render from the command line one frame at a time. There are a few reasons why you may want to do this. Sometimes maya does not get to the end of a long batch render due to memory errors. You set off a 100 batch and it dies after frame 27 maybe. Another reason is that sometimes your animation does not seem to work in a batch render. A single frame renders correctly, but when you batch it some things don't update correctly.

Command line renders are a good idea since you consume less system resources if you do not have the maya GUI running. When I'm launching a command line render I like to put the command in a .bat file so that I can reuse it for other renders without needing to remember all the render flags and paths.

If you open a cmd-prompt and type "render -help" or "render -r mr -help" (both without the quotes) then you'll get a list of all the possible render flags and their meanings. So a simple example of a render command would be (all on one line)

render -r mr -rt 4 -v 4 -s 1 -e 50 -proj x:\projectX -rd k:\renders x:\projectX\scenes\anims

If you enter that, then you'll get a mentalray render that starts at frame 1, ends at frame 50, displays warning messages and uses the project path "x:\projectX" and renders the images to "k:\renders".

Thats exactly what I need, except that I want to do it one frame at a time. Well, you could do that by duplicating this line and changing the start and end frame on each new line, because a .bat file just executes one line at a time. But that would be a very messy way to render more than a few frames.

After a bit of research I found that you can use a scripting language in a .bat file and create a mini program that will loop through the frames you want.

Here's the script I came up with

echo off
rem ----------------------------------------------------

rem usage: renderbatch.bat sceneName startFrame endFrame

rem ----------------------------------------------------

rem Change the next 3 lines to suit your project

SET PROJ=T:\Jobs\projectX\maya
SET RD=%PROJ%\renders
SET SCNPATH=%PROJ%\scenes\anims

rem ----------------------------------------------------

SET FS=%2%
SET FE=%3%

FOR /L %%F IN (%FS%,1,%FE%) DO (
render -r mr -rt 4 -v 4 -s %%F -e %%F -proj "%PROJ%" -rd "%RD%" "%SCNPATH%\%SCN%.mb"

Cut and paste that into a new text file and save it to something like renderbatch.bat (the name is not important, but it has to end with .bat)

This is a file I can reuse by editing three lines near the start, which set my project, renders and scene paths.  Then to launch a render I type the following in the cmd-prompt

renderbatch.bat animationTest1 1 100

This renders a scene file called animationTest1.mb from frame 1 to 100, one frame at a time.


  1. Hi. I'm in the middle of rendering out a bunch of scenes so your script is very useful =)
    I'm wondering though, Is it possible to create a queue of all scenes so I don't have to wait for one to finish?

    Comment by Dag — May 25, 2010 @ 5:07 am

  2. This answer probably comes way too late. Maybe you figured it out anyway.
    All you need to do is create a 2nd .bat file and add one command per line.

    For example create a file called renderQueue.bat containing the lines

    renderbatch.bat shot_01_tk007 1 100
    renderbatch.bat shot_02_tk002 29 75
    renderbatch.bat shot_02_tk001 10 90

    Then simply run renderQueue.bat from the command prompt.

    Comment by david — June 13, 2010 @ 12:55 am

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck