AVPlayer MPEG-TS HLS: unexpected 26.5-hour timeline near PTS wrap period

GitHub source

Evidence not classified. This page is generated from GitHub Issue #57; GitHub remains the canonical authoring and discussion source.

Source: https://developer.apple.com/forums/thread/848784

Observed behavior#

A developer reports an HLS MPEG-TS presentation with normal duration 6958 s and current time 355 s. In affected runs the values are approximately 95449 s and 95443 s. Sample PTS inspected with ffprobe are around 6426 s. Audio-only reportedly shows the expected timeline. No verified fix or Apple explanation was present in the reviewed thread.

Evidence and numerical fingerprint#

MPEG-TS PTS/DTS use a 33-bit timestamp at 90 kHz. The wrap period is 2^33 / 90000 = 95443.7176889 s. This is strikingly close to the reported current time, but does not establish a wrap bug. The duration difference (95449 - 6958 = 88491 s) is not one wrap period. The normal and abnormal current times are not established as paired observations at the same media position.

Competing explanations#

  • Incorrect timestamp unwrapping or discontinuity epoch selection.
  • Different audio/video rendition timestamp origins or missing discontinuity signaling.
  • App observing a stale item or comparing unlike time coordinates.
  • ffprobe normalization masking raw timestamp transitions.

Verification#

Capture every playlist and TS segment in sequence, including raw PTS/DTS per PID, PCR, continuity and discontinuity flags. Compare ffprobe packet output against raw PES timestamps. Record CMTime value, timescale, epoch and flags from the same AVPlayerItem with monotonic timestamps and item identity. Compare audio-only versus video, sequential versus seeking, clear versus authorized FairPlay and affected versus comparison OS builds. Construct a synthetic wrap-crossing and non-crossing control. No device experiment was executed here.

Client-only guidance#

Validate reported time against the active item's seekable ranges and known VOD metadata before updating the scrubber. Log anomalous values; avoid modulo correction of player time or unconditional seeks. Any timestamp remuxing or packager change is a separate proposal.

Reusable rule#

A value near the MPEG-TS wrap period is a diagnostic fingerprint, not proof of a wrap-handling defect. Establish the mapping between raw media timestamps and item time first.

Root cause remains unverified. FairPlay is not established as causal.

References#

Extended investigation prompt#

Show the full second-AI prompt
Act as a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia investigator, MPEG-TS/HLS timing engineer and FairPlay DRM specialist.

Case: https://developer.apple.com/forums/thread/848784
AVPlayer occasionally reports currentTime 95443 s and duration 95449 s for a 6958 s asset. Audio-only reportedly behaves normally. Identify the first proven timeline divergence.

Evidence hierarchy:
1. Apple Developer Documentation, HLS authoring specification, Apple engineering statements, ISO/IEC 13818-1 and RFC 8216.
2. Version-pinned verified WebKit and FFmpeg source, symbolicated AVFoundation/CoreMedia diagnostics, verified security research. Cite commit SHA, path, function, lines and OS build. WebKit is not native AVPlayer.
3. Raw authorized media, packet captures, repeatable physical-device A/B tests.
4. Explicit falsifiable hypotheses. Never invent private symbols, data or experiments.

Calculate 2^33/90000 and compare actual paired offsets; proximity alone is not proof. Parse raw 33-bit PTS/DTS, PCR, PID continuity, discontinuity indicators, EXTINF, EXT-X-DISCONTINUITY and rendition changes across the entire asset. Compare raw versus ffprobe-normalized timestamps. Trace media timestamp -> unwrap -> discontinuity epoch -> item time -> UI. Record CMTime value, timescale, epoch, flags, duration and seekable ranges from the same item and monotonic observation. Compare audio-only/video, sequential/seek, clear/authorized FairPlay, TS/fMP4 and OS builds, changing one factor at a time. Generate synthetic timestamps crossing wrap and a non-crossing control; never claim native-device results unless executed.

If DRM correlates independently, trace SKD identifiers, content-key callbacks and sanitized KSM transaction metadata; never expose secrets or bypass protection. Distinguish app-only mitigation from packaging/CDN proposals. Require reproduction, first divergent transition, controlled reversal and alternative falsification before declaring root cause. Output evidence ledger, timelines, commands, test matrix, proposed fix, regression tests, remaining unknowns and publication-ready article.