7
$\begingroup$

Id like to be able to use markers to render multiple video files. This would be handy when binding markers to camera switches so each camera gets its own video file, is this possible?


Had a request for this, thought it worth making an SE question

$\endgroup$

1 Answer 1

8
$\begingroup$

This isn't possible out-of the box, but it can be done with a script:

This isn't an addon, just paste the script into the text editor and run it, you may want to change the variables at the top.

# frames to use before and after
FRAMES_PAD = 0
# real render 3d scene or GL preview?
USE_OPENGL = True
# handle marker switching cameras
USE_MARKER_CAMERAS = True

import bpy
from bpy import context

wm = context.window_manager
scene = context.scene
# store original output
filepath_orig = scene.render.filepath
frame_range = scene.frame_start, scene.frame_end

markers = sorted(scene.timeline_markers, key=lambda m: m.frame)

# progress in cursor (countdown)
wm.progress_begin(0, len(markers) - 1)
scene.frame_start = 1

if USE_MARKER_CAMERAS:
    markers_camera = [m.camera for m in markers]

    def markers_cameras_restore():
        for m, c in zip(markers, markers_camera):
            m.camera = c


    def markers_cameras_disable():
        for m in markers:
            m.camera = None


for i in range(1, len(markers)):
    m_start = markers[i - 1]
    m_end = markers[i]

    # just in case
    if m_start.frame == m_end.frame:
        continue

    scene.frame_end = m_end.frame + FRAMES_PAD
    scene.frame_start = m_start.frame - FRAMES_PAD
    scene.render.filepath = filepath_orig + "_######_" + m_start.name

    if USE_MARKER_CAMERAS:
        markers_cameras_restore()
        scene.frame_set(scene.frame_start)
        if m_start.camera:
            scene.camera = m_start.camera
        markers_cameras_disable()

    wm.progress_update(len(markers) - (i + 1))

    if USE_OPENGL:
        bpy.ops.render.opengl(animation=True)
    else:
        bpy.ops.render.render(animation=True)


# restore original values
scene.render.filepath = filepath_orig
scene.frame_start, scene.frame_end = frame_range

if USE_MARKER_CAMERAS:
    markers_cameras_restore()

wm.progress_end()
$\endgroup$
1
  • $\begingroup$ Great one. You made my day!! Thanks a lot for this. $\endgroup$
    – Polosson
    Commented Sep 28, 2014 at 22:40

You must log in to answer this question.

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