def OnTSPacket(packet): """ Callback invoked on the successful extraction of a single TS packet from a ts file :param packet: The entire packet (header and payload) as a string :return: None """ global initial_timestamp global elapsed_time_s #pcr (program count record) can be used to calculate elapsed time in seconds # we've read through the .ts file pcr = TS.get_pcr(packet) if pcr > 0: current_timestamp = pcr initial_timestamp = initial_timestamp or current_timestamp delta = current_timestamp - initial_timestamp elapsed_time_s = float(delta) / 90000.0
def OnTSPacket(packet): """ Callback invoked on the successful extraction of a single TS packet from a ts file :param packet: The entire packet (header and payload) as a string :return: None """ global initial_timestamp global elapsed_time_s global time_offset #pcr (program count record) can be used to calculate elapsed time in seconds # we've read through the .ts file pcr = TS.get_pcr(packet) if pcr > 0: current_timestamp = pcr initial_timestamp = initial_timestamp or current_timestamp delta = current_timestamp - initial_timestamp elapsed_time_s = float(delta) / 90000.0 + time_offset