How to Convert Seconds to Timeline Frames for the DaVinci Resolve API
Timeline FPS, base frame, and recordFrame calculation for time-based placement
Convert a time value in seconds into an absolute Timeline frame suitable for recordFrame and other frame-based Resolve API operations.
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_timeline_fps(project, timeline, default: float = 24.0) -> float:
value = safe_call(timeline, "GetSetting", "timelineFrameRate")
if not value:
value = safe_call(project, "GetSetting", "timelineFrameRate")
try:
return float(value)
except Exception:
return float(default)
def get_timeline_base_frame(timeline) -> int:
value = safe_call(timeline, "GetStartFrame")
try:
return int(value)
except Exception:
return 0
def seconds_to_abs_frame(seconds: float, fps: float, base_frame: int = 0) -> int:
return int(round(base_frame + max(0.0, float(seconds)) * float(fps)))
resolve, project, timeline = get_project_and_timeline()
fps = get_timeline_fps(project, timeline)
base_frame = get_timeline_base_frame(timeline)
record_frame = seconds_to_abs_frame(12.5, fps, base_frame)
print("FPS:", fps, "recordFrame:", record_frame)
Guide
What the converter does
The script reads the Timeline frame rate and start frame, then converts a duration in seconds into an absolute Timeline frame that can be passed to recordFrame or another frame-based API parameter.
Why base_frame matters
A Timeline does not have to begin at frame zero. Ignoring its start frame can shift automated placements relative to the project’s actual Timeline position and displayed timecode.
Where to reuse the calculation
The same conversion is useful for AppendToTimeline, playhead movement, range construction, segment export, and any integration where timing arrives in seconds but Resolve expects frame positions.
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 seconds to timeline frames for 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
- Read FPS from the active Timeline instead of hard-coding it.
- Clamp negative second values when your workflow does not support positions before the Timeline start.
- recordFrame should be an integer.
- For projects with unusual starting timecode, inspect GetStartTimecode() as an additional validation signal.
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 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 Get the Timeline Start Frame with the DaVinci Resolve API
Read the Timeline base frame with GetStartFrame when available, fall back to GetStart on compatible builds, and avoid assuming that every Timeline begins at frame zero.
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.

