0
$\begingroup$

When I render via Blender, after rendering it's very easy for me to choose a different format and save it as that. Therefore I can get both Open EXR and PNG.

However, when rendering an animation, say via the command line, the entire reason I'm doing it on the command line is I'm using cloud compute.

I'd like to save time + money and not have to re-render the same animation in a different format. Is there a way to specify 2 formats without having to re-render? Maybe via a Python script or the command line?

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Yes you can do that using the Compositor where you can specify multiple File Output Nodes. You can use this script which automatically creates this setup and renders the outputs to the path specified in the OUTPUT_PATH variable. You can also append more types in the OUTPUTS list variable within the script.

enter image description here

Just copy the script and paste in Text Editor and run script or save it as .py file and execute it in the command line or terminal.

import bpy

OUTPUT_PATH = "/path/to/output/directory/"
FILENAME = "my_file_name"
OUTPUTS = ['PNG','OPEN_EXR']

scene = bpy.context.scene
scene.render.use_compositing = True
scene.use_nodes = True
scene.render.filepath = OUTPUT_PATH + FILENAME

tree = scene.node_tree

def clear_nodes():
    for node in tree.nodes:
        tree.nodes.remove(node)

def create_output_node(name, render_node, location, type):
    node = tree.nodes.new(type='CompositorNodeOutputFile')
    node.name = name
    node.base_path = OUTPUT_PATH
    node.location = location
    node.format.file_format = type
    node.file_slots[0].path = FILENAME
    link = tree.links.new(render_node.outputs[0], node.inputs[0])

def create_nodes():
    clear_nodes()
    comp_node = tree.nodes.new('CompositorNodeComposite')
    comp_node.location = 300,200
    render_node = tree.nodes.new('CompositorNodeRLayers')
    render_node.location = 0,0
    link = tree.links.new(render_node.outputs[0], comp_node.inputs[0])

    for i, type in enumerate(OUTPUTS):
        create_output_node("output_" + type, render_node, (300,-i*150), type)

create_nodes()

#bpy.ops.render.render() #render single image
bpy.ops.render.render(animation=True, use_viewport=True)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .