mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
Update broadcast_timecode.py
File reformat
This commit is contained in:
@@ -48,14 +48,14 @@ def smpte_to_frame_count(smpte_rep_string: str, frames_per_logical_second: int,
|
||||
|
||||
def frame_count_to_smpte(frame_count: int, frames_per_logical_second: int, drop_frame: bool = False,
|
||||
fractional_frame: float = None):
|
||||
assert frames_per_logical_second in [24,25,30,48,50,60]
|
||||
assert frames_per_logical_second in [24, 25, 30, 48, 50, 60]
|
||||
assert fractional_frame is None or fractional_frame < 1.0
|
||||
|
||||
nominal_frames = frame_count
|
||||
separator = ":"
|
||||
if drop_frame:
|
||||
assert frames_per_logical_second in [30, 60]
|
||||
mins , _= divmod(nominal_frames, frames_per_logical_second * 60)
|
||||
mins, _ = divmod(nominal_frames, frames_per_logical_second * 60)
|
||||
frames_dropped_per_inst = (frames_per_logical_second / 15)
|
||||
inst_count = mins - math.floor(mins / 10)
|
||||
dropped_frames = frames_dropped_per_inst * inst_count
|
||||
@@ -72,7 +72,8 @@ def frame_count_to_smpte(frame_count: int, frames_per_logical_second: int, drop_
|
||||
else:
|
||||
return "%02i:%02i:%02i%s%02i" % (hh, mm, ss, separator, ff)
|
||||
|
||||
def footage_to_frame_count(footage_string, include_fractional = False):
|
||||
|
||||
def footage_to_frame_count(footage_string, include_fractional=False):
|
||||
m = re.search("(\d+)\+(\d+)(\.\d+)?", footage_string)
|
||||
feet, frm, frac = m.groups()
|
||||
feet, frm, frac = int(feet), int(frm), float(frac or 0.0)
|
||||
@@ -84,10 +85,12 @@ def footage_to_frame_count(footage_string, include_fractional = False):
|
||||
else:
|
||||
return frames
|
||||
|
||||
def frame_count_to_footage(frame_count, fractional_frames = None):
|
||||
assert fractional_frames < 1.0 or fractional_frames is None
|
||||
|
||||
def frame_count_to_footage(frame_count, fractional_frames=None):
|
||||
assert fractional_frames is None or fractional_frames < 1.0
|
||||
feet, frm = divmod(frame_count, 16)
|
||||
if fractional_frames:
|
||||
|
||||
if fractional_frames is None:
|
||||
return "%i+%02i" % (feet, frm)
|
||||
else:
|
||||
return "%i+%02i%s" % (feet, frm, ("%.3f" % fractional_frames)[1:])
|
||||
return "%i+%02i%s" % (feet, frm, ("%.3f" % fractional_frames)[1:])
|
||||
|
||||
Reference in New Issue
Block a user