← All DaVinci Resolve API guides
DaVinci Resolve APIAdvancedTimeline

How to Split a Clip at an Exact Frame in DaVinci Resolve with Python

Find the clip under a frame, move the playhead, and trigger Resolve's native Split Clip command

Use the Scripting API to verify that a clip crosses the requested frame and move the playhead there, then trigger Resolve's native split command as a practical fallback when a direct SplitClip API method is unavailable.

API

Resolve Scripting API

Language

Python

Resolve

19–20+

Requires

Running Resolve

Syntax

set_playhead(timeline, frame, fps)
# trigger Resolve Split Clip command

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 subprocess
import sys
import time
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


def frames_to_tc(frame: int, fps: float) -> str:
    fps_i = max(1, int(round(fps)))
    total = int(round(frame))
    ff = total % fps_i
    seconds = total // fps_i
    hh = seconds // 3600
    mm = (seconds % 3600) // 60
    ss = seconds % 60
    return f"{hh:02d}:{mm:02d}:{ss:02d}:{ff:02d}"


def get_timeline_fps(project, timeline) -> float:
    value = safe_call(timeline, "GetSetting", "timelineFrameRate") or safe_call(project, "GetSetting", "timelineFrameRate")
    try:
        return float(value)
    except Exception:
        return 24.0


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):
            for item in safe_call(timeline, "GetItemListInTrack", media_type, track_index) or []:
                yield item


def set_playhead(timeline, frame: int, fps: float) -> bool:
    timecode = frames_to_tc(frame, fps)
    if safe_call(timeline, "SetCurrentTimecode", timecode):
        return True
    if safe_call(timeline, "SetCurrentFrame", int(frame)):
        return True
    return False


def focus_resolve_window() -> bool:
    if sys.platform.startswith("win"):
        command = "$ws=New-Object -ComObject WScript.Shell; $null=$ws.AppActivate('DaVinci Resolve')"
        subprocess.call(["powershell", "-NoProfile", "-Command", command], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        time.sleep(0.2)
        return True

    if sys.platform.startswith("linux"):
        for needle in ("DaVinci Resolve", "resolve", "Blackmagic Design"):
            for args in (("--name", needle), ("--class", needle)):
                try:
                    output = subprocess.check_output(["xdotool", "search", *args], text=True).strip()
                    ids = [line for line in output.splitlines() if line.strip()]
                    if ids:
                        subprocess.call(["xdotool", "windowactivate", "--sync", ids[-1]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                        time.sleep(0.2)
                        return True
                except Exception:
                    pass
        raise RuntimeError("DaVinci Resolve window was not found")

    return True


def send_split_hotkey() -> bool:
    focus_resolve_window()
    if sys.platform.startswith("win"):
        try:
            import pyautogui
            pyautogui.hotkey("ctrl", "b")
        except Exception:
            command = "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('^b')"
            subprocess.call(["powershell", "-NoProfile", "-Command", command], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        time.sleep(0.15)
        return True

    if sys.platform.startswith("linux"):
        subprocess.call(["xdotool", "key", "ctrl+b"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        time.sleep(0.15)
        return True

    raise RuntimeError("Hotkey-based splitting is not implemented for this platform")


def split_at_frame(timeline, fps: float, frame: int) -> bool:
    touching = []
    for item in iter_timeline_items(timeline):
        start = safe_call(item, "GetStart")
        end = safe_call(item, "GetEnd")
        if start is not None and end is not None and int(start) < frame < int(end):
            touching.append(item)

    if not touching:
        return True
    if not set_playhead(timeline, frame, fps):
        return False
    return send_split_hotkey()


dvr = import_resolve_module()
resolve = dvr.scriptapp("Resolve")
project = resolve.GetProjectManager().GetCurrentProject()
timeline = project.GetCurrentTimeline()
fps = get_timeline_fps(project, timeline)

if not split_at_frame(timeline, fps, frame=240):
    raise RuntimeError("Could not split the clip")

print("Split completed")

Guide

What the example does

Not every Resolve scripting version exposes a direct SplitClip method. This practical bridge pattern uses supported Timeline API calls to locate the target item and position the playhead, then invokes Resolve's normal Split Clip keyboard command to perform the edit.

Why the script checks for a clip first

A split is only meaningful when the target frame lies inside an existing item. Checking GetStart() and GetEnd() before sending the command avoids unnecessary UI actions and makes it safe to iterate through a prepared list of candidate frames.

Limitations of the approach

The final command depends on the Resolve window having focus and on OS-level keyboard automation. The sample uses xdotool on Linux and can use pyautogui or a PowerShell SendKeys approach on Windows. Treat this as a pragmatic bridge technique rather than a pure API 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 split a clip at an exact frame in davinci resolve with python.

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

  • Duplicate the Timeline before running large batches of automated splits.
  • Install xdotool on Linux if you use the provided system-hotkey path.
  • Make sure the configured shortcut still maps to Resolve's Split Clip command.
  • This is a practical automation fallback, not a dedicated official SplitClip scripting method.

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