Rendering from the command line in Blender: Part 2 – down the rabbit hole

I recently wrote a tutorial about the basics of command line rendering in Blender. If you haven’t read it, check it out here.

There I explained why using the command line is a good idea. I also gave you the most basic command that you’ll likely use 80%+ of the time.

c:\>blender -b file.blend -a

(The previous article explains what that means).

In this part I want to go just a bit deeper into what’s possible using cmd.exe.

Before that I’ll mention a few things that came up in comments related to the Part 1.

Some people noted that rendering from the command line makes their renders slightly… slower (about -5% or so). Technically this doesn’t make sense. But I’ve seen this complaint often enough to believe it. So do your own tests and find out if rendering performance from cmd.exe is better, same or worse. The improved stability seems to be undisputed tho. To me that will often justify a (potential, small) performance hit.

I also learned about two Blender addons that help you render from the command line without the hassle of writing commands by hand. I have not used those. I include the links without a recommendation or comments:

https://blendermarket.com/products/b-renderon ($8)

https://github.com/RayMairlot/Batch-Render-Tools (for Blender 2.79, Free)

Alright back to writing commands.

Setting up Beginning and End of Frame Range

One thing I need from time to time is to set the beginning and end of my “active frame range” (the range of frame that will be rendered). I want to do so without opening blender and messing with the interface. Our trusty basic command will change only slightly:

c:\>blender -b file.blend -s XXX -e YYY -a

So we inserted “-s XXX -e YYY” between the .blend file and -a. As I mentioned in part 1 the order in which you write the command is important. Do not change it.

Let’s explore the new commands:

  • -s : stands for Start. That’s the first frame of your “frame range”
  • XXX : replace that with an actual number. If you want your render to start at frame 54, type “54”
  • -e : stands for End. That’s the last frame of your “frame range”
  • YYY : replace that with an actual number. If you want your render to end at frame 102, type “102”

So a realistic command would read something like:

C:>C:\Program Files\Blender\blender.exe -b C:\MyProject\scene.blend -s 54 -e 102 -a

This will render your scene.blend exactly the way you’ve set it up. It will only change the range of frames to be rendered.

Here is one more time-saving workflow that I use often.

Using batch (.bat) files to render several files in a row

Let’s say you have to render a couple of scenes. Each of them is not too render-heavy. You want to tell blender to render them one by one and go to sleep (I mean you want to go to sleep, not Blender).

You can do that with a batch (.bat) file. This is how to do it under Windows. I am certain the same can be achieved under Linux/Mac but the steps to get there will be slightly different (and I don’t know them).

In Windows open up and standard Notepad and simply type a command for each file you want to render. Separate them by pressing Enter after each one. The list will look something like this:

In Notepad click File > Save as… and give it a filename like “render.bat”. To be clear, you give it a .bat extension even though Notepad normally saves .txt files.

(Depending on your Windows settings, you may get warnings, errors etc. I can’t think of every possible Windows setting here but if you encounter a problem, let me know in the comments. I’ll do my best to help you solve it.)

Go to where you saved your .bat file. Double click it. Go to sleep*.
*make sure you triple check the settings of each file so you can sleep peacefully. Also make sure the commands are written correctly.

Bonus trick: Rendering several .blend files simultaneously.

I wouldn’t recommend doing this in most cases. But when you have to render several lightweight files, you can just open two or more instances of cmd.exe, write a render command and hit Enter in each one. Or you can create two or more .bat files and start them simultaneously. As I said it’s not something you’d normally do but I do find it beneficial on rare occasions.

This pretty much sums up all the ways I use the command line. As you can see it’s very simple to use. And it can be a life saver.

If you really want to go deep into all the options available for command line rendering, check out this page of the Blender manual: https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html

I hope this information helps optimize your renders.

Happy cmd-ing!

Leave a Comment

Your email address will not be published. Required fields are marked *