Skip to content

feat(dash): download SegmentBase streams and skip non-MP4 representations - #619

Merged
linroid merged 2 commits into
mainfrom
feat/dash-segment-base
Oct 23, 2026
Merged

linroid merged 2 commits into
mainfrom
feat/dash-segment-base

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Found while downloading public DASH streams with the CLI: Shaka's demo stream (https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd) failed to list or download. It hit two limits in turn:

  1. Only MP4 DASH representations are supported: the manifest offers WebM (VP9, Opus) adaptation sets beside MP4 (H.264, AAC) ones, and one WebM representation made Ketch refuse the whole stream.
  2. DASH requires SegmentList or SegmentTemplate: on-demand profiles (isoff-on-demand, as Shaka Packager and many VOD services write them) store each representation as one fragmented MP4 file. The manifest gives a BaseURL and SegmentBase (initialization range and a sidx segment index) instead of listing segments.

What changes

  • Other containers are left out, not fatal: only MP4 representations (video/mp4, audio/mp4, application/mp4) are considered. A manifest is refused only when it has no MP4 at all.
  • SegmentBase / single-file representations (DashTrack.SingleFile):
    • as the only track (video alone, or audio alone): the file is the track, fetched whole with one request;
    • merged with separate audio: Ketch fetches its segment index (MediaDownloadHelper.fetchRange, at most 1 MiB, with the stream's origin-scoped headers) and parses the sidx (parseSegmentIndex, versions 0 and 1). The plan is the initialization range plus each fragment's byte range, with start times (minus presentationTimeOffset), so audio and video interleave exactly as SegmentTemplate tracks do. A file without an index follows whole after its initialization; one without an initialization range can't be merged and is refused with a reason.
    • Indexes that refer to further indexes (hierarchical sidx) are refused with a reason.
  • Indexes are fetched only when a download plans its chosen variant; resolve plans without them, since it only needs the container and the track count.
  • docs/media.md and AGENTS.md describe the new support.

Verification

  • ketch --list-files on angel-one lists its 5 H.264 variants (before: the error above). Downloading 144p and the default 576p gives H.264 + AAC MP4s of 60.02 s, ffmpeg -f null decodes them with no errors, and ffprobe shows video and audio packets interleaved.
  • A local manifest with only angel-one's SegmentBase AAC track: the output is byte-identical to the source file, from one request.
  • ffmpeg's on-demand packager (-single_file 1, SegmentList with byte ranges) still works, merged and video-only.
  • New tests: SegmentIndexTest (versions 0/1, boxes before the sidx, nested and truncated indexes) and DashManifestTest cases for SegmentBase alone (one whole-file part, no index fetched), merged with audio (indexes needed, fragments interleaved by time, whole-file fallback without indexes), missing base URL or ranges, and WebM beside MP4.
  • ./gradlew :library:dash:jvmTest :library:core:jvmTest --tests '*Media*' --tests '*Mp4*' passes.

…ions

On-demand DASH (isoff-on-demand, as Shaka Packager writes it) stores each
representation as one file with a segment index, which Ketch refused with
"DASH requires SegmentList or SegmentTemplate". Such a track is now
fetched whole, with one request, when it is the only one; merged with
separate audio, its initialization and each fragment its sidx lists are
fetched, timed so the tracks interleave as SegmentTemplate ones do.

Manifests offering WebM beside MP4 (Shaka's angel-one) were refused as a
whole with "Only MP4 DASH representations are supported"; representations
in other containers are now left out, and only a manifest with no MP4 at
all is refused.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T15:16:33.318675Z e53c286 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e53c286caf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

A Representation's SegmentBase may set only its indexRange while its
AdaptationSet's carries the Initialization, timescale and presentation
time offset. Their attributes now fold from the period down, each level
overriding what it sets, as SegmentTemplate's do.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 198 files  + 4   2 226 suites  +4   58m 44s ⏱️ + 1m 0s
15 312 tests +55  15 044 ✅ +55  268 💤 ±0  0 ❌ ±0 
18 665 runs  +57  18 397 ✅ +57  268 💤 ±0  0 ❌ ±0 

Results for commit af9365e. ± Comparison against base commit 9fb402d.

@linroid
linroid merged commit 9a5183e into main Oct 23, 2026
14 checks passed
@linroid
linroid deleted the feat/dash-segment-base branch October 23, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant