Skip to content

feat(download): start real SABR download support#68

Merged
InfinityLoop1308 merged 12 commits into
InfinityLoop1308:devfrom
Priveetee:draft/sabr-download
Jul 2, 2026
Merged

feat(download): start real SABR download support#68
InfinityLoop1308 merged 12 commits into
InfinityLoop1308:devfrom
Priveetee:draft/sabr-download

Conversation

@Priveetee

Copy link
Copy Markdown
Contributor

Fixes / continues InfinityLoop1308/PipePipe#2569

Context: #66 (comment)

Pairs with the extractor-side helper draft: InfinityLoop1308/PipePipeExtractor#79

Summary

This starts the real SABR download implementation.

I have something working locally now, but this is still draft. I will keep updating this PR while testing/fixing the remaining cases. Once it looks solid enough, I will ask for review.

Why

The old downloader cannot handle SABR as a normal URL.

SABR is a session, not a direct media file. So the download path needs to drive a YoutubeSabrSession, request the selected formats, collect init/media segments, write them in order, and mux the final result.

Since HLS also looks less reliable now, I think we need to start moving download toward real SABR support instead of only relying on temporary fallbacks.

What works locally right now

Tested on emulator:

https://www.youtube.com/watch?v=lLaRC7GkVR8

Selected stream:

AV1 480p SABR
itag 397

Audio:

AAC
itag 140

Result:

final MP4 generated successfully

ffprobe sees:

video: AV1 854x480, ~276s
audio: AAC, ~276s
size: ~15 MB

What changed

  • Detect SABR streams/resources in the download flow
  • Store SABR recovery info in the mission
  • Route SABR missions to a dedicated SABR downloader
  • Drive a SABR session for selected audio/video formats
  • Write SABR init/media segments to temp files
  • Handle delayed init segments
  • Keep media segments ordered
  • Handle SABR policy-only responses as retryable idle responses
  • Remux the downloaded tracks with ffmpeg
  • Clean SABR temp files with mission cleanup

Still not done

This is not merge-ready yet.

I still want to test/fix:

  • VP9
  • AVC1
  • WebM + Opus
  • audio-only
  • cancel / restart
  • longer videos
  • ffmpeg failure cases
  • retry limits around policy-only responses
  • memory behavior
  • cleanup temporary debug logs

Notes

Opening this as draft so the direction is visible early.

The base path works locally now, but I will continue updating it before asking for review.

@Priveetee

Copy link
Copy Markdown
Contributor Author

@InfinityLoop1308 I think this one is ready for a first real review now.

I kept it as draft while testing because SABR download is a big change and I did not want to rush it. I pushed more fixes after the first draft, especially around single-track/audio-only init recovery and retry behavior.

What I tested on emulator:

  • AV1 720p HFR download: ok, final MP4 with AV1 + AAC.
  • VP9/WebM video+audio: ok.
  • Opus audio-only: ok.
  • Audio-only after a clean reinstall + SAF folder permission + overwrite: ok.
  • Long video download, Big Buck Bunny 10m34: ok.
  • Network cut/reconnect during download: ok, final file still valid.
  • Force-stop during download, then resume from Downloads: ok.
  • Temporary SABR work directory cleanup after success/retry/resume: ok.

I also tested a few different videos, not only one sample:

  • lLaRC7GkVR8
  • aqz-KE-bpKQ
  • dQw4w9WgXcQ
  • 3JZ_D3ELwOQ

I still would like you to test it too on your side, especially with formats/videos that usually hit SABR edge cases. I could not do the final physical-device run today because my Pixel was not visible in adb anymore, but emulator testing is now much better than before.

@InfinityLoop1308

Copy link
Copy Markdown
Owner

Really fast XD

quick test:

  1. no progress (percent)
  2. resume lose all the progress

@InfinityLoop1308

Copy link
Copy Markdown
Owner

and don't push yourself :) you can just take this one and I'll handle other bugs.
these days are really busy - we should all take a rest after 5.2.1 lol

@Priveetee Priveetee force-pushed the draft/sabr-download branch from 9e5d16d to ca791e9 Compare July 2, 2026 07:08
@Priveetee

Copy link
Copy Markdown
Contributor Author

@InfinityLoop1308 I pushed a small follow-up for these two points.

For the percent: SABR download was forcing unknownLength = true, so the UI could only show the indeterminate progress. Now, when nearLength is known, it keeps a normal length and the percent can be displayed.

For resume: this is still not real segment-level resume yet. SABR currently restarts the temp transfer, but now it keeps the previous visible progress as a floor. So on resume/retry it does not jump back to 0%; the restarted transfer catches up silently, then progress continues from there.

Build is still ok on my side with ./gradlew :app:assembleDebug -Px86 --no-build-cache --no-configuration-cache --no-daemon.

@Priveetee

Priveetee commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

and don't push yourself :) you can just take this one and I'll handle other bugs.
these days are really busy - we should all take a rest after 5.2.1 lol

I’m fine, no worries :)

And np, honestly it’s a pleasure. I like coding when I come back from work or when I have some free time, I get more fun from coding than from doing other stuff :P

@InfinityLoop1308 InfinityLoop1308 merged commit 5dc95b9 into InfinityLoop1308:dev Jul 2, 2026
skajmer added a commit to skajmer/PipePipeClient that referenced this pull request Jul 2, 2026
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