本文整理汇总了Python中timecode.Timecode.frames方法的典型用法代码示例。如果您正苦于以下问题:Python Timecode.frames方法的具体用法?Python Timecode.frames怎么用?Python Timecode.frames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timecode.Timecode
的用法示例。
在下文中一共展示了Timecode.frames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xml_paser
# 需要导入模块: from timecode import Timecode [as 别名]
# 或者: from timecode.Timecode import frames [as 别名]
def xml_paser(self):
with open(self.xmlFile, 'rt') as f:
tree = ElementTree.parse(f)
root = tree.getroot()
#complete event list with tansition events, clip events and several tracks
event_list = []
for sequence_item in root.findall("./sequence"):
sec_name = sequence_item.find('name').text.split(" (")[0]
sec_framerate = int(sequence_item.find('./timecode/rate/timebase').text)
sec_cut_in = int(sequence_item.find('./timecode/frame').text)
sec_tc_in = Timecode(sec_framerate, sequence_item.find('./timecode/string').text)
sec_tc_duration = Timecode(sec_framerate,)
sec_tc_duration.frames = int(sequence_item.find('./duration').text)
sec_tc_out = sec_tc_in + sec_tc_duration
self.sequence_info = {"sec_name":sec_name,"sec_framerate":sec_framerate,\
"sec_cut_duration":sec_tc_duration.frames,"sec_tc_in":sec_tc_in,"sec_tc_out":sec_tc_out,\
"sec_cut_in":sec_cut_in,"sec_cut_out":sec_tc_out.frame_number}
#print sequence_info
video_tree = root.find('sequence/media/video')
for child in video_tree.iter():
if child.tag == 'clipitem':
#print "------------------------"
#print child.tag
clip_occurence = child.attrib['id'].split()[-1]
#print "id: ", clip_occurence
clip_item = {"type":child.tag}
for element in child:
if element.tag in ('name', 'duration', 'start', 'end', 'in', 'out'):
clip_item.update({element.tag:element.text})
if element.tag == "file":
if clip_occurence == "0":
#print "SOURCE CLIP NUEVO"
for field in element.iter():
if field.tag == 'pathurl':
#unquote translate symbols to url chars
file_path = unquote(field.text.split("//")[1])
clip_item.update({field.tag:file_path})
elif field.tag == 'timecode':
for subfield in field.iter():
if subfield.tag == "string":
clip_item.update({"clip_tc_in":subfield.text})
else:
#print "SOURCE CLIP EXISTENTE"
for event_list_item in event_list:
if clip_item['name'] in event_list_item.values():
clip_item.update({"pathurl":event_list_item["pathurl"]})
clip_item.update({"clip_tc_in":event_list_item["clip_tc_in"]})
clip_in = Timecode(sec_framerate,)
clip_in.frames = int(clip_item['in'])
shot_tc_source_in = Timecode(sec_framerate,clip_item['clip_tc_in']) + clip_in
clip_out = Timecode(sec_framerate,)
clip_out.frames = int(clip_item['out'])
shot_tc_source_out = Timecode(sec_framerate,clip_item['clip_tc_in']) + clip_out
clip_item.update({"shot_tc_source_in": str(shot_tc_source_in)})
clip_item.update({"shot_tc_source_out": str(shot_tc_source_out)})
###zero based frame numbers
clip_item.update({"shot_cut_source_in": str(shot_tc_source_in.frame_number)})
clip_item.update({"shot_cut_source_out": str(shot_tc_source_out.frame_number)})
clip_item.update({"cut_duration": int(clip_item['out'])-int(clip_item['in'])})
#print clip_item
event_list.append(clip_item)
elif child.tag == 'transitionitem':
#print "------------------------"
#print child.tag
clip_item = {"type":child.tag}
for element in child.iter():
if element.tag in ("start", "end", "name"):
clip_item.update({element.tag:element.text})
event_list.append(clip_item)
###seek for transitioned start or end clips and update record tc
for event_list_item in event_list:
if event_list_item['type'] == 'clipitem':
if event_list_item['start'] == "-1":
clip_item_index = event_list.index(event_list_item)
transition_data = event_list[clip_item_index-1]
event_list_item['start']=transition_data['start']
tc_start=Timecode(sec_framerate,)
tc_start.frames=int(event_list_item['start'])
event_list_item.update({'record_tc_in':self.sequence_info['sec_tc_in']+tc_start})
if event_list_item['end'] == "-1":
clip_item_index = event_list.index(event_list_item)
transition_data = event_list[clip_item_index+1]
event_list_item['end']=transition_data['end']
tc_end=Timecode(sec_framerate,)
tc_end.frames=int(event_list_item['end'])
event_list_item.update({'record_tc_out':self.sequence_info['sec_tc_in']+tc_end})
self.shot_list.append(event_list_item)
#order shot list by start frame on record (record cut in)
self.shot_list = sorted(self.shot_list, key=lambda k: int(k['start']))
for idx, shot_list_item in enumerate(self.shot_list):
#cut order is index with 3d padding begining in 1 multiple of 10 for interpolate new posible shots manually
shot_list_item.update({"cut_order": "{0:03d}".format((idx+1)*10)})
shot_list_item.update({"shot_code": "PL_" + str(shot_list_item["cut_order"]) + "_" + self.sequence_info['sec_name']})
示例2: frameToTC
# 需要导入模块: from timecode import Timecode [as 别名]
# 或者: from timecode.Timecode import frames [as 别名]
def frameToTC(frame, base=TC_BASE):
tc = Timecode(base, '00:00:00:00')
tc.frames = frame
return tc