← All DaVinci Resolve API guides
DaVinci Resolve APIIntermediateMedia Pool

How to Append Clips to a DaVinci Resolve Timeline with AppendToTimeline

Import media into the Media Pool and append clips to the active Timeline in a controlled order

Import a list of files with ImportMedia, map the resulting MediaPoolItem objects back to their source paths, and append them to the active Timeline in the intended order.

API

Resolve Scripting API

Language

Python

Resolve

19–20+

Requires

Running Resolve

Syntax

result = api_method()

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, **kwargs):
    try:
        fn = getattr(obj, name, None)
        if callable(fn):
            return fn(*args, **kwargs)
    except Exception:
        return None
    return None


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

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

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

    return resolve, project, timeline


def normalized_path(path: str) -> str:
    return os.path.normcase(os.path.abspath(os.path.expanduser(path)))


def import_and_append(files: list[str]) -> dict:
    resolve, project, timeline = get_project_and_timeline()
    media_pool = project.GetMediaPool()
    if not media_pool:
        raise RuntimeError("Media Pool is unavailable")

    files = [str(Path(p).expanduser()) for p in files if Path(p).expanduser().is_file()]
    if not files:
        raise RuntimeError("No existing media files were provided")

    imported_items = media_pool.ImportMedia(files) or []
    if not imported_items:
        raise RuntimeError("ImportMedia returned an empty list")

    path_to_item = {}
    for item in imported_items:
        props = safe_call(item, "GetClipProperty") or {}
        file_path = props.get("File Path") or props.get("FilePath") or ""
        if file_path:
            path_to_item[normalized_path(file_path)] = item

    ordered_items = []
    for file_path in files:
        item = path_to_item.get(normalized_path(file_path))
        if item:
            ordered_items.append(item)

    if not ordered_items:
        ordered_items = imported_items

    appended = 0
    failed = []
    for item in ordered_items:
        ok = media_pool.AppendToTimeline([item])
        if ok:
            appended += 1
        else:
            failed.append(safe_call(item, "GetName") or "unknown")

    safe_call(resolve, "OpenPage", "edit")
    return {"imported": len(imported_items), "appended": appended, "failed": failed}


result = import_and_append([
    r"D:\\video\\shot_001.mp4",
    r"D:\\video\\shot_002.mp4",
])
print(result)

Guide

What the example does

The script receives a list of source files, imports them into the Media Pool, and appends the resulting MediaPoolItem objects to the active Timeline. The important distinction is that Timeline assembly works with Resolve objects after import, not with raw filesystem paths.

Why preserving order takes extra work

ImportMedia can return items in an order chosen by Resolve rather than the order of the input list. The example therefore reads each imported item’s file path through GetClipProperty(), builds a path-to-item map, and reconstructs the original sequence before appending.

What to check after AppendToTimeline

Do not ignore the return value from AppendToTimeline. The example counts successful inserts and keeps the names of failed items so an automation layer can surface the problem instead of silently producing an incomplete Timeline.

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 append clips to a davinci resolve timeline with appendtotimeline.

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

  • Every source path should exist before ImportMedia is called.
  • AppendToTimeline works with MediaPoolItem objects or clip-info dictionaries, not plain path strings.
  • Create an active Timeline first if the project does not already have one.
  • Absolute file paths are preferable for repeatable automation.

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