How to Get a TimelineItem Track Type and Track Index with Python
Use GetMediaType and GetTrackIndex to identify where video, audio, titles, and other Timeline items live
Inspect TimelineItem media type and track index so clips can be grouped, reported, filtered, or processed according to their actual Timeline location.
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.
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 = safe_call(resolve, "GetProjectManager")
project = safe_call(project_manager, "GetCurrentProject") if project_manager else None
if not project:
raise RuntimeError("No DaVinci Resolve project is open")
timeline = safe_call(project, "GetCurrentTimeline")
if not timeline:
raise RuntimeError("No active Timeline")
return resolve, project, timeline
def item_track_info(item) -> tuple[str, int]:
media_type = str(safe_call(item, "GetMediaType") or "")
track_index = safe_call(item, "GetTrackIndex")
try:
track_index = int(track_index)
except Exception:
track_index = 0
return media_type, track_index
def collect_track_info(timeline, media_type: str = "video") -> list[dict]:
rows = []
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:
item_media_type, item_track_index = item_track_info(item)
rows.append({
"name": safe_call(item, "GetName") or "",
"media_type": item_media_type,
"track_index": item_track_index or track_index,
})
return rows
resolve, project, timeline = get_project_and_timeline()
for row in collect_track_info(timeline, "video"):
print(row)
Guide
What the example does
The code walks Timeline tracks, retrieves TimelineItem objects, and reads each item’s GetMediaType(), GetTrackIndex(), and name. The result can be stored as a simple row-oriented map of Timeline structure.
Why read both values
When iterating a known track, the loop already knows its index. Calling GetTrackIndex as well provides an independent value from the item itself and makes the helper reusable in workflows where an item is received without its surrounding loop context.
Where this information helps
Track metadata is useful for Timeline audits, JSON exports, selective cleanup, and technical workflows that need to distinguish clips by their real placement rather than by list order.
How the example works
Connect to Resolve
Establish a Resolve Scripting API connection and stop early if the application object is unavailable.
Validate the current context
Check the active project, Timeline, Media Pool, source paths, or Render Queue state required by this specific operation.
Run the core API operation
Execute the operation demonstrated in this guide: how to get a timelineitem track type and track index with python.
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
- GetMediaType can return different strings depending on the item type.
- Convert GetTrackIndex defensively because unavailable values should not crash an audit script.
- GetItemListInTrack returns an empty collection for tracks with no items.
- A track index is not the same thing as a clip’s position inside the returned item list.
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
Timeline
How to Build a Timeline Clip Map with the DaVinci Resolve API
Build a technical map of the active Timeline containing media type, track number, clip name, start, end, duration, and source file path when a linked MediaPoolItem is available.
Timeline
How to Export a DaVinci Resolve Timeline Clip Map to JSON
Build a technical JSON map of the current Timeline containing media type, track number, clip name, start, end, duration, and source path when available.
Timeline
How to Delete Timeline Clips with the DaVinci Resolve Python API
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.

