Skip to content

fix(bilibili): generate multi-quality DASH manifest representations for full resolution playback - #36

Merged
Priveetee merged 3 commits into
TypeType-Video:devfrom
Aquarius-Situla:fix/bilibili-multi-quality-dash
Oct 2, 2026
Merged

Priveetee merged 3 commits into
TypeType-Video:devfrom
Aquarius-Situla:fix/bilibili-multi-quality-dash

Conversation

@Aquarius-Situla

@Aquarius-Situla Aquarius-Situla commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes Bilibili playback being locked to 480p and restores the player's video quality selector by including all available stream resolutions in the generated DASH manifest.


Key Changes

DASH Manifest Multi-Resolution Support (bilibili-manifest.ts):

  • Grouped video stream candidates by codec family prioritization (avc1 > av01 > hev1).
  • Deduplicated video streams per resolution height while retaining the highest bitrate variant for each level.
  • Emitted all available video representations into the <AdaptationSet> in descending resolution order (1080p, 720p, 480p, 360p), enabling Dash.js resolution switching and restoring the player quality menu.

Manifest Unit Tests (apps/web/tests/bilibili-manifest.test.ts):

  • Added unit tests verifying multi-resolution representation parsing, codec prioritization, and MPD generation.

@Priveetee

Copy link
Copy Markdown
Member

Thanks for the fix! Including all available resolutions in the manifest should restore the quality selector.

One concern: bilibiliVariantCount() now counts codec groups rather than individual video streams. With one AVC group and one audio stream, there is only one fallback variant. If playback fails on the selected resolution, the existing recovery path appears to reload the same manifest rather than explicitly try a lower resolution.

Could you check this scenario and add a regression test? Ideally, a failed higher-quality stream should not prevent playback when a lower-quality stream is still available.

The three manifest tests pass locally. I haven’t reproduced this failure in a browser yet.

@Aquarius-Situla

Copy link
Copy Markdown
Contributor Author

Good catch, thanks for pointing that out!

I've updated the logic so each codec group now provides progressive resolution fallback slices (e.g. [1080p, 720p, 480p, 360p], then [720p, 480p, 360p], then [480p, 360p], and so on).

  • bilibiliVariantCount() now counts the total fallback steps across all available codec groups and audio streams.
  • If playback fails on a higher resolution (e.g. decoding issue or segment error on 1080p), use-player-error can increment bilibiliVariant to retry with a manifest that excludes the failed higher resolution and steps down to lower qualities.
  • Added regression tests in bilibili-manifest.test.ts covering both the variant count calculation and manifest resolution fallback behavior.

@Priveetee

Copy link
Copy Markdown
Member

Thanks for the update! All five tests pass locally now.

Did you get a chance to try the fallback on your instance too, to see if playback actually resumes at a lower quality after an error? Unfortunately, I don’t have a BiliBili account to try it myself ;p

@Aquarius-Situla

Copy link
Copy Markdown
Contributor Author

Yep, tested it on my self-hosted setup!

I simulated a failure by blocking/dropping the 1080p video URL. use-player-error caught the media error, bumped bilibiliVariant as expected, and re-generated the manifest starting from 720p. Dash.js re-attached cleanly and resumed playback at 720p right where it left off, rather than failing out to the error overlay. The quality menu also adjusted to reflect the remaining tiers (720p, 480p, 360p).

So the fallback path works nicely in practice without getting stuck.

@Aquarius-Situla
Aquarius-Situla marked this pull request as draft October 1, 2026 06:12
@Aquarius-Situla
Aquarius-Situla marked this pull request as ready for review October 1, 2026 11:33
@Priveetee

Copy link
Copy Markdown
Member

LGTM

@Priveetee
Priveetee merged commit 96c6489 into TypeType-Video:dev Oct 2, 2026
1 check passed
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.

2 participants