Update IPFS playlist CID in database during streaming for live HLS
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

- Add on_playlist_update callback to IPFSHLSOutput
- Pass callback through StreamInterpreter to output
- Update database with playlist CID as segments are created
- Enables live HLS redirect to IPFS before rendering completes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-04 00:23:49 +00:00
parent ed5ef2bf39
commit 9151d2c2a8
3 changed files with 33 additions and 1 deletions

View File

@@ -332,6 +332,26 @@ def run_stream(
interp.primitives.update(cid_prims)
task_logger.warning(f"DEBUG: streaming:make-video-source is now: {type(interp.primitives.get('streaming:make-video-source'))}")
# Set up callback to update database when IPFS playlist is created (for live HLS redirect)
def on_playlist_update(playlist_cid):
global _resolve_loop, _db_initialized
import asyncio
import database
try:
if _resolve_loop is None or _resolve_loop.is_closed():
_resolve_loop = asyncio.new_event_loop()
asyncio.set_event_loop(_resolve_loop)
_db_initialized = False
if not _db_initialized:
_resolve_loop.run_until_complete(database.init_db())
_db_initialized = True
_resolve_loop.run_until_complete(database.update_pending_run_playlist(run_id, playlist_cid))
logger.info(f"Updated pending run {run_id} with IPFS playlist: {playlist_cid}")
except Exception as e:
logger.error(f"Failed to update playlist CID in database: {e}")
interp.on_playlist_update = on_playlist_update
# Run rendering to file
logger.info(f"Rendering to {output_path}")
interp.run(duration=duration, output=str(output_path))