How to get the frame number from a timeline marker

Hello.

I want to render only the frames I mark.

and because it doesn’t have any pattern and I can’t do it manually.

Do you have a code to get the frame number from the marker? so I can use it for render.
Or another method to render only marked frames?

Thank you.

In python
bpy.context.scene.timeline_markers
will get you all the markers in the current scene

and then you can add .frame on each one to get the frame number

So then you can do for example:
[i.frame for i in bpy.context.scene.timeline_markers]
to get a list of all frames you have marked

Hope this helps

2 Likes

wow. thank you so much. I’m a newbie about programming. I don’t exactly know how to write it but I’ll learn and try what you told me. That looks promising.

Something like

import bpy

this_scene = bpy.context.scene 

for marker in this_scene.timeline_markers:
    this_scene.frame_set(marker.frame) #set the current frame to the frame of the marker
    bpy.ops.render.render() #render an image at the current frame

is a good place to start.

It won’t do exactly what you want, (it’ll render each frame to the image editor instead of actually saving them out, and each one will over-write the previous one,) but you can adapt the basic structure to make it behave the way you want it to.

Personally I would probably adapt it to render a series of 1-frame animations (in which case use render(animation=True) and frame_start=marker.frame and frame_end=marker.frame)

I’ll let you figure out the rest however you want it.

I hope that is useful. Feel free to ask if you have more questions. :slightly_smiling_face:

1 Like

I just found this add-on, I thought I should post the link here since it seemed relevant:
https://github.com/p2or/blender-loom

It can render specific frames of an animation that can be specified manually, and it can also render only frames which have keyframes (& fill in the gaps by copying the previous frame)

1 Like

wow. that’s wonderful. Thank you so much. I’ll look into it.

Sorry for the late reply. I’m a super newbie. I tried coding but nothing works. Might have set something wrong. I’ll update the result again when I got something.