Cinema need: place images based on filename content?

Wow, fantastic, thank you @horusscope!
It works fine after renumbering filenames.

Now, I wanted to go on and tested to insert an image by console, but it failed because I found that we can’t simply call image_strip_add from the scripting context (it makes sense once you get the idea of context).
BTW:

>>> area = bpy.context.area
>>> area.type = 'SEQUENCE_EDITOR'

is fun to do in the console :smiley:

From there, it’s piece of cake to change the function call with variables and end up with:


Note that frame_end = frame_start of the next image so Blender spread images on 2 channels to prevent overlap, neat!
Simply a matter of b-1 to have everything on the same channel if needed.

final script:

import os
import re
import bpy

rootDir = 'E:/test/'
(_, _, files) = next(os.walk(rootDir))

dict = { }
num = len(files)

def frame(name):
    return re.search("\d+", name).group(0)

area = bpy.context.area
old_type = area.type
area.type = 'SEQUENCE_EDITOR'
for i in range(0,num):
    a = frame(files[i])
    a = int(a)
    if i < num-1:
        b = int(frame(files[i+1]))
    else:
        b = a+1000
    dict[files[i]] = b-a
    bpy.ops.sequencer.image_strip_add(directory=rootDir, files=[{"name":files[i]}], frame_start=a, frame_end=b, channel=2)

#import pprint
#pprint.pprint(dict) # see what you get
area.type = old_type

Maybe calling image_strip_add for all images, then resizing all images is more memory and CPU wise, but I wanted quick result. Feel free to improve and share.

I think garbage collector is not present because before script, memory is 34.7MB and after running the script with 274 files (just a tense 24min episode) it jumped to 1.7GB as soon as I start moving the playhead in the sequencer, it goes up to 5GB then lowers down to 4.33GB. JPG images are 9.87MB altogether, so there’s an issue somewhere for sure.

if i<num-1 has been an issue, I broke down the if statement to spot the error, and had to make sure it was an int in the end. Could be wrapped up again.

I learned quite a few things in this process, thank you @horusscope for this.
Could we go further to learn how to wrap it as an add-on?
And final bonus: Is there a way to export the sequencer timeline to something? Screenshot is not the best option.