Timestamps and Loop Behavior

By default, file streaming preserves the original MPEG timestamps from the source file.

Timestamp Modes

The selected MPEG timestamp mode determines whether SkyView forwards source timing as-is or rewrites it to a fresh monotonic timeline.

Original Mode: The streamer ignores the current wall-clock time and simply spits out the bits with their original birth-dates (timestamps) intact.
Restamp Mode: The streamer preserves source timing deltas but shifts PCR/PTS/DTS onto a monotonic output timeline.
Regenerate Mode: The streamer synthesizes a new timeline from sender pace/bitrate and rewrites PCR/PTS/DTS from that synthetic clock.

Original timestamps mode

No PCR/PTS/DTS restamping is applied to MPEG-TS timing fields, MPEG timing is kept as-is.
You can still restamp KLV

Restamp timestamps mode

The streamer restamps:

  • PCR on the detected PCR PID.
  • PES timestamps (PTS/DTS) on any PID carrying PES timestamps (video/audio/KLV if present in PES form).
  • Relative timing inside the file is preserved, but shifted (during loops) to keep timing monotonic.

Regenerate timestamps mode

The streamer regenerates MPEG timing from a synthetic packet clock:

  • PCR is generated from a synthetic 27 MHz timeline.
  • PES timestamps are mapped to a synthetic 90 kHz timeline.
  • The timeline is monotonic across loop restarts (no reset-to-zero at each loop).
  • Useful when source PCR/PTS/DTS are inconsistent and strict live-like timing is preferred.

File Loop mode

File loop

On each EOF loop restart, the streamer performs continuity-safe transport handling:

  • Continuity Counter (CC) rewrite per PID
  • TS CC is rewritten continuously per PID across loop boundaries.
  • Payload packets increment CC normally.
  • Adaptation-only packets reuse the last emitted CC for that PID. This prevents CC jumps when source file counters restart at loop start.

Discontinuity indicator signaling

After loop restart, the streamer sets MPEG-TS discontinuity_indicator on outgoing packets that already contain an adaptation field. This explicitly tells receivers a timeline discontinuity occurred, so they resynchronize cleanly.

Timestamp handling across loops

In both restamp and regenerate modes, internal timestamp mapping keeps output timelines monotonic across loops (no large backward jumps).
In original mode, source timestamps are not rewritten, so loop restart can jump backward to the file's initial timeline. Receivers are expected to recover via the discontinuity indicator.

For PES packets with both PTS and DTS (PTS_DTS_flags=0x03), rewriting is decode-order aware:
- DTS is rewritten on a monotonic per-PID timeline.
- PTS is derived from rewritten DTS plus the original packet-level delta:
PTS_out = DTS_out + (PTS_in - DTS_in) (wrap-safe)
This preserves B-frame presentation reordering (PTS may be non-monotonic in decode order), while keeping decode timing stable.
For PES packets with only PTS (PTS_DTS_flags=0x02), only PTS is rewritten.
In regenerate mode, the rewritten timeline is synthetic and packet-clock driven - it is monotonic across loops and not guaranteed to restart at exact zero on each loop. Synthetic PCR-only packets may also be inserted to cap long PCR gaps.