HLS mid-GOP TS segment triggers Shaka transmuxing failure — codec parameter-set continuity investigation

GitHub source

Inferred. This page is generated from GitHub Issue #56; GitHub remains the canonical authoring and discussion source.

Local reproduction and solution — 18 November 2026#

Status: Reproduced locally; upstream AVC fix and additional local HEVC candidate verified.

Source and evidence#

Upstream case · local report and evidence · portable reproduction instructions

Observed results are Reproduced only within the stated seam. Implementation explanations remain Inferred, not Apple Confirmed.

Reconstruct the scene#

Generate a 4-second, 25 fps AVC/HEVC HLS asset with a 2-second GOP and 1-second MPEG-TS segments. In 5.2.12, the AVC control throws 3018 on segment 1, which lacks parameter sets. The pinned upstream build fixes AVC but still loses HEVC pictures.

The reviewed HEVC candidate retains four RASL slices and avoids resetting the decoder at a contiguous CRA append. It commits continuity only after successful append and invalidates it across failure/abort/init/chunked operations. Both release-compiled and uncompiled complete Player paths render 100/100 AVC and HEVC frames with a continuous [0.08,4.08] buffer. All 100 decoded picture hashes match; 136 codec/parser/MSE tests and changed-file ESLint pass.

Solution / guideline#

For AVC, use/backport complete upstream commit ed8e14db624bea92239f46ec24fa319149e20699. For the residual HEVC case, review the additional five-file candidate linked below; it is local work, not an upstream merged or released fix.

HEVC candidate · build and frame evidence

Limits / remaining work#

Chrome 158 on macOS, generated clear fixtures. Safari/physical-device HEVC, cold random access, wider CRA variants and ABR/LL-HLS stress remain unverified.

This update supersedes earlier no-local-run statements below only within the stated scope. Historical source reports are retained; no unresolved issue is closed by this publication.


Earlier investigation and source history

Verification update — 17 November 2026#

Status: reproducible upstream; fix merged. PR #10704 merged on 2026-10-23 as ed8e14db624bea92239f46ec24fa319149e20699.

  • Reproduction: FFmpeg-generated H.264/H.265 with a 2-second GOP split into 1-second TS segments; alternate segments lack their own parameter sets/keyframe. The PR contains generated fixtures, unit tests and playback/buffer-continuity integration tests; its author reports the build/test matrix passed, including macOS Safari.
  • Solution: cache validated video parameters per stream and discontinuity; skip an initially undecodable mid-GOP segment until a valid GOP; preserve the video timestamp offset for contiguous mid-GOP appends. Parameter caching alone was insufficient because resetting the offset could discard dependent frames.
  • Action: use a Shaka build containing this commit or backport the complete patch and regression tests. A seek into a long GOP can still resume at the next keyframe if the preceding keyframe is not fetched.
  • Scope: upstream reproduction/test evidence and patch inspected in this review; no local playback or native AVPlayer test. Release inclusion has not been independently mapped.

This update supersedes older statements below about missing fix verification; the historical investigation and prompt are retained.


Source: shaka-project/shaka-player#10703

Problem and observed behavior#

A Shaka Player 5.2.12 report describes HLS MPEG-TS playback failing with MEDIA.TRANSMUXING_FAILED (3018) at a segment boundary when an H.264/H.265 GOP spans multiple TS segments. The reporter supplies a short FFmpeg reproduction using 2-second GOPs and 1-second HLS segments with split_by_time.

According to the report, alternate TS segments contain inter-predicted pictures but no new SPS/PPS and IDR. Shaka's segment-local codec inspection reportedly rejects the segment, while hls.js continues. The reproduction uses clear media on Chrome/Windows; it does not establish a Safari, FairPlay or native AVPlayer defect.

Evidence status: reporter-provided reproduction and source-level hypothesis; no independent FFmpeg playback run or pinned Shaka source diff was performed for this entry. Root cause remains unverified independently.

First causal boundary#

HLS media playlist (no EXT-X-INDEPENDENT-SEGMENTS)
  → TS segment boundary inside a GOP
  → AVC/HEVC parameter sets absent in this segment
  → Shaka TsTransmuxer codec-info extraction
  → TRANSMUXING_FAILED (3018)

The proposed first divergence is failure to retain or recover codec configuration across a segment boundary. This is a testable explanation, not yet an independently proven implementation root cause.

A segment boundary does not inherently imply a random-access point. Absence of EXT-X-INDEPENDENT-SEGMENTS means a player must not assume every segment is independently decodable. Conversely, a client starting directly at a mid-GOP segment may need to acquire earlier reference frames or skip to a valid random-access point.

Evidence and competing explanations#

Claim Status Verification
3018 occurs at a mid-GOP TS boundary Reported Reproduce exact FFmpeg asset
Affected segment lacks SPS/PPS/IDR Reported Inspect TS NAL units and hashes
Shaka discards previously observed codec parameters Hypothesis based on reporter source reading Pin release SHA and trace TsTransmuxer.getAvcStreamInfo_() / getHvcStreamInfo_()
HLS forbids GOPs spanning TS segments Not established Check RFC 8216 and Apple's HLS authoring guidance
Native AVPlayer shares this failure No evidence Separate native AVPlayer control

Controlled client-side investigation#

  1. Generate the reporter's 4-second H.264 test with 2-second GOP and 1-second TS segments. Hash all playlist and segment bytes.
  2. Extract NAL-unit types, SPS/PPS, IDR, PTS/DTS, PAT/PMT and continuity counters for each TS segment; also inspect the concatenated TS stream.
  3. Compare Shaka 5.2.12, pinned main, and hls.js against the identical clear asset. Capture the exact segment index, function and thrown error. Verify whether cached codec configuration is present when segment 1 is processed.
  4. Run controls with segment boundaries aligned to IDR, with EXT-X-INDEPENDENT-SEGMENTS only when truthful, and with fMP4 generated from a compliant reference asset. Never label a packaging change as a client-only fix.
  5. Separately test native AVPlayer on iOS/tvOS using the same authorized HLS asset, player error/access logs and network traces. Do not extrapolate JavaScript transmuxer behavior to AVFoundation.
  6. Only add FairPlay analysis if encrypted and clear controls diverge; then trace EXT-X-KEY, SKD identity, AVContentKeySession, SPC/KSM/CKC metadata and key status without exposing protected payloads.

Reusable engineering rule#

An HLS segment boundary is not necessarily a codec configuration boundary or a random-access point. Diagnose transmuxer state retention separately from media conformance and decoder failures.

Client-only candidates: preserve validated codec parameter sets across compatible consecutive segments and reset that state on real discontinuities or incompatible codec changes; test graceful handling of a seek into a non-independent segment. These are design proposals, not verified Shaka fixes.

Packaging proposal, separate from client scope: align segments to suitable random-access points when independent segment access is required. Do not add EXT-X-INDEPENDENT-SEGMENTS to streams that violate its contract.

Publication status and next milestone#

Evidence-led investigation draft. Next: execute the supplied FFmpeg reproduction, pin TsTransmuxer source at affected and candidate-fixed commits, and establish the first divergent state using byte-level traces. No claim of completed experiments.

References#

Extended investigation prompt#

Copy the full prompt for a second AI
ROLE
Act as a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia specialist, HLS/MPEG-TS forensic engineer and FairPlay DRM security expert.

CASE
https://github.com/shaka-project/shaka-player/issues/10703
Shaka Player 5.2.12 reportedly fails with TRANSMUXING_FAILED (3018) when H.264/H.265 GOPs span TS segment boundaries. The reporter provides a reproducible FFmpeg recipe. Root cause is not independently verified.

OBJECTIVE
Identify the FIRST PROVEN causal divergence: HLS contract, TS/codec metadata, Shaka transmuxer state, MSE append or decoder. Do not infer root cause from the final error code.

STRICT EVIDENCE HIERARCHY
Tier 1: Official Apple Developer Documentation, HLS Authoring Specification, Apple engineer/WWDC statements, RFC 8216 and applicable ISO/ITU codec specifications, FairPlay SDK where relevant.
Tier 2: Commit-pinned Shaka and verified WebKit source code, Apple open-source components, symbolicated AVFoundation/CoreMedia/CFNetwork diagnostics and independently verified security research. Every source-level claim requires URL, commit SHA, path, function, line range and control-flow explanation. WebKit is not native AVPlayer source.
Tier 3: Byte-verified manifests and TS segments, NAL traces, reproducible controlled A/B playback, network captures and authorized DRM transaction metadata.
Tier 4: Explicit hypotheses, never stated as facts.

For every major claim report evidence tier, exact source, observation, counterevidence, confidence and falsification test. If source access or experiments are unavailable, say so.

TRACE
Playlist EXTINF, MEDIA-SEQUENCE, DISCONTINUITY, INDEPENDENT-SEGMENTS → TS PAT/PMT and continuity counters → PES PTS/DTS → H.264 SPS/PPS/IDR or H.265 VPS/SPS/PPS/IRAP → GOP/reference dependencies → Shaka TsTransmuxer.getAvcStreamInfo_ / getHvcStreamInfo_ → fMP4 initialization and media fragments → MSE SourceBuffer → decoder → playback state.

EXPERIMENTS
Run reporter's exact FFmpeg command. Verify hashes and per-segment NAL units. Compare affected Shaka release and pinned source with hls.js; inspect actual state retention and error branch. Change one variable at a time: GOP length, segment length, keyframe alignment, discontinuity, seek target, TS vs fMP4. Include a separate native AVPlayer test on iOS/tvOS. Never invent runs or measurements.

FAIRPLAY
The original case is clear media. Investigate DRM only if an authorized encrypted control shows a new divergence. Then trace EXT-X-KEY → full SKD identifier → AVContentKeySession → SPC → KSM → CKC → usable key, using metadata only. Never extract keys, bypass DRM, or publish SPC/CKC bytes.

ROOT-CAUSE STANDARD
Declare a root cause only when the failure reproduces, the first divergent transition is proven, a controlled intervention reverses it and major alternatives are falsified. Otherwise state ROOT CAUSE UNVERIFIED.

OUTPUT
Executive finding; evidence ledger; standards contracts; manifest and TS/NAL audit; pinned source trace; successful/failing timelines; first divergence; controlled tests; competing hypotheses; client-only mitigation; separate packaging/CDN proposals; regression tests; unknowns; exact citations; and a concise publication-ready article with restrained bold text, short paragraphs and the extended prompt collapsed.