Skip to content

Instantly share code, notes, and snippets.

@DanielBaulig
Created March 8, 2023 21:22
Show Gist options
  • Save DanielBaulig/3b95897e705d664ca8c597316527c5ab to your computer and use it in GitHub Desktop.
Save DanielBaulig/3b95897e705d664ca8c597316527c5ab to your computer and use it in GitHub Desktop.
Davinci Resolve Script to calculate the total duration of all clips on a track, filterable by clip color
# Configuration
# Track to be used to calculate duration
videoTrack = 1
# Clip color to filter for; empty is default
filterColor = ""
# Frames per second used
fps = 60
from datetime import timedelta
manager = resolve.GetProjectManager()
manager.SaveProject()
project = manager.GetCurrentProject()
timeline = project.GetCurrentTimeline()
timelineItems = timeline.GetItemListInTrack('Video', 1)
totalDurationFrames = 0
for item in timelineItems:
totalDurationFrames += item.GetDuration() if item.GetClipColor() == filterColor else 0
totalDurationTimeDelta = timedelta(seconds=totalDurationFrames/fps)
print("Total Duration (frames):", totalDurationFrames)
print("Total Duration:", totalDurationTimeDelta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment