Targeting video track 2 with script

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

davidcampbell

  • Posts: 3
  • Joined: Wed Sep 07, 2022 7:46 am
  • Real Name: David Campbell

Targeting video track 2 with script

PostFri Feb 07, 2025 1:58 pm

Hi,

I've created a python script that pulls media into a project, creates a timeline and then puts the media onto the new timeline. The problem I have is that I can only seem to place media on video track 1. What I would like to do is place all our camera 1 clips on track 1, and then go back to the beginning and put all our camera 2 clips on video track 2. Is there some way to do this? Specifically, is there a way to target video track 2?

I thought perhaps locking / enabling tracks might be the way to do it, but it doesn't seem to work.

Thanks,

David
Online

Christoph Schmid

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

Re: Targeting video track 2 with script

PostSat Feb 08, 2025 11:42 am

AppendToTimeline([{clipInfo}, ...])

Appends list of clipInfos specified as dict of "mediaPoolItem", "startFrame" (float/int), "endFrame" (float/int), (optional) "mediaType" (int; 1 - Video only, 2 - Audio only), "trackIndex" (int) and "recordFrame" (float/int). Returns the list of appended timelineItems.

Code: Select all
projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()
mediapool = project.GetMediaPool()
currFolder = mediapool.GetCurrentFolder()
clips = currFolder.GetClipList()

mediapool.AppendToTimeline([{'mediaPoolItem': clips[0], 'startFrame': 0, 'endFrame': 25, 'recordFrame': 90000, 'mediaType': 1, 'trackIndex': 2}])


This code will append the first 25 frames of the first clip in the current bin to frame 90000 of the current timeline on V2.

'recordFrame': 90000 equals to timecode 01:00:00:00 in a 25p timeline

To get the startframe of your timeline:
Code: Select all
timeline = project.GetCurrentTimeline()
print(timeline.GetStartFrame())

Davinci Resolve Studio 20.0 Build 49
Windows 10 Pro 22H2
Davinci Resolve Studio 19.1.4 Build 11
Linux Ubuntu Studio 24.04 (Rocky 8.6 Container)
Offline

davidcampbell

  • Posts: 3
  • Joined: Wed Sep 07, 2022 7:46 am
  • Real Name: David Campbell

Re: Targeting video track 2 with script

PostSat Feb 08, 2025 12:14 pm

That’s brilliant, Christoph. Thanks so much for your help.
Offline

rohnen

  • Posts: 1
  • Joined: Mon May 19, 2025 9:48 am
  • Real Name: Rohnen Raju

Re: Targeting video track 2 with script

PostMon May 19, 2025 9:51 am

Hello,
When I use the trackIndex parameter in CreateTimelineFromClips() to assign a mediaPoolItem to a specific video track (e.g., V2), DaVinci Resolve Studio 19.1.4 freezes and becomes unresponsive. Is this parameter officially supported? If not, what’s the correct way to place clips on different tracks programmatically?

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 8 guests