diff --git a/ptulsconv/broadcast_timecode.py b/ptulsconv/broadcast_timecode.py index 6712033..4c2ce1a 100644 --- a/ptulsconv/broadcast_timecode.py +++ b/ptulsconv/broadcast_timecode.py @@ -3,8 +3,7 @@ import re import math -def smpte_to_frame_count(smpte_rep_string: str, frames_per_logical_second: int, drop_frame_hint=False, - include_fractional=False) -> object: +def smpte_to_frame_count(smpte_rep_string: str, frames_per_logical_second: int, drop_frame_hint=False) -> int: """ Convert a string with a SMPTE timecode representation into a frame count. @@ -40,10 +39,10 @@ def smpte_to_frame_count(smpte_rep_string: str, frames_per_logical_second: int, dropped_frames = frames_dropped_per_inst * inst_count frames = raw_frames - dropped_frames - if include_fractional: - return frames, frac - else: - return frames + # if include_fractional: + # return frames, frac + # else: + return frames def frame_count_to_smpte(frame_count: int, frames_per_logical_second: int, drop_frame: bool = False, diff --git a/ptulsconv/docparser/doc_entity.py b/ptulsconv/docparser/doc_entity.py index 5d49a0c..a63cb03 100644 --- a/ptulsconv/docparser/doc_entity.py +++ b/ptulsconv/docparser/doc_entity.py @@ -4,6 +4,13 @@ from typing import Tuple, List class SessionDescriptor: + header: "HeaderDescriptor" + files: List["FileDescriptor"] + clips: List["ClipDescriptor"] + plugins: List["PluginDescriptor"] + tracks: List["TrackDescriptor"] + markers: List["MarkerDescriptor"] + def __init__(self, **kwargs): self.header = kwargs['header'] self.files = kwargs['files'] @@ -38,8 +45,7 @@ class HeaderDescriptor: def convert_timecode(self, tc_string) -> Fraction: frame_count = smpte_to_frame_count(tc_string, self.logical_fps, - self.timecode_drop_frame, - include_fractional=False) + self.timecode_drop_frame) return self.frame_duration * frame_count @@ -53,20 +59,20 @@ class HeaderDescriptor: @property def logical_fps(self) -> int: - return self._get_tcformat_params[0] + return self._get_tc_format_params[0] @property def frame_duration(self) -> Fraction: - return self._get_tcformat_params[1] + return self._get_tc_format_params[1] @property - def _get_tcformat_params(self) -> Tuple[int, Fraction]: + def _get_tc_format_params(self) -> Tuple[int, Fraction]: frame_rates = {"23.976": (24, Fraction(1001, 24_000)), - "24": (24, Fraction(1, 24)), - "29.97": (30, Fraction(1001, 30_000)), - "30": (30, Fraction(1, 30)), - "59.94": (60, Fraction(1001, 60_000)), - "60": (60, Fraction(1, 60)) + "24": (24, Fraction(1, 24)), + "29.97": (30, Fraction(1001, 30_000)), + "30": (30, Fraction(1, 30)), + "59.94": (60, Fraction(1001, 60_000)), + "60": (60, Fraction(1, 60)) } if self.timecode_format in frame_rates.keys(): diff --git a/tests/test_broadcast_timecode.py b/tests/test_broadcast_timecode.py index a17910f..4f416b9 100644 --- a/tests/test_broadcast_timecode.py +++ b/tests/test_broadcast_timecode.py @@ -32,12 +32,6 @@ class TestBroadcastTimecode(unittest.TestCase): s1 = broadcast_timecode.frame_count_to_smpte(c1, 30, drop_frame=True) self.assertEqual(s1, "01:00:03;18") - def test_fractional_to_framecount(self): - s1 = "00:00:01:04.105" - c1, f1 = broadcast_timecode.smpte_to_frame_count(s1, 24, drop_frame_hint=False, include_fractional=True) - self.assertEqual(c1, 28) - self.assertEqual(f1, 0.105) - def test_fractional_to_string(self): c1 = 99 f1 = .145 @@ -66,10 +60,6 @@ class TestBroadcastTimecode(unittest.TestCase): f1 = broadcast_timecode.footage_to_frame_count(s1) self.assertEqual(f1, 3115) - s2 = "1+1.014" - f2 = broadcast_timecode.footage_to_frame_count(s2, include_fractional=True) - self.assertEqual(f2, (17, 0.014)) - s3 = "0+0.1" f3 = broadcast_timecode.footage_to_frame_count(s3, include_fractional=False) self.assertEqual(f3, 0) diff --git a/tests/test_doc_entities.py b/tests/test_doc_entities.py index ef5ca6e..ea9b92c 100644 --- a/tests/test_doc_entities.py +++ b/tests/test_doc_entities.py @@ -17,7 +17,7 @@ class DocParserTestCase(unittest.TestCase): count_files=0) self.assertEqual(header.session_name, "Test Session") - self.assertEqual(header.convert_timecode(header.start_timecode), Fraction((59 * 60 + 52) * 30, 30)) + self.assertEqual(header.start_time, Fraction((59 * 60 + 52) * 30, 30)) if __name__ == '__main__':