How to Create Missing Video Tracks with the DaVinci Resolve API
Use GetTrackCount("video") and AddTrack("video") before targeting V2, V3, or higher tracks
Prepare a Timeline safely by checking how many video tracks exist and creating missing tracks before later placement operations target them.
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 ensure_video_track(timeline, track_index: int) -> int:
if track_index < 1:
raise ValueError("track_index must start at 1")
count = int(safe_call(timeline, "GetTrackCount", "video") or 0)
while count < track_index:
if not safe_call(timeline, "AddTrack", "video"):
raise RuntimeError(f"Could not create video track V{count + 1}")
count += 1
return count
resolve, project, timeline = get_project_and_timeline()
tracks_after = ensure_video_track(timeline, 3)
print("Video tracks after check:", tracks_after)
Guide
What the helper does
The function guarantees that the requested video-track index exists. If the current count is too low, it repeatedly calls AddTrack("video") until Resolve reaches the required track number.
When to use it
Before inserting media on V2, V3, or a higher track, explicitly preparing the Timeline makes an automation script more reliable across projects that start with different track layouts.
What AddTrack does not configure
AddTrack creates a track, but this minimal helper does not assign custom names, colors, or advanced routing. Its responsibility is only to guarantee that the requested trackIndex exists.
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 create missing video tracks with the davinci resolve 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
- Video track numbering starts at 1.
- AddTrack changes the Timeline.
- The method can return False when Resolve cannot create a track in the current state.
- Use AddTrack("audio") for audio tracks.
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
Media Pool
How to Append Clips to a DaVinci Resolve Timeline with AppendToTimeline
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.
Audio
How to Create Missing Audio Tracks with the DaVinci Resolve API
Build a helper that guarantees A1, A2, A3, or another requested audio track exists before a later AppendToTimeline operation targets it.
Audio
How to Append an Audio File to a DaVinci Resolve Timeline with Python
Import an audio file into the Media Pool and place it on a specific Timeline audio track at an exact frame position using a clip-info dictionary.

