How to Convert Frames to Timecode for DaVinci Resolve in Python
A practical frames_to_tc helper for SetCurrentTimecode, In/Out ranges, and frame-accurate Timeline operations
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.
API
Resolve Scripting API
Language
Python
Resolve
19–20+
Requires
Running Resolve
Syntax
timecode = frames_to_tc(frame, 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 frames_to_tc(frame: int, fps: float) -> str:
fps_i = max(1, int(round(fps)))
total = int(round(frame))
ff = total % fps_i
seconds = total // fps_i
hh = seconds // 3600
mm = (seconds % 3600) // 60
ss = seconds % 60
return f"{hh:02d}:{mm:02d}:{ss:02d}:{ff:02d}"
fps = 24.0
frame = 1875
print(frames_to_tc(frame, fps)) # 00:01:18:03Guide
What the helper does
Resolve often exposes Timeline positions as frame numbers while some methods expect a timecode string. frames_to_tc() converts an integer frame position into HH:MM:SS:FF using the Timeline frame rate. It is a small utility, but it becomes a core building block in frame-accurate automation.
Why not convert through seconds
Seconds are convenient for human-readable calculations, but editing precision is frame-based. Passing through floating-point seconds can introduce rounding errors and one-frame offsets. Keeping the calculation in integer frames until the final timecode string avoids that unnecessary ambiguity.
Where to use it
The output is useful before SetCurrentTimecode(), SetInOutPoints(), and whenever diagnostic output needs to describe a clip or range in Resolve-style timecode. The same conversion pattern is useful in bridge tools that jump to a known frame or prepare render ranges.
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 frames to timecode for davinci resolve 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
- Read FPS from the active Timeline with GetSetting("timelineFrameRate") whenever possible.
- Non-integer and drop-frame rates require dedicated timecode rules; the simple helper is intended for straightforward non-drop workflows such as 24, 25, 30, 50, or 60 fps.
- Make sure the frame number is already expressed in the coordinate system of the current Timeline.
- The helper is read-only and safe to test outside a production-changing script.
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 DaVinci Resolve Timecode to Frames in Python
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.
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.
Render
How to Set a Render Range from V1 Clips with the DaVinci Resolve API
Find the combined frame range occupied by clips on video track V1, convert that range to timecode, set Timeline In/Out points, and switch the Deliver page to In/Out Range.

