Welcome to WSL!

New to the forum? Please read this and this.

Importing image sequences into Resolve media pool with Lua

User avatar
Posts: 5
Joined: Mon May 10, 2021 5:50 pm

Importing image sequences into Resolve media pool with Lua


Post by msantana »


I'm having a bit of trouble importing image sequences into the media pool with Lua scripting.

Specifically importing them as timeline mattes.

I can use this without a problem to add .movs as timeline mattes -
  1. filepath = 'path_to_movie.mov'
  2. resolve:GetMediaStorage():AddTimelineMattesToMediaPool(filepath)
using osSeparators to build the directory up to the desired file - working perfectly.

But running the same on a png sequence just brings in a single frame. Which makes sense if I'm defining the path string as 'seq.01.png'. But I tried to break the sequence up like 'seq.' .. * .. '.png' which doesnt work - but I don't know what the correct syntax would be if this was even the route.

From the scripting ReadMe file, the following is shown regarding sequences under the ImportMedia command, which I'm hoping is similar even if not documented for AddTimelineMattesToMediaPool:
  1. ImportMedia([{clipInfo}])                       --> [MediaPoolItems]   # Imports file path(s) into current Media Pool folder as specified in list of clipInfo dict. Returns a list of the MediaPoolItems created.
  2.                                                                          # Each clipInfo gets imported as one MediaPoolItem unless 'Show Individual Frames' is turned on.
  3.                                                                          # Example: ImportMedia([{"FilePath":"file_%03d.dpx", "StartIndex":1, "EndIndex":100}]) would import clip "file_[001-100].dpx".
But I can't seem to get that to work, not even the ImportMedia version.

I'm really new to Lua, so I'm hoping this will be super easy for some of you to figure out! Been banging my head against the wall all day.

Thank you all in advance!

User avatar
Sir Requestalot
Posts: 311
Joined: Fri Nov 03, 2017 5:36 am
Answers: 4
Real name: Alexey Bogomolov
Been thanked: 14 times

Re: Importing image sequences into Resolve media pool with Lua


Post by Movalex »

@msantana The example from Resolve documentation is a Python code, not Lua. And ImportMedia is a method of the MediaPool, so you need to get it first. Therefore the correct approach to import sequence programmatically would be:
  1. resolve = bmd.scriptapp("Resolve")
  2. pm = resolve.GetProjectManager()
  3. cp = pm.GetCurrentProject()
  4. mp = cp.GetMediaPool()
  5. mp.ImportMedia([{"FilePath": "/Users/username/Desktop/test/test_%07d.exr", "StartIndex":430, "EndIndex":440}])
Of course, it is still possible to do that with Lua, with some syntax changes.
NB, looks like the "StartIndex" and "EndIndex" are mandatory, and import won't work without specifying frame range. So you will need to parse the sequence first.