From 26204eb9804c6cca79ea16a5fefed7f98af0a27d Mon Sep 17 00:00:00 2001 From: Adrian of Doom <52701496+futzu@users.noreply.github.com> Date: Sun, 24 Nov 2024 20:10:32 -0500 Subject: [PATCH] Update cue2vtt.py --- examples/stream/cue2vtt.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/stream/cue2vtt.py b/examples/stream/cue2vtt.py index b44b1eaf..da232fbf 100644 --- a/examples/stream/cue2vtt.py +++ b/examples/stream/cue2vtt.py @@ -13,6 +13,7 @@ from threefive import Stream import time + def ts_to_vtt(timestamp): """ ts_to_vtt converts timestamp into webvtt times @@ -27,16 +28,17 @@ def scte35_to_vtt(cue): """ scte35_to_vtt prints splice insert cue out and cue in via webvtt """ - start =0 + start = 0 end = 0 duration = None pts_time = None upid = None - seg_mesg= None + seg_mesg = None now = cue.packet_data.pts if cue.command.has("pts_time"): - start= pts_time = cue.command.pts_time+cue.info_section.pts_adjustment - if pts_time > now: time.sleep(pts_time -now) + start = pts_time = cue.command.pts_time + cue.info_section.pts_adjustment + if pts_time > now: + time.sleep(pts_time - now) if cue.command.has("break_duration"): duration = cue.command.break_duration for d in cue.descriptors: @@ -49,7 +51,7 @@ def scte35_to_vtt(cue): if start and duration: end = start + duration if end == 0: - end = start+4 + end = start + 4 print(f"{ts_to_vtt(start)} --> {ts_to_vtt(end)} ") @@ -57,7 +59,7 @@ def scte35_to_vtt(cue): if pts_time: print(f"PTS: {pts_time} ") if duration: - print(f"Duration: {round(duration,3)} " ) + print(f"Duration: {round(duration,3)} ") if seg_mesg: print(seg_mesg) if upid: