Script access to timeline items

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

hpJohn

  • Posts: 1
  • Joined: Tue Nov 06, 2018 4:10 pm
  • Real Name: John Pope

Script access to timeline items

PostTue Nov 06, 2018 4:51 pm

Im trying to programmatically set keyframes for timeline clips, for things like Transform->Position/Zoom and Composite->Opacity

Using the following script I can access the timeline item, but none of the members of 'Timeline item' (GetDuration, GetFlags, GetMarkers, etc) appear to point to these properties. How can I modify these values?

It would also be useful if, instead of "timeline.GetItemsInTrack("video",1)" I could use something like "GetCurrentlySelectedItem()" but that also seems un-doable.

Code: Select all
import imp
dr = imp.load_source('DaVinciResolveScript', 'C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules\DaVinciResolveScript.py')
resolve = dr.scriptapp('Resolve')

projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()
timeline = project.GetCurrentTimeline()

items = timeline.GetItemsInTrack("video",1)
item = items[1]
print(item.GetName()) #Item successfully acquired


Image
Offline

Drughi

  • Posts: 4
  • Joined: Sun Oct 06, 2019 1:30 pm
  • Real Name: Johannes Heintz

Re: Script access to timeline items

PostSun Oct 06, 2019 5:29 pm

I'm trying to do something similar. Did you find a solution?
Offline

brokenfeet

  • Posts: 38
  • Joined: Wed Sep 25, 2019 10:25 am
  • Real Name: Volker Klink

Re: Script access to timeline items

PostThu Jan 14, 2021 4:00 pm

+1

Trying to get access to the currently selected clip :-(
What seems to be a basic functionality, seems nt popssible.
Offline
User avatar

Igor Riđanović

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

Re: Script access to timeline items

PostThu Jan 14, 2021 10:44 pm

Those item properties are not exposed via the API.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

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

Re: Script access to timeline items

PostThu Jan 14, 2021 10:50 pm

brokenfeet wrote:+1

Trying to get access to the currently selected clip :-(
What seems to be a basic functionality, seems nt popssible.


I responded to your question in another thread, but are you trying to access the current item, not the current clip? The OP is talking about accessing the timeline item.

To access the current item you use GetCurrentVideoItem() on the timeline instance.
www.metafide.com - DaVinci Resolve™ Apps
Offline

csx333

  • Posts: 75
  • Joined: Thu Sep 26, 2019 10:15 am
  • Location: Germany
  • Real Name: Christoph Schmid

Re: Script access to timeline items

PostWed Feb 21, 2024 10:42 am

Igor Riđanović wrote:To access the current item you use GetCurrentVideoItem() on the timeline instance.

GetCurrentVideoItem() retrieves the topmost item at the playhead position - not the currently selected clip!

I would like to be able to access the selected clip(s) in the timeline.
It would also be nice to be able to retrieve the selected clip(s) in a bin.

So please BMD, add the following to the API:
- MediaPool.GetSelectedItems()
- Timeline.GetSelectedItems()
_____________________________________
Davinci Resolve Studio 18.6.5
Windows 10 Pro 22H2
Linux Ubuntu Studio 23.10
GeForce RTX 2070 Super
AMD Ryzen 9 3900X
32 GB DDR4
Offline

MarcusWolschon

  • Posts: 801
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Script access to timeline items

PostWed Feb 21, 2024 11:33 am

For timeline-items that are Multicams,
is there any way to find out what camera angle and position within the Multicam they are?
Offline

csx333

  • Posts: 75
  • Joined: Thu Sep 26, 2019 10:15 am
  • Location: Germany
  • Real Name: Christoph Schmid

Re: Script access to timeline items

PostWed Feb 21, 2024 1:57 pm

As far as I know, there is no direct way to determine the camera or angle used in the timeline.
For the MediaPool item, there is a property for "Angle" and "Camera #"
Code: Select all
item.GetProperty('Angle')
or
Code: Select all
item.GetProperty('Camera #')
but unfortunately the clips in the timeline refer to the multi-camera clip and not to the source clips.

But there is a small workaround:

The angle or camera# (depending on the setting when creating a multi-camera clip)
is appended to the name of the timeline element.

So you can use this python code to get the information:

Code: Select all
import DaVinciResolveScript
resolve = DaVinciResolveScript.scriptapp('Resolve')
project_manager = resolve.GetProjectManager()
project = project_manager.GetCurrentProject()
current_timeline = project.GetCurrentTimeline()
current_item = current_timeline.GetCurrentVideoItem()
current_mp_item = current_item.GetMediaPoolItem()
clipname = current_item.GetName()
multiclipname = current_mp_item.GetName()
angle = clipname.replace(multiclipname  + " - ", "")
print(angle)
_____________________________________
Davinci Resolve Studio 18.6.5
Windows 10 Pro 22H2
Linux Ubuntu Studio 23.10
GeForce RTX 2070 Super
AMD Ryzen 9 3900X
32 GB DDR4
Offline

MarcusWolschon

  • Posts: 801
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Script access to timeline items

PostWed Feb 21, 2024 2:05 pm

Very indirect and not exactly robust. But it could actually solve half of what we need.

Currently we access the database directly because the API is way too limited.

The Properties are clip-metadata and not Multicam track names.
So we can't rely on them even to be non-blank. Let alone correct or unique.
Way too often a camera is moved to a different position ad-hoc without anyone entering the
metadata screen with the tiny on-screen keyboard while a live show is about to start any second.
(It's more important to check focus, be level with the stage, adjust interkom and make sure jam-syncing timecode was not forgotten about at that moment. ...and check that the internal micophone in not off, as a backup to timecode.)
Offline

csx333

  • Posts: 75
  • Joined: Thu Sep 26, 2019 10:15 am
  • Location: Germany
  • Real Name: Christoph Schmid

Re: Script access to timeline items

PostWed Feb 21, 2024 2:12 pm

MarcusWolschon wrote:The Properties are clip-metadata and not Multicam track names.

Yes, but Davinci uses the clip-metadata to generate the Multicam Clip Name (in timeline).
_____________________________________
Davinci Resolve Studio 18.6.5
Windows 10 Pro 22H2
Linux Ubuntu Studio 23.10
GeForce RTX 2070 Super
AMD Ryzen 9 3900X
32 GB DDR4
Offline

csx333

  • Posts: 75
  • Joined: Thu Sep 26, 2019 10:15 am
  • Location: Germany
  • Real Name: Christoph Schmid

Re: Script access to timeline items

PostWed Feb 21, 2024 2:20 pm

MarcusWolschon wrote:So we can't rely on them even to be non-blank.

The same applies to the metadata - if it is not filled in correctly...
_____________________________________
Davinci Resolve Studio 18.6.5
Windows 10 Pro 22H2
Linux Ubuntu Studio 23.10
GeForce RTX 2070 Super
AMD Ryzen 9 3900X
32 GB DDR4

Return to DaVinci Resolve

Who is online

Users browsing this forum: FAST WebCrawler [Crawler], Google [Bot] and 156 guests