help with Python script to create new timelines from clips

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

Doc_spn

  • Posts: 1
  • Joined: Sat Jan 20, 2024 8:49 am
  • Real Name: David Ortega

help with Python script to create new timelines from clips

PostTue Apr 02, 2024 9:47 am

Hi resolve users

I am trying to create a Python script that creates one timeline for each clip in the media pool. So if there are 20 clips in the media pool, then 20 timelines will be created, each of them containing only one clip

To do so here´s what I have:
Code: Select all
import DaVinciResolveScript as dvr_script

# Get Resolve instance
resolve = dvr_script.scriptapp("Resolve")

# Get project manager and current project
project_manager = resolve.GetProjectManager()
project = project_manager.GetCurrentProject()

# Get media pool
media_pool = project.GetMediaPool()
root_folder = media_pool.GetRootFolder()
clips = root_folder.GetClipList()

# Iterate over each clip in the Media Pool
for i, clip in enumerate(clips):
    # Create a new timeline for the clip
    timeline_name = f"Timeline_{i+1}"
    media_pool.CreateEmptyTimeline(timeline_name)
    timeline = project.GetTimelineByName(timeline_name)
   
    # Append the clip to the timeline
    timeline.AppendClip(clip)


But it is not working, can you help me achieve this?

thanks in advance, BR
Offline
User avatar

Stefan Weßling

  • Posts: 30
  • Joined: Thu Oct 30, 2014 2:00 am

Re: help with Python script to create new timelines from cli

PostThu May 02, 2024 12:07 am

Got it working

1:
You are calling clip_list from the root folder => are you clips in the root folder?
otherwise you might want to use media_pool.GetCurrentFolder()

2:
Selecting the new timeline; use "SetCurrentTimeline(timeline_name)" and "GetCurrentTimeline(timeline_name)" instead of the TimelineByName function.

3:
Use "media_pool.AppendToTimeline(clip)" to insert the clip into the new timeline instead of timeline.AppendClip(clip).

=> tested on 18.6.6

Return to DaVinci Resolve

Who is online

Users browsing this forum: Google [Bot], kristofer22, Michel Rabe, Paddywack0, Steve Alexander, ZRGARDNE and 159 guests