Local API: Implement SABR for VODs
Pull Request Type
- [ ] Bugfix
- [x] Feature Implementation
- [ ] Documentation
- [ ] Other
Related issue
Closes https://github.com/FreeTubeApp/FreeTube/pull/7145 https://github.com/FreeTubeApp/FreeTube/pull/7887
Description
Based on https://github.com/FreeTubeApp/FreeTube/pull/7145 (Please read that PR first Using https://github.com/LuanRT/googlevideo 4.0.4
- Implementation updated (different from #7145) to have playback session scoped stuff like SABR context & playbackCookie (SABR details)
- Player streaming timeout doubled (30s > 60s) to handle sometimes ~40MB response instead of ~10MB (at 2k quality, e.g. https://youtu.be/NmdXl7vXZ7g)
- New setting for enabling SABR in experimental section
Non-SABR
- Also updated the implementation for https://github.com/FreeTubeApp/FreeTube/pull/7887 to show pre-roll ads time in toast
- Toast now updated to be possible to show updated messages (hard coded to refresh per 1s currently)
Screenshots
Lazy maybe add later?
Testing
A. SABR off
- Test pre-roll ads time toast
- Test various video playback (should be the same)
B. SABR on
- Test various video playback (should be the same)
Find custom builds at https://github.com/PikachuEXE/FreeTube/actions/workflows/build.yml?query=branch%3Asabr-pr Find cutting edge custom builds (I only use this branch for testing fixes myself, but can be outdated once I finished testing): https://github.com/PikachuEXE/FreeTube/actions/workflows/build.yml?query=branch%3Acustom-builds%2Fsabr
Desktop
- OS:
- OS Version:
- FreeTube version:
Additional context
Remaining tasks
- [x] Add/Update labels/tooltips/toasts & make them translatable (after text confirmed)
- [x] Handle infinite player reload - Allow max 3 player reloads for the same video before fallback to older DASH, if player loaded the reload doesn't count
- [x] Handle player reload during playback - Reload while keeping timestamp
- [x] Handle SABR playback delay in the middle - keep toast for now
- [x] Handle infinite SABR playback delay - reload player after (per req) backoff requested 5 times / cumulative delay going to be larger than timeout for request
- [x] Handle infinite next request policy received - reload player after (per req) next request policy received 100 times
- [x] Enable SABR by default
- [ ] Handle more edge cases if found
Post PR
- Remove download feature (broken anyway)
Didnt test yet but im very sure this will close the SABR related issues
#7119 #6683
I really hope it being an experimental setting that is disabled by default is just because you have some things left in the remaining tasks section...
I don't think it should be enabled by default for the first release Otherwise there might be too many feedbacks to be handled Whether it should remain in experimental section depends on how many edge case found and not handled well (Might be moved or not before next release
If we are going to keep it as a setting for the moment, it definitely should stay in the experimental settings and we should have a very clear plan for getting rid of it ASAP. The MWEB workaround is a workaround and is unlikely to keep working forever, so if it breaks while we still allow people to not use SABR we will have to keep finding new workarounds, which quite frankly I don't want to have to do when we know that SABR is the proper solution.
If we keep it a setting I would suggest enabling it by default but having the setting there as a temporary opt-out, that way we'll get more feedback but people can also disable it temporarily if they have issues, until you've decided it is stable enough.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Im not seeing the return of audio tracks -> #6683
Conflicts have been resolved. A maintainer will review the pull request shortly.
Test fix not pushed this this PR yet: https://github.com/PikachuEXE/FreeTube/actions/runs/17907855602
Seems to resolve https://github.com/FreeTubeApp/FreeTube/issues/7921 but we have to check with users after release
Test fix not pushed this this PR yet: https://github.com/PikachuEXE/FreeTube/actions/runs/17907855602
Was using this and got hit with 404 earlier for a music
https://youtu.be/8tamOu8AwFE
It was only once so far.
@efb4f5ff-1298-471a-8973-3d47447115dc Audio track seems fixed (I don't have many videos to test) https://github.com/FreeTubeApp/FreeTube/issues/7921 seems to be timeout so this PR raising the timeout for SABR responses (due to bigger response body sometimes) might or might not make it better Auto reload currently only occurs when infinite retry detected (except redirect where none encountered yet)
@ArthurKun21 Let me know if it occurs more often. But could be YT testing new player which affects dev/current release too
From branch -> https://github.com/PikachuEXE/FreeTube/actions/workflows/build.yml?query=branch%3Asabr-pr
Build -> https://github.com/PikachuEXE/FreeTube/actions/runs/17933228357
https://youtu.be/ubfACjzvBOg
I go out of the window and then play the same video again. It played but like few seconds to the music it reloaded. Thought you might want the log for it
I got more reloads at the middle these few days No idea why, adding debug stuff to my custom build to find out...
Update 1: HTTP 403 Not player JS related (still using 0004de42) but no idea what causes it..
Update 2: Seems to be Failed to extract signature decipher algorithm all the time
Update 3: Testing new fix for audio track with less requests but not sure if that's the cause of 403 (so I enabled some logging and toasts - https://github.com/PikachuEXE/FreeTube/actions/runs/17939377956
https://github.com/PikachuEXE/FreeTube/actions/runs/17939377956
same music video -> https://youtu.be/ubfACjzvBOg
it still reloaded near the start
different music video https://youtu.be/EjlMPu5sEgw
same issue, reloaded near the start
- Should be sorted A-Z
- 2x Chinese is listed but i only see one on YT
English should be listed above descriptive
English should be sorted above descriptive
We don't sort the audio tracks, that was the same before this PR. Lets keep this PR focused on implementing SABR, all unrelated bugs and feature requests should be left until later.
Implemented fallback and tested a few days Fixes some of the issues but would still have issue (invalid poToken) sometimes (and I am not sure if YT issue or this PR issue) You can test with https://github.com/PikachuEXE/FreeTube/actions/runs/18115890405
Latest build, just merged dev and with proper commits (i.e. only debug/workaround changes in a separate branch for this build, others all in this PR Will make the new setting enabled by default next week if no major issues with playback (I expect you to test now if not started yet~
Update 1: forgot to put build link - https://github.com/PikachuEXE/FreeTube/actions/runs/18298073231
Before I forgot: It seems what player reload will be requested (when SABR enabled) once poToken expires I got this once I forgot to close a window and try to resume (and it starts buffering Not sure if works every time though
To fix the unknown type issues for the googlevideo imports could you please add these lines to the compilerOptions in the jsconfig.json file:
"module": "esnext",
"moduleResolution": "bundler",
Additionally the SabrStreamState type is referenced on lines 54 and 170 of the SabrSchemePlugin but is only defined on line 600, so Visual Studio Code treats it as if it doesn't exist, could you please move it earlier on in the file.
Updated
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Conflicts have been resolved. A maintainer will review the pull request shortly.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Conflicts have been resolved. A maintainer will review the pull request shortly.
New build created: https://github.com/PikachuEXE/FreeTube/actions/runs/18454142459 With fix for data import/export (https://github.com/FreeTubeApp/FreeTube/pull/8106) (So I can test on windows) And with https://github.com/FreeTubeApp/FreeTube/pull/8115 (Also removed hardcoded player ID)
New build: https://github.com/PikachuEXE/FreeTube/actions/runs/18482293990 No debug, with latest dev (with all fixes so no workaround needed) SABR also now enabled by default There should only be minor changes/fixes left if any (I hope
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Conflicts have been resolved. A maintainer will review the pull request shortly.
Maybe last build - https://github.com/PikachuEXE/FreeTube/actions/runs/18607715883 Fixed issues in https://github.com/PikachuEXE/FreeTube/issues/83 (maybe OS specific no idea) Added a tweak to load less data for video/audio requests (no idea how to test if it really loads less data) taken from https://github.com/LuanRT/googlevideo/blob/googlevideo-v4.0.4/src/core/SabrStreamingAdapter.ts#L426