← All DaVinci Resolve API guides
DaVinci Resolve APIAdvancedTimeline

How to Delete Timeline Clips with the DaVinci Resolve Python API

Find a TimelineItem by frame range, validate it, and pass the selected item to DeleteClips

Locate an item on the active Timeline by its start and end frame positions, verify that DeleteClips is available, and delete only the TimelineItem that matches the requested range.

API

Resolve Scripting API

Language

Python

Resolve

19–20+

Requires

Running Resolve

Syntax

timeline.DeleteClips([item], True)

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",
            "/opt/BlackmagicDesign/DaVinciResolve/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


def safe_call(obj, name, *args):
    try:
        fn = getattr(obj, name, None)
        if callable(fn):
            return fn(*args)
    except Exception:
        return None
    return None


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

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

timeline = project.GetCurrentTimeline()
if not timeline:
    raise RuntimeError("No active Timeline")
def iter_timeline_items(timeline):
    for media_type in ("video", "audio"):
        track_count = int(safe_call(timeline, "GetTrackCount", media_type) or 0)
        for track_index in range(1, track_count + 1):
            items = safe_call(timeline, "GetItemListInTrack", media_type, track_index) or []
            for item in items:
                yield media_type, track_index, item


def find_item_by_range(timeline, start_frame: int, end_frame: int):
    for media_type, track_index, item in iter_timeline_items(timeline):
        try:
            start = int(item.GetStart())
            end = int(item.GetEnd())
        except Exception:
            continue
        if abs(start - start_frame) <= 1 and abs(end - end_frame) <= 1:
            return item
    return None


item = find_item_by_range(timeline, start_frame=100, end_frame=200)
if not item:
    raise RuntimeError("No clip matches the requested frame range")

delete_clips = getattr(timeline, "DeleteClips", None)
if not callable(delete_clips):
    raise RuntimeError("Timeline.DeleteClips is unavailable in this Resolve version")

if not delete_clips([item], True):
    raise RuntimeError("Resolve did not delete the selected clip")

print("Clip deleted")

Guide

What the example does

The script walks through video and audio tracks, looks for an item whose start/end frame range matches the requested coordinates, and passes that TimelineItem to DeleteClips(). The second argument is set to True to request ripple deletion where the Resolve build supports that call shape.

Why the example matches by frame range

TimelineItem does not always expose a convenient stable identifier for small scripting examples. Start and end frame positions are easy to inspect with GetStart() and GetEnd(), making them a practical reproducible key for a controlled technical operation.

Why validation matters

Deletion changes the Timeline. The script therefore verifies that an item was found, confirms that DeleteClips is callable, and checks the returned result. Destructive automation should fail closed instead of silently continuing after an uncertain delete operation.

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 delete 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

  • Test destructive Timeline code on a duplicate project or Timeline first.
  • DeleteClips availability and behavior can vary between Resolve versions.
  • Prefer frame ranges obtained from a prior Timeline audit instead of typing destructive coordinates manually.
  • This example demonstrates the deletion mechanism only; selection policy should live in a separate, testable layer.

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