How to Convert DaVinci Resolve Timecode to Frames in Python
Convert HH:MM:SS:FF back to a frame index for precise Timeline calculations
Use a small parse_tc_to_frames() helper to convert Resolve timecode into a frame number so ranges, durations, offsets, and external Timeline data can be compared in one coordinate system.
API
Resolve Scripting API
Language
Python
Resolve
19–20+
Requires
Running Resolve
Syntax
frame = parse_tc_to_frames(timecode, fps)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.
def parse_tc_to_frames(tc: str, fps: float) -> int:
try:
hh, mm, ss, ff = [int(part) for part in str(tc).split(":")]
return int(round(((hh * 3600) + (mm * 60) + ss) * fps + ff))
except Exception:
return 0
fps = 24.0
timecode = "00:01:18:03"
print(parse_tc_to_frames(timecode, fps)) # 1875Guide
What the example does
The helper splits an HH:MM:SS:FF string into hours, minutes, seconds, and frames, then converts the complete value into a frame count using the supplied FPS. Numeric frame positions are much easier to compare and subtract than timecode strings.
Why a single coordinate system matters
TimelineItem.GetStart() and GetEnd() normally return frame positions, while a Timeline start may be represented as a timecode string. Converting the timecode to frames prevents a script from mixing units and keeps later calculations deterministic.
Practical role in automation
The reverse conversion is useful when reading timelineStartTimecode, measuring Timeline offsets, preparing render ranges, or matching Resolve data against external JSON, subtitle, or analysis files. It is basic Timeline math that helps keep every system aligned to the same frame reference.
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 convert davinci resolve timecode to frames in 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
- The helper expects HH:MM:SS:FF.
- Drop-frame timecode requires separate handling; this simple example does not implement SMPTE drop-frame rules.
- The example returns 0 on malformed input so the calling code can handle a missing or invalid timecode safely.
- Read FPS from the Timeline or project settings instead of hard-coding it in production scripts.
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 Convert Frames to Timecode for DaVinci Resolve in Python
Convert a Timeline frame number into HH:MM:SS:FF timecode before moving the playhead, setting In/Out points, or calling Resolve methods that expect timecode instead of seconds.
Timeline
How to Get Timeline FPS with the DaVinci Resolve Python API
Read the active Timeline frame rate, convert string settings safely to float, and use project settings as a fallback when the Timeline does not expose a value.
Timeline
How to Move the Playhead in DaVinci Resolve with the Python API
Move the Resolve playhead to a known frame by trying SetCurrentTimecode first and falling back to SetCurrentFrame when that method is available in the current scripting build.

