Playout Service: core HLS streaming (single channel, FFmpeg, SegmentStore port) #9

Closed
opened 2026-07-12 05:48:41 +00:00 by GKaszewski · 0 comments
Owner

Parent

#2

What to build

Create the Playout Service binary (crates/playout/, binary k-tv-playout). This is the core streaming engine per ADR-0002.

For this slice, implement single-channel playout: the service reads the active GeneratedSchedule, determines the current ScheduledSlot, resolves the source URI from the provider, and feeds it to FFmpeg to produce an HLS stream (.m3u8 playlist + .ts segments).

Key behaviors:

  • Shared broadcast: one HLS stream per channel, all viewers share segments
  • FFmpeg reads from the source URI on-demand (network URL or local file path — no full download)
  • Include all audio tracks and subtitle tracks from the source container
  • Sliding window segment retention: keep N segments around the current position, delete older ones. Window size configurable via env.
  • SegmentStore port: abstracts where segments are written. Implement a local filesystem adapter. The port should support write, read, list, and delete operations.
  • Serve the HLS playlist and segments via an HTTP endpoint (e.g., GET /playout/:channel_id/playlist.m3u8, GET /playout/:channel_id/:segment)
  • Handle slot transitions: when the current slot ends, start FFmpeg on the next slot's source URI seamlessly

InMemory SegmentStore adapter for testing.

Acceptance criteria

  • k-tv-playout binary compiles and starts
  • Given an active schedule with a slot, the playout service produces HLS segments from the source URI
  • HLS playlist is served via HTTP endpoint
  • Segments are written through the SegmentStore port (local FS adapter)
  • Sliding window cleanup deletes segments older than N positions
  • All audio tracks from source are included in HLS output
  • All subtitle tracks from source are included in HLS output
  • Slot transitions are handled (new FFmpeg process for next slot)
  • Configurable via env: segment duration, window size, storage path, listen port
  • SegmentStore port has an InMemory adapter for testing
  • Test: InMemory SegmentStore write/read/delete lifecycle

Blocked by

None — can start immediately

## Parent #2 ## What to build Create the Playout Service binary (`crates/playout/`, binary `k-tv-playout`). This is the core streaming engine per ADR-0002. For this slice, implement single-channel playout: the service reads the active GeneratedSchedule, determines the current ScheduledSlot, resolves the source URI from the provider, and feeds it to FFmpeg to produce an HLS stream (.m3u8 playlist + .ts segments). Key behaviors: - Shared broadcast: one HLS stream per channel, all viewers share segments - FFmpeg reads from the source URI on-demand (network URL or local file path — no full download) - Include all audio tracks and subtitle tracks from the source container - Sliding window segment retention: keep N segments around the current position, delete older ones. Window size configurable via env. - SegmentStore port: abstracts where segments are written. Implement a local filesystem adapter. The port should support write, read, list, and delete operations. - Serve the HLS playlist and segments via an HTTP endpoint (e.g., `GET /playout/:channel_id/playlist.m3u8`, `GET /playout/:channel_id/:segment`) - Handle slot transitions: when the current slot ends, start FFmpeg on the next slot's source URI seamlessly InMemory SegmentStore adapter for testing. ## Acceptance criteria - [ ] `k-tv-playout` binary compiles and starts - [ ] Given an active schedule with a slot, the playout service produces HLS segments from the source URI - [ ] HLS playlist is served via HTTP endpoint - [ ] Segments are written through the SegmentStore port (local FS adapter) - [ ] Sliding window cleanup deletes segments older than N positions - [ ] All audio tracks from source are included in HLS output - [ ] All subtitle tracks from source are included in HLS output - [ ] Slot transitions are handled (new FFmpeg process for next slot) - [ ] Configurable via env: segment duration, window size, storage path, listen port - [ ] SegmentStore port has an InMemory adapter for testing - [ ] Test: InMemory SegmentStore write/read/delete lifecycle ## Blocked by None — can start immediately
GKaszewski added the ready-for-agent label 2026-07-12 05:48:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GKaszewski/k-tv#9