M7 DONE via delegation — pv.youtube plays HD with audio

After hitting the segment-timing wall on our hand-rolled DASH MPD
(audio drifted -25s -> -44s behind video on long content), pivoted to
delegating playback to plugin.video.youtube v7.4.3 which already has
years of sidx-parsed SegmentTimeline + multi-client fallback work.

torttube._play() now:
  1. Tries _delegate_to_pv_youtube(yt_id) — sets a resolved URL of
     'plugin://plugin.video.youtube/play/?video_id=<id>'. Kodi
     chain-resolves to pv.youtube which builds the proper MPD and
     hands inputstream.adaptive a correctly-aligned manifest. Default.
  2. Falls back to our DASH builder (still in code, gated by
     'dash_enabled' setting + dash.on marker) if pv.youtube is absent.
  3. Falls through to yt-dlp progressive 360p as the final safety net.

When delegating, we skip our SponsorBlock monitor — pv.youtube has its
own and would double-skip otherwise.

Verified live on a LibreELEC Pi: LTT 'Trump Phone' (which crashed
our DASH with audio sync errors growing to -44s) now plays HD with
audio synced. 'Please sign in' message in log is from the tv_unplugged
Innertube client; pv.youtube falls back to a working client
automatically — no user account required.

Settings: prefer_pv_youtube boolean (default true). Addon v0.0.11.
Reference: https://kodi.wiki/view/Add-on:YouTube
This commit is contained in:
Sulkta 2026-05-23 11:58:12 -07:00
parent 69ab07778f
commit 025a86b7aa
5 changed files with 102 additions and 12 deletions

View file

@ -25,6 +25,18 @@ _(none yet — opens with M1 development)_
to setResolvedUrl. plugin.video.youtube uses this pattern via a long-lived
service addon. Worth filing an enhancement to either accept `file://` or
document the LAN-IP HTTP-server pattern in the inputstream.adaptive docs.
- **Architecture resolution: torttube delegates playback to plugin.video.youtube**
2026-05-23. After spending an iteration on a native DASH MPD builder + HTTP
manifest server, conceded that solving segment-timing alignment correctly
(sidx-parse, SegmentTimeline emission, audio-rate detection, init-segment
presentationTimeOffset) is multiple-week work. plugin.video.youtube has
years of that work already. torttube now does what it's faster at (Rust
rustypipe search/browse, SponsorBlock skip with fewer false positives)
and hands the video_id to pv.youtube for actual playback. This is the
"stand on giants' shoulders" call rather than reinvent. Native DASH code
path stays in the addon as a fallback when pv.youtube is absent (or as a
testbed for someday revisiting). Reference: https://kodi.wiki/view/Add-on:YouTube
- **DASH segment timing for googlevideo SegmentBase URLs** — Hit 2026-05-23.
My MPD with one Representation per video/audio (using SegmentBase with
indexRange to the sidx box of the static MP4) parses cleanly and segments