-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline.py
36 lines (26 loc) · 1.01 KB
/
timeline.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
from typing import Any
import prefs
class Timeline:
name : str
startTime : float
endTime : float
mediaPool : Any
def __init__(self, timeline, mediaPool) -> None:
self.timeline = timeline
self.mediaPool = mediaPool
def __str__(self) -> str:
return f'{self.name}\t{self.startTime}\t{self.endTime}'
def coversTimestamp(self, timeToCheck : float) -> bool:
if (timeToCheck >= self.startTime) and (timeToCheck <= self.endTime):
result = True
else:
result = False
return result
def TimestampToFrameID(self, timestamp:float) -> float:
floatFrameID = (timestamp - self.startTime) * prefs.TIMELINE_FPS
frameID = round(floatFrameID, 0)
return frameID
def TimestampToRecordFrame(self, timestamp:float) -> float:
startFrame = self.timeline.GetStartFrame()
recordFrame = startFrame + self.TimestampToFrameID(timestamp)
return recordFrame