Skip to content

fix(youtube): restore SABR initialization cold start#86

Open
Priveetee wants to merge 1 commit into
InfinityLoop1308:mainfrom
Priveetee:fix/youtube-sabr-init-cold-start
Open

fix(youtube): restore SABR initialization cold start#86
Priveetee wants to merge 1 commit into
InfinityLoop1308:mainfrom
Priveetee:fix/youtube-sabr-init-cold-start

Conversation

@Priveetee

Copy link
Copy Markdown
Contributor

Summary

While fixing a SABR playback regression in TypeType, I found that initialization requests could receive several valid SABR responses without the requested init segment.

The session eventually failed with:

Requested SABR segment was not returned: itag=140:init
Requested SABR segment was not returned: itag=299:init

PipePipe normally gets initialization data directly from the format metadata, but both the player fallback and the downloader still use fetchSegment(SabrSegmentRequest.initialization(...)) when that data is unavailable.

This restores the cold-start request shape needed for those initialization requests without changing the normal media request flow.

Problem

An initialization request needs to identify the requested audio or video track without carrying the buffered ranges and playback state of a normal follow-up request.

With the current request shape, YouTube can return policy and media responses while skipping the requested init segment entirely.

Changes

  • Use an initialization-specific request state while fetching an init segment.
  • Enable only the requested audio or video track for that request.
  • Keep audio and video format preferences separate from the selected track state.
  • Omit buffered ranges and top-level player time from the initialization request.
  • Restore the normal session state after the request completes.

Validation

Build:

  • ./gradlew :extractor:compileJava
  • git diff --check

Runtime validation through TypeType with the patched extractor:

  • audio initialization returned successfully
  • video initialization returned successfully
  • audio and video media segments continued loading
  • playback reached 45 seconds without interruption or player errors

Test videos:

  • https://www.youtube.com/watch?v=X4FeyMPB6SY
  • https://www.youtube.com/watch?v=J_T7EFHEcpc

Notes

This is extractor-only. PipePipe already uses the affected initialization API, so no client change is required.

This does not address WebView, BotGuard, or DNS failures. It only fixes SABR init-segment retrieval.

@InfinityLoop1308

Copy link
Copy Markdown
Owner

Thanks. I was able to reproduce the missing init segment issue, but in my local testing, changing the request shape as done here did not appear to fix it. Can you share some logs showing the difference in your test environment?

@InfinityLoop1308

InfinityLoop1308 commented Jul 19, 2026

Copy link
Copy Markdown
Owner

btw, thanks for your replies and doc updates this week :) I'm busy with some other things this week and your works really helps a lot. (and I am not good at writing docs lol
do you mind making a small pr in the main repo to edit the readme: remove the User in User wiki maintained by [@Priveetee](https://github.com/Priveetee) ? this also makes you shown as Contributor in the main repo

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