-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurrentTimelineItem Beat Marker.py
74 lines (57 loc) · 1.8 KB
/
CurrentTimelineItem Beat Marker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/ python
# Beat Marker Python Script
# Made for Resolve V16.2 free
# Copyright 2020 Guillaume Hullin, www.youtube.com/GuillaumeHullin
### CONFIGUARATION VARIABLES
# FPS of your timeline
fps = 30
# Beats per minutes
bpm = 130
# How many beats per time
time= 4
# Offset the beat by the number of frame
offset = 20.0
# On which audio track is your sound and which item number is your item
track = 2
item = 1
### END CONFIGURATION
import sys
#sys.path.append("C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules")
sys.path.append("/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules")
import DaVinciResolveScript as dvr_script
try:
resolve = dvr_script.scriptapp("Resolve")
pm = resolve.GetProjectManager()
proj = pm.GetCurrentProject()
tl = proj.GetCurrentTimeline()
mp = proj.GetMediaPool()
rootfolder = mp.GetRootFolder()
rootclips = rootfolder.GetClips()
ms = resolve.GetMediaStorage()
folder = mp.GetCurrentFolder()
clips = folder.GetClips()
except:
print("Open the script file and copy/paste in DVR Console :)")
sys.exit()
# Get the item of the audio track
tli = tl.GetItemsInTrack("audio", track)
tli = tli[item]
max = tli.GetDuration()
# Calculate where should be placed the beat marker (return the frameNbr)
def calcBeatFrame(beatNbr):
global offset
return (((60.0/bpm)*fps)*beatNbr)+offset
tli.DeleteMarkersByColor('Red')
tli.DeleteMarkersByColor('Yellow')
beat = 0.0
x = 0
while beat < max:
x += 1
beat = calcBeatFrame(x)
if x % time:
tli.AddMarker(beat, 'Yellow', 'Beat Nbr{}'.format(x) , '', 1.0)
else:
tli.AddMarker(beat, 'Red', 'Beat Nbr{}'.format(x) , '', 1.0)
print 'Beat Nbr{} created at {} frame'.format(x,beat)
print
print 'End of script'