How to Unlock Timeline Tracks with the DaVinci Resolve Python API
Use GetTrackCount, SetTrackLock, and SetTrackEnable across all video and audio tracks
Prepare a Timeline for later automation by iterating every existing video and audio track, removing track locks, and enabling tracks without hard-coding V1, V2, A1, or A2.
API
Resolve Scripting API
Language
Python
Resolve
19–20+
Requires
Running Resolve
Syntax
timeline.SetTrackLock("video", track_index, False)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):
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 unlock_all_tracks(timeline) -> None:
for media_type in ("video", "audio"):
track_count = int(safe_call(timeline, "GetTrackCount", media_type) or 0)
for index in range(1, track_count + 1):
safe_call(timeline, "SetTrackLock", media_type, index, False)
safe_call(timeline, "SetTrackEnable", media_type, index, True)
print(f"{media_type} track {index}: unlocked and enabled")
unlock_all_tracks(timeline)Guide
What the script does
The code reads the number of tracks separately for video and audio, then iterates indexes from 1 through the returned track count. For each track it attempts to remove the lock and enable the track through the Timeline API.
Why track indexes start at 1
Resolve Scripting API track numbering is one-based. That differs from normal Python list indexing. Passing 0 as a track number can result in a failed call or no useful action, so automation should always treat V1/A1 as index 1.
When to run this preparation step
Unlocking tracks is useful before destructive or structural Timeline operations such as deleting clips, trimming, moving items, or validating track state. It is best treated as an explicit preparation step rather than an invisible side effect buried inside another function.
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 unlock timeline tracks with the davinci resolve python api.
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
- SetTrackLock and SetTrackEnable availability can vary by Resolve version.
- The loop only touches tracks that already exist.
- Calling the unlock step again on an already unlocked track is normally harmless.
- Save the project before any later operation that will modify Timeline content.
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 Iterate Timeline Clips with the DaVinci Resolve Python API
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.
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.
Timeline
How to Iterate Timeline Clips with the DaVinci Resolve Python API
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.

