-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHD_index.py
More file actions
28 lines (25 loc) · 1.03 KB
/
HD_index.py
File metadata and controls
28 lines (25 loc) · 1.03 KB
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
import glob
from time_utils import convert_hex_line_to_ms, convert_ms_to_time
class HD_index:
#2014_06_06_13_38_35421
def __init__(self, directory):
self.times = []
index_file = glob.glob("{}/HiRes/*/*/lightson.ist".format(directory))[0]
fp = open(index_file,'rb')
line = fp.read(22)
parts = line.rstrip().split("_")
self.date = parts[0] + "_" + parts[1] + "_" + parts[2]
while len(line) == 22:
self.times.append(convert_hex_line_to_ms(line))
fp.read(1)
line = fp.read(22)
def convert_scroll_to_time(self, scroll):
index = int(len(self.times)*scroll)
return self.times[index]
def get_range(self, start_time, stop_time):
result = [time for time in self.times if time >=start_time and time <= stop_time]
return result
def get_frame_name(self,ms):
time_string = convert_ms_to_time(ms)
return_val = self.date + "_" + time_string + ".jpg"
return return_val