def video_entries(self):
entries = []
for attr in self.session['children']:
- if 'playlist' in attr['name'] and 'children' in attr:
+ if 'playlist' in attr['name'] and 'children' in attr and not 'main' in attr['attributes']['id']:
for att in attr['children']:
if 'entry' in att['name'] and att['attributes']['producer'] != 'black' \
and not 'audio' in att['attributes']['producer']:
return sorted(self.entries(), key=lambda k: int(k['in']), reverse=False)
def entries_video_seconds(self):
- fps = float(self.profile()['frame_rate_num'])/1000
+ profile = self.profile()
+ fps = float(profile['frame_rate_num'])/float(profile['frame_rate_den'])
#fps= 25
- list = []
+ res = []
+ start = 0
entries = self.video_entries()
- for i in range(0,len(entries)):
- id = entries[i]['producer'].split('_')[0]
- t_in = int(entries[i]['in'])/fps
- t_out = int(entries[i]['out'])/fps
-
- if i == 0:
- t = 0
- else:
- t = list[i-1]['t'] + int(entries[i-1]['out'])/fps - int(entries[i-1]['in'])/fps
- list.append({'id' : id, 't': t, 'in': t_in , 'out': t_out })
-
- return list
+ for entry in entries:
+ id = entry['producer'].split('_')[0]
+ t_in = int(entry['in'])/fps
+ t_out = int(entry['out'])/fps
+ t_len = t_out - t_in
+ end = start + t_len
+ res.append({ 'id': str(id), 't': start, 'in': t_in, 'out': t_out })
+ start = end
+ return res
def cuts(self, entries):
i = 0
name = att['attributes']['name']
if 'marker' in name:
name = name.encode('utf8')
- print(name)
marker_time = float(name.split(':')[-1].replace(',','.').replace(' ', ''))
- id = name.split(':')[-2].split('.')[-1]
+ id = str(name.split(':')[-2].split('.')[-1])
rel_time = 0
for entry in entries:
- if marker_time >= entry['in'] and marker_time <= entry['out'] and id == entry['id']:
+ if entry['in'] <= marker_time <= entry['out'] and id == entry['id']:
if i == 0 and from_first_marker:
abs_time = entry['t']
rel_time = entry['t'] + (marker_time - entry['in']) - abs_time + offset
break
+ else:
+ continue
marker['time'] = rel_time
marker['session_timecode'] = time.strftime('%H:%M:%S', time.gmtime(rel_time))