  
  def replay(route, segment):
    route = route.replace('|', '/')
  
    lr = LogReader(f"cd:/{route}/{segment}/rlog.bz2")
    fr = FrameReader(f"cd:/{route}/{segment}/fcamera.hevc", readahead=True)
  
    # Build mapping from frameId to segmentId from encodeIdx, type == fullHEVC
    msgs = [m for m in lr if m.which() not in IGNORE]
    msgs = sorted(msgs, key=lambda m: m.logMonoTime)
    times = [m.logMonoTime for m in msgs]
 
</s> remove def replay(route, segment):
 </s> add def replay(route, loop): </s> remove     socks[w].send(msg.to_bytes())
 </s> add     try:
      if socks[w]:
        socks[w].send(msg.to_bytes())
    except messaging.messaging_pyx.MultiplePublishersError:
      socks[w] = None </s> remove     i = min(i + 1, max_i)
 </s> add     i = (i + 1) % max_i if loop else min(i + 1, max_i) </s> remove   parser.add_argument("route")
  parser.add_argument("segment", type=int)
 </s> add   parser.add_argument("--loop", action='store_true')
  parser.add_argument("segment") </s> remove     replay(args.route, args.segment)
 </s> add     replay(args.segment, args.loop)
  lr = LogReader(f"cd:/{route}/rlog.bz2")
  fr = FrameReader(f"cd:/{route}/fcamera.hevc", readahead=True)
  
  def replay(route, segment):
    route = route.replace('|', '/')
  
  lr = LogReader(f"cd:/{route}/rlog.bz2")
  fr = FrameReader(f"cd:/{route}/fcamera.hevc", readahead=True)
  lr = LogReader(f"cd:/{route}/rlog.bz2")
  fr = FrameReader(f"cd:/{route}/fcamera.hevc", readahead=True)
  
    # Build mapping from frameId to segmentId from encodeIdx, type == fullHEVC
    msgs = [m for m in lr if m.which() not in IGNORE]
    msgs = sorted(msgs, key=lambda m: m.logMonoTime)
    times = [m.logMonoTime for m in msgs]
keep keep keep keep replace replace keep keep keep keep keep
 Handle loop and multiple publishers 
tools/replay/unlog_segment.py