Resolve API: Finding the MediapoolItem object of a timeline

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

dominik.eckold

  • Posts: 17
  • Joined: Mon Mar 04, 2019 10:58 am
  • Real Name: Dominik Eckold

Resolve API: Finding the MediapoolItem object of a timeline

PostFri Mar 17, 2023 3:05 pm

I was thrilled to find the new function 'GetUniqueId()' in the scripting documentation of Resolve 18.1.

I thought maybe it is finally possible to identify a Timeline object in the Mediapool by ID rather than just by its name (not robust enough as there may be duplicate names in a project) or its index (not possible to match that to a MediapoolItem).

However, it seems like a Timeline object has a different 'unique id' than its corresponding MediapoolItem.

To test it, create a new project with just one timeline in the 'Master' bin and run this:

Code: Select all
import DaVinciResolveScript as dvrs

# ########## Global variables ##########
# Scripting Engine
resolve = dvrs.scriptapp('Resolve')
# Project Manager
projectManager = resolve.GetProjectManager()
# Current Project
project = projectManager.GetCurrentProject()
# Number of timelines in project
tlCount = project.GetTimelineCount()
# Media Pool
mediaPool = project.GetMediaPool()
# Get the root bin
rootFolder = mediaPool.GetRootFolder()

# Find all objects in the media pool
mediaPoolObjects = rootFolder.GetClipList()

# Print the unique ID of each mediapool object
for obj in mediaPoolObjects:
    print('Obj ID: ' + obj.GetUniqueId())

# Print the unique ID of each timeline in the project
for i in range(tlCount):
    tl = project.GetTimelineByIndex(i+1.0)
    print('TL ID: ' + tl.GetUniqueId())


Returns this:
Code: Select all
Obj ID: 05cb51ff-4992-4d46-ad54-129f4de74b26
TL ID: 8d05f53e-b05d-419c-832e-c00027ff29d0


As you can see, the IDs are different.

So the unique id is not so unique after all. Or put another way: a 'Timeline' object and a 'MediaPoolItem' object are two separate entities and there seems to be no way to match one to the other. Even though every 'Timeline' object must have a 'MediaPoolItem' associated with it.

Unless I'm missing something. Is that correct or does anybody know a way?
Offline
User avatar

roger.magnusson

  • Posts: 3399
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Resolve API: Finding the MediapoolItem object of a timel

PostFri Mar 17, 2023 3:47 pm

The only reliable way I have found is to rename the timeline temporarily and find the MediaPoolItem that way.

Not a great solution though, to make changes to a project if you're only listing stuff.
Offline

dominik.eckold

  • Posts: 17
  • Joined: Mon Mar 04, 2019 10:58 am
  • Real Name: Dominik Eckold

Re: Resolve API: Finding the MediapoolItem object of a timel

PostFri Mar 17, 2023 4:53 pm

Hi Roger,

roger.magnusson wrote:The only reliable way I have found is to rename the timeline temporarily and find the MediaPoolItem that way.

thank you! I had not thought of that. It does seem a little invasive but it would be a workaround.
Offline
User avatar

Igor Riđanović

  • Posts: 1601
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Resolve API: Finding the MediapoolItem object of a timel

PostFri Mar 17, 2023 5:26 pm

The thing is that the timeline item is an instance of the media pool item. They can not have the same UID.

Think of it from the normal user perspective, a single clip in the bin can be cut many times in one or more timelines. Each of those timeline item instances have their own attributes. They should not have the same UID as their parent.
www.metafide.com - DaVinci Resolve™ Apps
Offline

dominik.eckold

  • Posts: 17
  • Joined: Mon Mar 04, 2019 10:58 am
  • Real Name: Dominik Eckold

Re: Resolve API: Finding the MediapoolItem object of a timel

PostMon Mar 20, 2023 8:55 am

I get that. But there still should be a way to find a timeline's instance or 'parent' in the Media Pool. There should be some shared id or attribute to connect these two instances. They have to be connected somehow after all.

Just like a TimelineItem's MediaPoolItem can be found through the UI (right-click -> Find in MediaPool)

There just seems to be no real way to reveal such connections through the API.
Offline
User avatar

roger.magnusson

  • Posts: 3399
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Resolve API: Finding the MediapoolItem object of a timel

PostThu Mar 30, 2023 8:23 pm

dominik.eckold wrote:Hi Roger,

roger.magnusson wrote:The only reliable way I have found is to rename the timeline temporarily and find the MediaPoolItem that way.

thank you! I had not thought of that. It does seem a little invasive but it would be a workaround.

Thinking about this some more, it's not a good workaround as it will fail when setting the name back to the original name if there are two timelines with the same name in the project. Resolve enforces unique names for timelines, but not when pasting copies of timelines to another bin. So it's possible to have a project where all timelines have the same name. Even in the same bin if you move them after pasting them to another bin.

I reported that as a bug here: https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=178493
Offline
User avatar

Igor Riđanović

  • Posts: 1601
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Resolve API: Finding the MediapoolItem object of a timel

PostFri Mar 31, 2023 11:55 pm

I might be very confused by what you're asking, but if not, the solution is super simple. See: viewtopic.php?f=21&t=178493
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

roger.magnusson

  • Posts: 3399
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Resolve API: Finding the MediapoolItem object of a timel

PostSat Apr 01, 2023 1:25 am

Let's say you want to get the In/Out points of the current timeline (project.GetCurrentTimeline()).

In/Out points are properties of the Media Pool Item that represents the Timeline. So we need to traverse the Media Pool for a Media Pool Item with a name that matches the Timeline. The issue is that timeline names aren't unique (even though Resolve pretends to not allow duplicates in many cases). So there's no failsafe way of getting the right Media Pool Item.

Return to DaVinci Resolve

Who is online

Users browsing this forum: Daniel Batinic, ghost355 and 221 guests