Fix live HLS streaming with dynamic quality playlist URLs
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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user