本文整理汇总了Python中timecode.Timecode类的典型用法代码示例。如果您正苦于以下问题:Python Timecode类的具体用法?Python Timecode怎么用?Python Timecode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timecode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_tc_to_frame_test_in_2997
def test_tc_to_frame_test_in_2997(self):
"""testing if timecode to frame conversion is ok in 2997
"""
tc = Timecode('29.97', '00:00:00:00')
self.assertEqual(tc.frames, 1)
tc = Timecode('29.97', '00:00:00:21')
self.assertEqual(tc.frames, 22)
tc = Timecode('29.97', '00:00:00:29')
self.assertEqual(tc.frames, 30)
tc = Timecode('29.97', '00:00:00:60')
self.assertEqual(tc.frames, 61)
tc = Timecode('29.97', '00:00:01:00')
self.assertEqual(tc.frames, 31)
tc = Timecode('29.97', '00:00:10:00')
self.assertEqual(tc.frames, 301)
# test with non existing timecodes
tc = Timecode('29.97', '00:01:00:00')
self.assertEqual(1799, tc.frames)
self.assertEqual('00:00:59:28', tc.__str__())
# test the limit
tc = Timecode('29.97', '23:59:59:29')
self.assertEqual(2589408, tc.frames)
开发者ID:davekimgreat,项目名称:timecode,代码行数:29,代码来源:test_timecode.py
示例2: test_framerate_can_be_changed
def test_framerate_can_be_changed(self):
"""testing if the timecode value will be automaticall updated when the
framerate attribute is changed
"""
tc1 = Timecode('25', frames=100)
self.assertEqual('00:00:03:24', tc1.__str__())
self.assertEqual(100, tc1.frames)
tc1.framerate = '12'
self.assertEqual('00:00:08:03', tc1.__str__())
self.assertEqual(100, tc1.frames)
开发者ID:davekimgreat,项目名称:timecode,代码行数:11,代码来源:test_timecode.py
示例3: test_toggle_fractional_frame
def test_toggle_fractional_frame(self):
tc = Timecode(24, 421729315)
self.assertEqual(tc.__repr__(), '19:23:14:23')
tc.set_fractional(True)
self.assertEqual(tc.__repr__(), '19:23:14.958')
tc.set_fractional(False)
self.assertEqual(tc.__repr__(), '19:23:14:23')
开发者ID:eoyilmaz,项目名称:timecode,代码行数:9,代码来源:test_timecode.py
示例4: test_24_hour_limit_in_2997fps
def test_24_hour_limit_in_2997fps(self):
"""testing if the timecode will loop back to 00:00:00:00 after 24 hours
in 29.97 fps
"""
tc = Timecode('29.97', '00:00:00:21')
self.assertTrue(tc.drop_frame)
self.assertEqual(22, tc.frames)
tc2 = Timecode('29.97', '23:59:59:29')
self.assertTrue(tc2.drop_frame)
self.assertEqual(2589408, tc2.frames)
self.assertEqual(
'00:00:00:21',
tc.__repr__()
)
self.assertEqual(
'23:59:59:29',
tc2.__repr__()
)
self.assertEqual(
'00:00:00:21',
(tc + tc2).__str__()
)
self.assertEqual(
'02:00:00:00',
(tc2 + 215785).__str__()
)
self.assertEqual(
'02:00:00:00',
(tc2 + 215785 + 2589408).__str__()
)
self.assertEqual(
'02:00:00:00',
(tc2 + 215785 + 2589408 + 2589408).__str__()
)
开发者ID:davekimgreat,项目名称:timecode,代码行数:40,代码来源:test_timecode.py
示例5: test_frame_to_tc
def test_frame_to_tc(self):
def assertFrameToTC(tc_, hrs, mins, secs, frs):
self.assertEqual(hrs, tc_.hrs)
self.assertEqual(mins, tc_.mins)
self.assertEqual(secs, tc_.secs)
self.assertEqual(frs, tc_.frs)
tc = Timecode('29.97', '00:00:00:01')
assertFrameToTC(tc, 0, 0, 0, 1)
self.assertEqual('00:00:00:01', tc.__str__())
test_code = '03:36:09:23'
framerates = ['23.98', '24', '25', '29.97', '30', '59.94', '60']
for fr in framerates:
tc = Timecode(fr, test_code)
assertFrameToTC(tc, 3, 36, 9, 23)
tc = Timecode('ms', '03:36:09:230')
assertFrameToTC(tc, 3, 36, 9, 230)
tc = Timecode('24', frames=12000)
assertFrameToTC(tc, 0, 8, 19, 23)
self.assertEqual('00:08:19:23', tc.__str__())
开发者ID:AdricEpic,项目名称:timecode,代码行数:25,代码来源:test_timecode.py
示例6: test_drop_frame
def test_drop_frame(self):
tc = Timecode('29.97', '13:36:59:29')
timecode = tc.next()
self.assertEqual("13:37:00:02", timecode.__str__())
tc = Timecode('59.94', '13:36:59:59')
self.assertEqual("13:36:59:59", tc.__str__())
timecode = tc.next()
self.assertEqual("13:37:00:04", timecode.__str__())
tc = Timecode('59.94', '13:39:59:59')
timecode = tc.next()
self.assertEqual("13:40:00:00", timecode.__str__())
tc = Timecode('29.97', '13:39:59:29')
timecode = tc.next()
self.assertEqual("13:40:00:00", timecode.__str__())
开发者ID:davekimgreat,项目名称:timecode,代码行数:18,代码来源:test_timecode.py
示例7: test_rational_frame_delimiter
def test_rational_frame_delimiter(self):
tc = Timecode('24000/1000', frames=1)
self.assertFalse(';' in tc.__repr__())
tc = Timecode('24000/1001', frames=1)
self.assertFalse(';' in tc.__repr__())
tc = Timecode('30000/1001', frames=1)
self.assertTrue(';' in tc.__repr__())
开发者ID:eoyilmaz,项目名称:timecode,代码行数:9,代码来源:test_timecode.py
示例8: xml_paser
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']})
开发者ID:djlevi,项目名称:xml2shots,代码行数:97,代码来源:xml_2_shotgun.py
示例9: test_24_hour_limit
def test_24_hour_limit(self):
"""testing if the timecode will loop back to 00:00:00:00 after 24 hours
in 29.97 fps
"""
tc0 = Timecode('59.94', '23:59:59:29')
self.assertEqual(5178786, tc0.frames)
tc0 = Timecode('29.97', '23:59:59:29')
self.assertEqual(2589408, tc0.frames)
tc1 = Timecode('29.97', frames=2589408)
self.assertEqual('23:59:59:29', tc1.__str__())
tc2 = Timecode('29.97', '23:59:59:29')
tc3 = tc2 + 1
self.assertEqual('00:00:00:00', tc3.__str__())
tc2 = Timecode('29.97', '23:59:59:29')
tc3 = tc2 + 21
self.assertEqual('00:00:00:20', tc3.__str__())
tc = Timecode('29.97', '00:00:00:21')
tc2 = Timecode('29.97', '23:59:59:29')
tc3 = (tc + tc2)
self.assertEqual('00:00:00:21', tc3.__str__())
tc = Timecode('29.97', '04:20:13:21')
tca = Timecode('29.97', frames=467944)
self.assertEqual(467944, tca.frames)
self.assertEqual(467944, tc.frames)
self.assertEqual('04:20:13:21', tca.__str__())
self.assertEqual('04:20:13:21', tc.__str__())
tc2 = Timecode('29.97', '23:59:59:29')
self.assertEqual(2589408, tc2.frames)
self.assertEqual('23:59:59:29', tc2.__str__())
tc2a = Timecode('29.97', frames=2589408)
self.assertEqual(2589408, tc2a.frames)
self.assertEqual('23:59:59:29', tc2a.__str__())
tc3 = (tc + tc2)
self.assertEqual('04:20:13:21', tc3.__str__())
tc = Timecode('59.94', '04:20:13:21')
self.assertEqual('04:20:13:21', tc.__str__())
tca = Timecode('59.94', frames=935866)
self.assertEqual('04:20:13:21', tc.__str__())
tc2 = Timecode('59.94', '23:59:59:59')
tc3 = (tc + tc2)
self.assertEqual('04:20:13:21', tc3.__str__())
开发者ID:davekimgreat,项目名称:timecode,代码行数:51,代码来源:test_timecode.py
示例10: test_timecode_init
def test_timecode_init(self):
"""testing several timecode initialization
"""
tc = Timecode('29.97')
self.assertEqual('00:00:00:00', tc.__str__())
self.assertEqual(1, tc.frames)
tc = Timecode('29.97', '00:00:00:01')
self.assertEqual(2, tc.frames)
tc = Timecode('29.97', '03:36:09:23')
self.assertEqual(388704, tc.frames)
tc = Timecode('29.97', '03:36:09:23')
self.assertEqual(388704, tc.frames)
tc = Timecode('30', '03:36:09:23')
self.assertEqual(389094, tc.frames)
tc = Timecode('25', '03:36:09:23')
self.assertEqual(324249, tc.frames)
tc = Timecode('59.94', '03:36:09:23')
self.assertEqual(777384, tc.frames)
tc = Timecode('60', '03:36:09:23')
self.assertEqual(778164, tc.frames)
tc = Timecode('59.94', '03:36:09:23')
self.assertEqual(777384, tc.frames)
tc = Timecode('23.98', '03:36:09:23')
self.assertEqual(311280, tc.frames)
tc = Timecode('24', '03:36:09:23')
self.assertEqual(311280, tc.frames)
tc = Timecode('ms', '03:36:09:230')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(230, tc.frs)
tc = Timecode('24', frames=12000)
self.assertEqual('00:08:19:23', tc.__str__())
tc = Timecode('29.97', frames=2589408)
self.assertEqual('23:59:59:29', tc.__str__())
tc = Timecode('29.97', frames=2589409)
self.assertEqual('00:00:00:00', tc.__str__())
tc = Timecode('59.94', frames=5178816)
self.assertEqual('23:59:59:59', tc.__str__())
tc = Timecode('59.94', frames=5178817)
self.assertEqual('00:00:00:00', tc.__str__())
开发者ID:davekimgreat,项目名称:timecode,代码行数:57,代码来源:test_timecode.py
示例11: test_repr_overload
def test_repr_overload(self):
timeobj = Timecode('24', '01:00:00:00')
self.assertEqual('01:00:00:00', timeobj.__repr__())
timeobj = Timecode('23.98', '20:00:00:00')
self.assertEqual('20:00:00:00', timeobj.__repr__())
timeobj = Timecode('29.97', '00:09:00:00')
self.assertEqual('00:08:59:28', timeobj.__repr__())
timeobj = Timecode('30', '00:10:00:00')
self.assertEqual('00:10:00:00', timeobj.__repr__())
timeobj = Timecode('60', '00:00:09:00')
self.assertEqual('00:00:09:00', timeobj.__repr__())
timeobj = Timecode('59.94', '00:00:20:00')
self.assertEqual('00:00:20:00', timeobj.__repr__())
timeobj = Timecode('ms', '00:00:00:900')
self.assertEqual('00:00:00:900', timeobj.__repr__())
timeobj = Timecode('24', frames=49)
self.assertEqual('00:00:02:00', timeobj.__repr__())
开发者ID:davekimgreat,项目名称:timecode,代码行数:24,代码来源:test_timecode.py
示例12: test_iteration
def test_iteration(self):
tc = Timecode('29.97', '03:36:09:23')
self.assertEqual("03:36:09:23", tc)
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:11:23", t)
self.assertEqual(388764, tc.frames)
tc = Timecode('29.97', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:11:23", t)
self.assertEqual(388764, tc.frames)
tc = Timecode('30', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:11:23", t)
self.assertEqual(389154, tc.frames)
tc = Timecode('25', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:12:08", t)
self.assertEqual(324309, tc.frames)
tc = Timecode('59.94', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:10:23", t)
self.assertEqual(777444, tc.frames)
tc = Timecode('60', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:10:23", t)
self.assertEqual(778224, tc.frames)
tc = Timecode('59.94', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:10:23", t)
self.assertEqual(777444, tc.frames)
tc = Timecode('23.98', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:12:11", t)
self.assertEqual(311340, tc.frames)
tc = Timecode('24', '03:36:09:23')
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("03:36:12:11", t)
self.assertEqual(311340, tc.frames)
tc = Timecode('ms', '03:36:09:230')
for x in range(60):
t = tc.next()
self.assertIsNotNone(t)
self.assertEqual('03:36:09:290', t)
self.assertEqual(12969291, tc.frames)
tc = Timecode('24', frames=12000)
for x in range(60):
t = tc.next()
self.assertTrue(t)
self.assertEqual("00:08:22:11", t)
self.assertEqual(12060, tc.frames)
开发者ID:davekimgreat,项目名称:timecode,代码行数:78,代码来源:test_timecode.py
示例13: test_frame_to_tc
def test_frame_to_tc(self):
tc = Timecode('29.97', '00:00:00:01')
self.assertEqual(0, tc.hrs)
self.assertEqual(0, tc.mins)
self.assertEqual(0, tc.secs)
self.assertEqual(1, tc.frs)
self.assertEqual('00:00:00:01', tc.__str__())
tc = Timecode('29.97', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('29.97', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('30', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('25', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('59.94', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('60', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('59.94', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('23.98', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('24', '03:36:09:23')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(23, tc.frs)
tc = Timecode('ms', '03:36:09:230')
self.assertEqual(3, tc.hrs)
self.assertEqual(36, tc.mins)
self.assertEqual(9, tc.secs)
self.assertEqual(230, tc.frs)
tc = Timecode('24', frames=12000)
self.assertEqual('00:08:19:23', tc.__str__())
self.assertEqual(0, tc.hrs)
self.assertEqual(8, tc.mins)
self.assertEqual(19, tc.secs)
self.assertEqual(23, tc.frs)
开发者ID:davekimgreat,项目名称:timecode,代码行数:74,代码来源:test_timecode.py
示例14: frameToTC
def frameToTC(frame, base=TC_BASE):
tc = Timecode(base, '00:00:00:00')
tc.frames = frame
return tc
开发者ID:worrytron,项目名称:py,代码行数:5,代码来源:edlToLog.py
注:本文中的timecode.Timecode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论