Sub topic 13
Rendering from the command line
This chapter covers running Blender without its interface to render stills and animations. It assumes you can open a terminal, know where your blender executable lives, and have already set up a scene with a camera, engine, and output settings as covered in earlier chapters.
Why render from the command line
Command-line rendering runs Blender in background mode. No window opens, so the render uses less memory and can run on a server, in a script, or overnight over SSH. It also lets you override a few settings without opening the file.
The command line does not replace the Output properties. Blender loads the .blend file first, so the saved engine, resolution, frame range, and camera still apply. The options you pass override only the settings they name.
Making the command available
On Linux, blender is usually on your PATH after a package install. On Windows and macOS you normally call the full path to the executable.
# Linux, if blender is on PATH
blender --version
# macOS
/Applications/Blender.app/Contents/MacOS/Blender --version
# Windows (Command Prompt)
"C:\Program Files\Blender Foundation\Blender 4.2\blender.exe" --versionThe version number in the Windows path depends on what you installed. Adjust it to match.
The core options
These are the options you will use in almost every render.
| Option | Long form | Meaning |
|---|---|---|
| `-b` | `--background` | Run without the interface |
| `-o` | `--render-output` | Output path and filename pattern |
| `-F` | `--render-format` | Image or video format, such as `PNG` or `OPEN_EXR` |
| `-x` | `--use-extension` | `1` adds the file extension, `0` leaves it off |
| `-s` | `--frame-start` | First frame of the range |
| `-e` | `--frame-end` | Last frame of the range |
| `-f` | `--render-frame` | Render one frame and exit |
| `-a` | `--render-anim` | Render the whole frame range |
| `-E` | `--engine` | Render engine, such as `CYCLES` or `BLENDER_EEVEE_NEXT` |
Engine identifiers change between Blender versions. EEVEE is BLENDER_EEVEE in older releases and BLENDER_EEVEE_NEXT from 4.2. Run blender -E help to list the names your build accepts.
Rendering a still image
This command renders frame 1 of scene.blend and saves it as a PNG.
blender -b scene.blend -o //renders/still_#### -F PNG -x 1 -f 1Each part does the following:
-bturns off the interface.scene.blendis the file to load. It must come right after-bor earlier, because Blender needs to know which file the following options apply to.-o //renders/still_####sets the output path. The//prefix means "relative to the.blendfile", so the images land in arendersfolder beside the scene. The####becomes a zero-padded frame number, so frame 1 is written asstill_0001.-F PNGselects the file format.-x 1adds the.pngextension to the name.-f 1renders frame 1 and then exits.
The result is renders/still_0001.png.
Rendering an animation as an image sequence
For an animation, use -a instead of -f and set the range with -s and -e.
blender -b scene.blend -o //renders/frame_#### -F PNG -x 1 -s 1 -e 48 -aThis renders frames 1 to 48 and writes frame_0001.png through frame_0048.png. Without -s and -e, Blender uses the frame range stored in the file.
Two details are worth knowing.
First, the number of # characters sets the padding width. #### gives four digits. If you leave out the # characters, Blender appends a four-digit frame number to the name for you. Using more # characters than your highest frame number needs is harmless. Using fewer, such as ## for frame 120, simply prints the full number, so frame_120. File sorting then breaks, because frame_100 sorts before frame_20.
Second, -f takes a frame number and -a takes none. You can pass -f more than once to render several frames, as in -f 1 -f 10 -f 25.
Rendering straight to video
You can pass a video format to -F as well. FFMPEG encodes the frames into a single file. The container, codec, and quality come from the settings saved in the .blend file, because there are no command-line flags for them.
blender -b scene.blend -o //renders/clip_ -F FFMPEG -x 1 -s 1 -e 120 -aThis writes a single file such as clip_0001-0120.mp4. Blender builds the name from the start and end frames. Set the encoding options in the Output properties first, or use a script to set them, as the next chapter covers.
If an animation can fail partway, an image sequence is safer than a video. A crash during a video render leaves a damaged or missing file. A crash during a sequence leaves every finished frame on disk, and you can resume from where it stopped.
Resuming and avoiding overwrites
By default, Blender overwrites existing files. That is convenient for re-runs and dangerous when the output folder holds work you want to keep. The Output properties include an Overwrite checkbox and a Placeholders checkbox. With Overwrite off, Blender skips frames whose files already exist. With Placeholders on, it creates an empty file for each frame before rendering it. That lets several Blender processes share one folder without both rendering the same frame.
To resume a render that stopped at frame 73, you can restart at that frame:
blender -b scene.blend -o //renders/frame_#### -F PNG -x 1 -s 73 -e 240 -aDo this only if the earlier frames are complete. A frame that was being written when the crash happened may be damaged, so it is safer to start a few frames earlier.
Overriding settings without editing the file
The -E option picks the engine for one run. Blender also runs Python expressions or scripts with --python-expr and --python. These are useful when a setting has no dedicated flag, such as the sample count.
blender -b scene.blend -E CYCLES --python-expr "import bpy; bpy.context.scene.cycles.samples = 64" -o //renders/draft_#### -F PNG -x 1 -f 1The expression runs after the file loads and before the render starts, because it appears before -f. A quick draft at 64 samples therefore does not touch the saved value of 128 or whatever the file contains. The file on disk stays unchanged unless you save it.
Choosing a device and watching progress
Cycles can render on a GPU, but the device is a Preferences setting, not a scene setting. For headless machines, pass the device type after a double dash. Blender reserves everything after -- for the Cycles arguments:
blender -b scene.blend -o //renders/gpu_#### -F PNG -x 1 -f 1 -- --cycles-device CUDAUse OPTIX, HIP, METAL, or ONEAPI depending on your hardware. The console prints a line per frame with the elapsed time and, for Cycles, per-sample progress. Redirect it to a log file so you can read it afterward:
blender -b scene.blend -o //renders/frame_#### -F PNG -x 1 -s 1 -e 48 -a > render.log 2>&1Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| Output lands in `/tmp` or the wrong folder | A relative path without `//` | Use `//renders/...` or an absolute path |
| Settings you passed have no effect | Options come after `-f` or `-a` | Move them before the render option |
| Files named `frame_0001.png.png` | Extension already in the path and `-x 1` set | Drop the extension from `-o` |
| Only one frame renders | `-f` used instead of `-a` | Use `-a` with `-s` and `-e` |
| Render finishes instantly with no files | The file path to the `.blend` is wrong, or the scene has no camera | Check the console output for errors |
| Blender complains about the engine name | Name differs between versions | Run `blender -E help` |
Exercise
You run blender -b scene.blend -f 1 -o //out/shot_####. Blender renders frame 1, but the image does not appear in out. Why, and how do you fix the command?
Show answer
Blender reads arguments left to right, and -f 1 triggers the render before -o is read. The output path was still the one saved in the file. Put -o //out/shot_#### before -f 1, as in blender -b scene.blend -o //out/shot_#### -F PNG -x 1 -f 1.
Exercise
Write a command that renders frames 10 to 30 of scene.blend as a numbered PNG sequence into a renders folder beside the file, with names like take_0010.png.
Show answer
blender -b scene.blend -o //renders/take_#### -F PNG -x 1 -s 10 -e 30 -a