Fix live HLS streaming with dynamic quality playlist URLs
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

The problem: HLS.js caches quality playlist URLs from the master playlist.
Even when we update the master playlist CID, HLS.js keeps polling the same
static quality CID URL, so it never sees new segments.

The fix:
- Store quality-level CIDs in database (quality_playlists JSONB column)
- Generate master playlist with dynamic URLs (/runs/{id}/quality/{name}/playlist.m3u8)
- Add quality endpoint that fetches LATEST CID from database
- HLS.js now polls our dynamic endpoints which return fresh content

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-04 21:07:29 +00:00
parent 4647dd52c8
commit 2f56ffc472
4 changed files with 150 additions and 23 deletions

View File

@@ -410,7 +410,18 @@ class MultiResolutionHLSOutput:
print(f"[MultiResHLS] Master playlist: {cid}", file=sys.stderr)
if self._on_playlist_update:
self._on_playlist_update(cid)
# Pass both master CID and quality info for dynamic playlist generation
quality_info = {
name: {
"cid": q.playlist_cid,
"width": q.width,
"height": q.height,
"bitrate": q.bitrate,
}
for name, q in self.qualities.items()
if q.playlist_cid
}
self._on_playlist_update(cid, quality_info)
def close(self):
"""Close all encoders and finalize output."""