def test_sub_from_str_spd(self): s = sub_from_str( 'a=00:00:01.0,b=00:00:02.0,spd=0.5') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta,1*1000) self.assertEqual(s.tb,2*1000) self.assertEqual(s.spd,0.5)
def test_sub_from_str_dur(self): s = sub_from_str( 'a=01:20:31.59,b=01:21:34.0,dur=3') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta,(1*3600+20*60+31.59)*1000) self.assertEqual(s.tb,(1*3600+21*60+34.0)*1000) self.assertEqual(s.dur,3*1000)
def test_sub_from_str_non_rational_fraction(self): s = sub_from_str( 'a=00:00:00.5,b=00:00:01.0,fps=24/1.001') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta,0.5*1000) self.assertEqual(s.tb,1.0*1000) self.assertEqual(s.fps,24/1.001)
def test_sub_from_str_fps(self): s = sub_from_str( 'a=00:05:00.0,b=00:05:30.0,fps=59.94') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta,(5*60)*1000) self.assertEqual(s.tb,(5*60+30)*1000) self.assertEqual(s.fps,59.94)
def test_sub_from_str_time_a_greater_than_time_b_fails(self): with self.assertRaises(ValueError): s = sub_from_str('a=00:00:02.0,b=00:00:01.0,spd=2')
def test_sub_from_str_spd(self): s = sub_from_str('a=00:00:01.0,b=00:00:02.0,spd=0.5') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta, 1 * 1000) self.assertEqual(s.tb, 2 * 1000) self.assertEqual(s.spd, 0.5)
def test_sub_from_str_dur(self): s = sub_from_str('a=01:20:31.59,b=01:21:34.0,dur=3') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta, (1 * 3600 + 20 * 60 + 31.59) * 1000) self.assertEqual(s.tb, (1 * 3600 + 21 * 60 + 34.0) * 1000) self.assertEqual(s.dur, 3 * 1000)
def test_sub_from_str_non_rational_fraction(self): s = sub_from_str('a=00:00:00.5,b=00:00:01.0,fps=24/1.001') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta, 0.5 * 1000) self.assertEqual(s.tb, 1.0 * 1000) self.assertEqual(s.fps, 24 / 1.001)
def test_sub_from_str_fps(self): s = sub_from_str('a=00:05:00.0,b=00:05:30.0,fps=59.94') self.assertIsInstance(s, RenderSubregion) self.assertEqual(s.ta, (5 * 60) * 1000) self.assertEqual(s.tb, (5 * 60 + 30) * 1000) self.assertEqual(s.fps, 59.94)
def test_sub_from_str_time_a_greater_than_time_b_fails(self): with self.assertRaises(ValueError): s = sub_from_str( 'a=00:00:02.0,b=00:00:01.0,spd=2')