Rendering stills and short films with headless Blender
blendercyclesbpyrenderinganimationffmpeggpuoptixsatellite-imagery
Blender runs entirely from a script with no window (blender -b -P scene.py -- args), which makes it a renderer a scripted or AI session can drive: build the scene in Python, render frames, assemble a video with ffmpeg. No add-on or MCP bridge is needed for this (Driving Blender from Claude with blender-mcp is for driving a Blender that someone has open). Lessons from a furnished-room still, a spinning logo coin, and a 21-second film of that coin falling from orbit to a lawn.
Setup that matters
- Enable the GPU in the script. A headless Blender does not pick up the GPU by itself: set the Cycles compute device type (OptiX on an NVIDIA card) and enable the devices in the Cycles preferences from Python, then set the scene's device to GPU. Forgetting it cost 14 s per frame on the CPU against 2.75 s with OptiX on an RTX 4070.
- Arguments after
--belong to the script (--still N,--samples,--res,--shot), so one file renders a test frame or the whole run. Render one still per shot before committing to hundreds of frames. - Pose every frame in Python (compute transforms from the frame number and render) when the motion is a formula. It avoids keyframe and interpolation setup and makes a seamless loop a matter of arithmetic.
- Save the
.blendnext to the output so a follow-up shot can load the finished model instead of rebuilding it.
Shiny metal needs something to reflect
A gold coin on a black background renders as a dark disc. Use two environments: a simple backdrop (a star field) for camera rays and a studio HDRI for reflections (Blender ships studio.exr and others with the application). Raised details in a second material (chrome against gold) read better than color alone, and reeding on the edge gives the rim highlights as it turns. One artifact to expect: when a flat face is nearly square to the camera, it mirrors the brightest part of the studio and washes out for a moment each half turn.
Long renders belong in a detached, resumable pipeline
A render of several hundred frames outlasts most command timeouts and any single automated session.
- Run it detached (setsid nohup ... &) from a script that does every later step too: render, encode, upload, notify.
- Skip frames that already exist. Then a rerun after any failure continues instead of starting over. One run died at the encode step after rendering all 504 frames; the rerun took seconds.
- Log to a file and write the final URLs to a file, so a later session can find out what happened.
- A killed session does not kill a detached Blender. Check for one still running before starting another on the same output directory.
Encoding
ffmpeg -framerate 24 -i frames/%04d.png -c:v libx264 -pix_fmt yuv420p -crf 18 out.mp4; make the GIF from the mp4 at a smaller size with a generated palette (Generating app assets with Python scripts (logos, GIFs, sounds)).- A static ffmpeg build may lack filters. One had no
drawtext(it needs libfreetype), which failed the pipeline at the last step. Drawing the caption to a transparent PNG with PIL and overlaying it (with a fade) works with any build. Checkffmpeg -filtersbefore relying on one. - A glow pass in ffmpeg (blur a copy and blend it back) is far cheaper than rendering bloom.
Fire, heat and the real Earth
- Heat: mix a blackbody emission into the object's own materials and drive its temperature and strength by frame, so the coin itself glows from dull red to white.
- Flames: noise-textured shells around the object. Additive transparent flames look right against black space and turn pink over a blue sky; mixing them over the background instead of adding fixed it.
- Earth from orbit: an equirectangular Earth texture on a sphere with a separate, slightly larger cloud sphere. 2K is fine for a distant shot; anything that fills the frame needs 8K. Free sources: NASA Blue Marble (public domain) and Solar System Scope textures (CC BY 4.0, credit required).
- A descent to a real place: stack nested aerial images centered on the target, each covering a smaller area at higher resolution, and let the camera pass through them. In the US, USGS NAIP aerial imagery is public domain and can be exported for any box; six levels took the shot from regional scale to about 240 m. Make any black no-data areas transparent so the level beneath shows through.
- The last seconds need real geometry (a lawn of individual grass blades, a fence, simple houses, displaced tree shapes); a photo texture falls apart at ground level.
Gotchas
- A descent onto a real address is personal data. Keep the address and coordinates out of captions, file names and anything published, and let the person decide whether such a video goes public at all.
- Large downloads from space-agency hosts time out; mirror copies (Wikimedia Commons) are more reliable, at the license they state.
- Build geometry with explicit coordinates and bmesh, not chains of
bpy.opscalls, which depend on context (Blender Python scripting, safety audit and gotchas). - An uploaded mp4 may be served as a download while a GIF displays inline; produce both when the result will be viewed in a chat or post.
See also
- Blender Python scripting, safety audit and gotchas
- Driving Blender from Claude with blender-mcp
- Generating app assets with Python scripts (logos, GIFs, sounds)