How to Get the Audio Track Count from a DaVinci Resolve Timeline
Use GetTrackCount("audio") before inserting music, SFX, or running audio-oriented automation
Read the number of audio tracks in the active Timeline and use that value to validate track targets before adding audio clips or preparing an audio workflow.
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 get_audio_track_count(timeline) -> int:
count = safe_call(timeline, "GetTrackCount", "audio")
return int(count or 0)
resolve, project, timeline = get_project_and_timeline()
audio_tracks = get_audio_track_count(timeline)
print("Audio tracks:", audio_tracks)
Guide
What the example does
The code obtains the active Timeline and calls GetTrackCount("audio"). This is the simplest way to discover how many audio tracks currently exist before an automation script attempts any track-specific operation.
Why the check matters
A script should not assume that A2, A3, or another target track already exists in every project. Reading the current count first lets the automation create missing tracks deliberately or stop with a clear message.
Where to use it
Track-count checks are useful before inserting music, placing sound effects, exporting audio, normalizing project structure, or building a Timeline map for later processing.
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 the audio track count from a davinci resolve timeline.
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
- GetTrackCount("audio") returns the number of audio tracks; defensive code can treat an unavailable result as zero.
- Resolve track indexes start at 1.
- Validate that an active Timeline exists before calling the method.
- Use GetTrackCount("video") for video 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
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.
Audio
How to Export Timeline Audio to WAV with the DaVinci Resolve Python API
Export the active Timeline to WAV from Python: switch to Deliver, clear stale jobs, configure LinearPCM audio, create a Render Job, start it, and wait for Resolve to finish.

