← All DaVinci Resolve API guides
DaVinci Resolve APIIntermediateTimeline

How to Iterate Timeline Clips with the DaVinci Resolve Python API

Use GetTrackCount and GetItemListInTrack across video and audio tracks

Walk every video and audio track on the active Timeline, inspect TimelineItem objects, and print the name, start frame, and end frame for each clip.

API

Resolve Scripting API

Language

Python

Resolve

19–20+

Requires

Running Resolve

Syntax

items = timeline.GetItemListInTrack("video", 1)

Parameters

  • The relevant arguments are shown in the complete working example below. Validate paths, object types, and required project state before calling the API method.

Returns

Always validate the returned object, list, identifier, or boolean before continuing to the next automation step.

Complete working Python exampleuse it as a starting point for your own script
import os
import sys
from pathlib import Path


def import_resolve_module():
    try:
        import DaVinciResolveScript as dvr
        return dvr
    except ImportError:
        search_paths = [
            os.environ.get("RESOLVE_SCRIPT_API", ""),
            os.environ.get("RESOLVE_MODULES", ""),
            r"C:\\ProgramData\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules",
            "/opt/resolve/Developer/Scripting/Modules",
            "/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules",
            str(Path.home() / "Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules"),
        ]
        for path in search_paths:
            if path and os.path.isdir(path) and path not in sys.path:
                sys.path.append(path)
        import DaVinciResolveScript as dvr
        return dvr


dvr = import_resolve_module()


def iter_timeline_items(timeline):
    for track_type in ("video", "audio"):
        track_count = timeline.GetTrackCount(track_type) or 0
        for track_index in range(1, track_count + 1):
            items = timeline.GetItemListInTrack(track_type, track_index) or []
            for item in items:
                yield track_type, track_index, item


resolve = dvr.scriptapp("Resolve")
if not resolve:
    raise RuntimeError("Resolve API is unavailable")

project = resolve.GetProjectManager().GetCurrentProject()
if not project:
    raise RuntimeError("No project is open")

timeline = project.GetCurrentTimeline()
if not timeline:
    raise RuntimeError("No active Timeline")

for track_type, track_index, item in iter_timeline_items(timeline):
    name = item.GetName()
    start = int(item.GetStart())
    end = int(item.GetEnd())
    print(track_type, track_index, name, start, end)

Guide

How track iteration works

Resolve separates tracks by type: video and audio. The script first calls GetTrackCount(track_type), then loops from track index 1 through the returned count and calls GetItemListInTrack(track_type, index). Resolve track indexes start at 1.

What a TimelineItem is

GetItemListInTrack() returns TimelineItem objects. From each item you can read values such as name, start frame, end frame, media reference, track information, and other properties depending on Resolve version.

Practical uses

Clip iteration is useful for timeline audits: identify which clips are present, where they start and end, how the sequence is structured, or which items should be included in a later export or validation step.

Why this example is safe

The script is read-only. It does not delete, trim, move, or modify clips. That makes it a good diagnostic example and a safe introduction to Timeline API objects.

How the example works

1

Connect to Resolve

Establish a Resolve Scripting API connection and stop early if the application object is unavailable.

2

Validate the current context

Check the active project, Timeline, Media Pool, source paths, or Render Queue state required by this specific operation.

3

Run the core API operation

Execute the operation demonstrated in this guide: how to iterate timeline clips with the davinci resolve python api.

4

Validate the result

Check the returned value before the workflow continues. Resolve methods often signal an unavailable object or failed operation with None, False, or an empty result.

Resolve API notes

  • Resolve track indexes start at 1, not 0.
  • GetItemListInTrack() can return an empty list.
  • GetStart() and GetEnd() return Timeline frame positions.
  • Use the active Timeline FPS when converting frame positions to seconds.

Common errors

Resolve API is unavailable

Reason: Resolve is closed or Python cannot import/use DaVinciResolveScript.

Fix: Start Resolve and verify the Developer/Scripting/Modules path from the same Python interpreter used by the script.

The method returns None or False

Reason: A required project, Timeline, clip, preset, path, or application state is missing.

Fix: Validate each input and add explicit result checks after important Resolve API calls.

The script only works on one workstation

Reason: Paths or environment assumptions are hard-coded for a single operating system or machine.

Fix: Move paths into configuration and support the required Windows, Linux, and macOS locations explicitly.

Next step

Continue only after the current operation has returned the expected Resolve object or result.

Related API guides