Skip to Content

Multi-Server Animation Rendering

This guide explains how to render an animation of 100 frames using two servers. Each server is responsible for 50 frames. The server index is provided by the environment variable BC_SERVER_INDEX, which determines the frame range each server will process.

Example Files

Core Script

The following Python script uses Blender’s bpy module to set the correct frame range for rendering based on the server index.

import bpy import os def render_animation(): # Retrieve the output folder from environment variable output_folder = os.getenv('BC_OUTPUT_FOLDER', '/default/output/path') # Total frames for the animation and frames per server total_frames = 100 frames_per_server = 50 # Get server index (0 or 1) server_index = int(os.getenv('BC_SERVER_INDEX', 0)) # Calculate start and end frames based on server index start_frame = server_index * frames_per_server + 1 end_frame = start_frame + frames_per_server - 1 print(f"Server {server_index}: Rendering frames {start_frame} to {end_frame}") # Set the frame range for the scene scene = bpy.context.scene scene.frame_start = start_frame scene.frame_end = end_frame # Set output path using frame number formatting scene.render.filepath = os.path.join(output_folder, "frame_####.png") # Render the animation for the assigned frame range bpy.ops.render.render(animation=True) if __name__ == "__main__": render_animation()

Key Concepts Explained

1. Splitting the Animation Frames

server_index = int(os.getenv('BC_SERVER_INDEX', 0)) frames_per_server = 50 start_frame = server_index * frames_per_server + 1 end_frame = start_frame + frames_per_server - 1

Each server uses its index (0 or 1) to determine its assigned frame range. For example:

  • Server 0: Renders frames 1 to 50.
  • Server 1: Renders frames 51 to 100.

2. Setting the Frame Range

scene.frame_start = start_frame scene.frame_end = end_frame

This configures the Blender scene to render only the assigned frames.

3. Output Path Configuration

scene.render.filepath = os.path.join(output_folder, "frame_####.png")

Using the BC_OUTPUT_FOLDER environment variable, this line sets the destination for the rendered frames, with the frame number automatically appended.

4. Render Execution

bpy.ops.render.render(animation=True)

This command starts rendering the animation for the defined frame range.

Environment Variables

VariableDescriptionExample Usage
BC_OUTPUT_FOLDERDirectory where rendered images will be saved.scene.render.filepath = os.path.join(os.getenv('BC_OUTPUT_FOLDER'), "frame_####.png")
BC_SERVER_INDEXIndex of the current server (0 for the first server, 1 for the second server).Used to calculate the frame range: server 0 renders frames 1–50, server 1 renders frames 51–100.

Usage Steps

Upload Script

Test Script

  • Click on script name to access detail view
  • Click Test Script to run a test render
  • Verify that the correct frame range is processed based on the server index.
  • If successful, proceed to job configuration

Configure Job

  • Navigate to New Render
  • Upload your .blend file (or a .zip containing the .blend and assets).
  • Select multi_server_animation.py from the script dropdown.
  • Ensure you set up 2 servers, BC_SERVER_INDEX is set automatically.

Launch Render

Expected Output

# BC_OUTPUT_FOLDER: /app/bc_output/ /app/bc_output/ ├── frame_0001.png ├── frame_0002.png ├── ... (frames 1-50 from Server 0 or frames 51-100 from Server 1)

This simple multi-server setup distributes the rendering task for a 100-frame animation evenly across two servers, reducing overall processing time.

Last updated on