Skip to content

Command-line rendering

When your scene becomes more complex the rendering becomes more time consuming. Then you want to have more control over where and when you render your shots. You also might want to render on another more powerful machine. In those cases you want to know how to run Blender from the command-line in a terminal. Lets see how easy you can achieve this.

Starting Blender from the console

In order to use Blender from the console, you need to know where to find the executable. Depending on the operating system you're working on the location can differ:

OS Executable name Location (default)
Windows blender.exe C:\Program Files\Blender Foundation\Blender
macOS Blender /Applications/Blender.app/Contents/MacOS/Blender
Linux blender /usr/bin/blender

Tip

Note that the executable location might be on the PATH, so you can just call the executable itself, without specifying the full path.

The general format format for calling Blender from the command-line (with blender being the executable from above) is

blender [args ...] [file] [args ...]

So if you wanted to start Blender and open a file in one step you would call

blender myfile.blend

Executing Blender without GUI

In a lot of cases when you're using Blender from the command-line, such as rendering a frame to an image file, you do not want use the graphical user interface. For this you can use the -b option:

blender -b myfile.blend [...]

This command simply opens Blender and quits it right away, because it runs in the background with nothing to do:

$ blender -b myfile.blend 
Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Read prefs: "/home/melis/.config/blender/4.1/config/userpref.blend"
Read blend: "/tmp/myfile.blend"

Blender quit

Rendering a frame (or more)

If we add, say -f 1, we ask Blender to render the first frame and save it to disk:

$ blender -b myfile.blend -f 1
Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Read prefs: "/home/melis/.config/blender/4.1/config/userpref.blend"
Read blend: "/tmp/myfile.blend"
Fra:1 Mem:43.56M (Peak 44.63M) | Time:00:00.10 | Syncing Cube
Fra:1 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Syncing Light
Fra:1 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Syncing Camera
Fra:1 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Rendering 1 / 64 samples
Fra:1 Mem:43.61M (Peak 44.63M) | Time:00:00.15 | Rendering 26 / 64 samples
Fra:1 Mem:43.61M (Peak 44.63M) | Time:00:00.18 | Rendering 51 / 64 samples
Fra:1 Mem:43.61M (Peak 44.63M) | Time:00:00.19 | Rendering 64 / 64 samples
Saved: '/tmp/0001.png'
Time: 00:00.48 (Saving: 00:00.27)


Blender quit

We can render a range of frames with -f <first>..<last>, or specific frames with -f <i>,<j>,<k>,....

Arguments are executed in order given

It is important to know that any arguments provided (either before or after the filename) are executed in the order given. Take this command, for example:

$ blender -b myfile.blend -f 10 -o frame.png
Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Read prefs: "/home/melis/.config/blender/4.1/config/userpref.blend"
Read blend: "/tmp/myfile.blend"
Fra:10 Mem:43.56M (Peak 44.63M) | Time:00:00.10 | Syncing Cube
Fra:10 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Syncing Light
Fra:10 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Syncing Camera
Fra:10 Mem:43.60M (Peak 44.63M) | Time:00:00.11 | Rendering 1 / 64 samples
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.14 | Rendering 26 / 64 samples
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.17 | Rendering 51 / 64 samples
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.19 | Rendering 64 / 64 samples
Saved: '/tmp/0010.png'
Time: 00:00.47 (Saving: 00:00.27)


Blender quit

This starts Blender in background mode (-b), opens myfile.blend, renders frame 10 (-f 10)... and then sets the output file name to frame.png using -o. But because the -f comes before the -o, the output of the render is written to the output location set in the Output Properties in the blend file, not what is specified by -f.

On the other hand, when -o comes before -f the command more or less does what you expect and probably want:

$ blender -b myfile.blend -o frame.png -f 10
...
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.19 | Rendering 64 / 64 samples
Saved: 'frame.png0010.png'
...

However, notice the output file name is frame.png0010.png, which is not the frame.png we specified. This is due to the output file set with -o actually being a template, not a real file name. When rendering a frame the frame number is filled in in the template to determine the actual output file name. We can use # markers in the template to fix this:

$ blender -b myfile.blend -o frame####.png -f 10
...
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.18 | Rendering 64 / 64 samples
Saved: 'frame0010.png'
...

Another useful element in the template is //. This is replaced with the path of the current Blender file, so it provides an easy way to render frames to the same directory as the Blender file (or a sub-directory). For example:

$ blender -b myfile.blend -o //frames/ -f 10
...
Fra:10 Mem:43.61M (Peak 44.63M) | Time:00:00.17 | Rendering 64 / 64 samples
Saved: '/tmp/frames/0010.png'

Rendering an animation

You can render an animation in a Blender file using -a and set start and end frames to render with -s and -e. For example:

blender -b my_animation.blend -s 5 -e 35 -a

This will render the animation, in the background, from frame 5 to 35 and output the images to the output specified in the blend file.

Figuring out more commands

There are many more command-line options, which can be listed with blender --help. For example, there are options to run Python scripts, switch Blender scenes, set the output image format, or choose the render engine.

You can also read more on rendering using the command-line on this page in the official Blender documentation.


Last update: 28 August 2024 15:59:43