There is a scene in Video Sequence Editor with several video strips one after another in time. Each strip corresponds to a video file. Along the timeline I have several markers.

What I'd like to do is to take a marker and return a videofile path under the marker and a time position in this video file at which marker points. I'm thinking of writing a python script to do that automatically for a long scene with lots of markers. What would be a preferred way to do that?


This will print the Marker time (in seconds since it's corresponding video strip started) with it's corresponding video strip's path for every marker in the scene's timeline.

import bpy

scene = bpy.context.scene

fps = scene.render.fps / scene.render.fps_base

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

all_strips = list(sorted(scene.sequence_editor.sequences,
            key=lambda x: x.frame_final_start))

for strip in all_strips:
    if strip.type == 'MOVIE':
        start = strip.frame_final_start
        end = strip.frame_final_end

        for marker in all_markers:    
            if marker.frame >= start and marker.frame <= end:
                time = (marker.frame - start) / fps
                path = strip.filepath
                print(time, path)
  • $\begingroup$ Thank you for the example. One thing I guess is that time should be "time = (marker.frame - start) / fps" since I want to get the time in strips' file $\endgroup$
    – Ali Rustam
    May 21 '17 at 18:58
  • $\begingroup$ Right. I'll adjust the answer to make it more accurate. $\endgroup$
    – doakey3
    May 21 '17 at 19:14
  • $\begingroup$ you can filter your list to get only the movie strips: strips_movie = (i for i in strips_all_sorted if i.type == 'MOVIE') this returns a generator so it should be very memory friendly - if you exchange the () to [] you will get a normal list $\endgroup$ May 11 '19 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.