System Design - roto31/EXStreamTV GitHub Wiki
EXStreamTV System Design
Version: 2.6.0
Last Updated: 2026-02-21
For a full architecture overview, streaming lifecycle, restart safety, and AI model, see the Platform Guide. This document focuses on component layout and data models.
Overview
EXStreamTV combines StreamTV (Python/FastAPI, AI agent) and ErsatzTV (scheduling, transcoding, local media) into one platform. Clients connect via REST, M3U/EPG, or HDHomeRun emulation; the channel manager and ProcessPoolManager control streaming; the playout engine drives scheduling.
Component Layout
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXStreamTV Platform β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β WebUI (Jinja2) β Channels β Playlists β Schedules β Libraries β ... β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ β
β β REST API β IPTV M3U/EPG β HDHomeRun Emulator β SSDP Discovery β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ β
β β ChannelManager β SessionManager β ProcessPoolManager β StreamThrottlerβ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ β
β β Playout Engine β FFmpeg Pipeline β AI Agent (bounded) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ β
β β SQLite/PostgreSQL β Plex/Jellyfin/Emby β YouTube β Archive.org β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Plex β β Jellyfin β β IPTV β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
Core Components
FastAPI Application (exstreamtv/main.py)
- Lifespan: async startup/shutdown for database, channel manager, ProcessPoolManager
- Routers: REST, IPTV, HDHomeRun, WebUI, SSDP
- Static files and Jinja2 templates
Channel Manager (exstreamtv/streaming/channel_manager.py)
- Background streams per channel
- Shared streams for multiple clients
- Integration with ProcessPoolManager for FFmpeg spawn/release
- Buffer: 2MB with 64KB read chunks
ProcessPoolManager (exstreamtv/streaming/process_pool_manager.py)
Sole gatekeeper for FFmpeg processes. See Platform Guide Β§2.
acquire_process/release_process- Rate limiting, memory/FD guards, zombie detection
Circuit Breaker (exstreamtv/streaming/circuit_breaker.py)
Per-channel restart protection. States: CLOSED β OPEN β HALF_OPEN. See Platform Guide Β§2.
Session Manager (exstreamtv/streaming/session_manager.py)
Tracks client connections per channel. Idle timeout, cleanup, error counting.
Stream Throttler (exstreamtv/streaming/throttler.py)
Rate-limits MPEG-TS delivery. Modes: realtime, burst, adaptive, disabled.
Playout Engine (exstreamtv/scheduling/)
Schedule modes (Flood, Duration, Multiple, One), block scheduling, filler. See Advanced Scheduling.
FFmpeg Pipeline (exstreamtv/ffmpeg/)
Hardware detection (VideoToolbox, NVENC, QSV, VAAPI, AMF), encoder selection, filter chains, profiles.
AI Agent (exstreamtv/ai_agent/)
Bounded loop, tool registry, grounded envelope, containment. See Platform Guide Β§5.
Media Scanner (exstreamtv/media/scanner/)
Library sources (Plex, Jellyfin, Emby, local), metadata providers, collection building.
Data Models
Channel
# Simplified
id: int
number: int
name: str
streaming_mode: str # "iptv" | "hdhomerun" | "both"
playouts: List[Playout]
Playout
id: int
channel_id: int
program_schedule_id: int
anchor: PlayoutAnchor
items: List[PlayoutItem]
PlayoutItem
id: int
playout_id: int
media_item_id: int
start_time: datetime
finish_time: datetime
in_point: timedelta
out_point: timedelta
filler_kind: str
ProgramSchedule
id: int
name: str
items: List[ProgramScheduleItem]
# Modes: keep_multi_part_episodes, shuffle_schedule_items, random_start_point
Streaming and Playout Flow
Stream request flow (Client β SessionManager β ChannelManager β ProcessPoolManager β FFmpeg β Throttler) and restart decision logic are in Platform Guide Β§2.
Playout: Schedule Timer β TimeSlot/Balance Scheduler β Media Selection β Subtitle/Audio Pickers β FFmpeg β Channel Stream.
Configuration
config.yaml with EXSTREAMTV_ environment overrides:
server:
host: "0.0.0.0"
port: 8411
ffmpeg:
max_processes: 150
spawns_per_second: 5
memory_guard_threshold: 0.85
fd_guard_reserve: 100
hdhomerun:
device_id: "E5E17001" # Must be 8 hex chars
tuner_count: 4
Related Documentation
- Platform Guide β Full architecture, streaming, HDHomeRun, AI, observability
- TUNARR_DIZQUETV_INTEGRATION.md β v2.6 integration
- API Reference β REST and IPTV endpoints