$ show tsukumijima/KonomiTV
KonomiTV is a modern, full-stack online PVR/streaming server tailored for Japanese digital television (GR, BS, CS, BS4K). In production, it serves as a live TV player with hardware-accelerated transcoding (QSV, NVENC, VCE, FFmpeg), a complete EPG and recording scheduler, and deep social media integration (Twitter/X, Bluesky, Niconico Jikkyo). The system acts as a modern web frontend for the traditional EDCB and Mirakurun TV middleware. The backend is a Python FastAPI application executing complex pipelines for MPEG-TS parsing, live encoding, and metadata analysis. The frontend is a Vue 3/TypeScript Progressive Web App with offline storage via Service Workers. The codebase exhibits high craftsmanship in its low-level protocol interactions: it contains a complete reverse-engineered binary protocol parser for EDCB, an undocumented Twitter GraphQL scraper, and zero-dependency keyframe seekers for MPEG-TS and MP4 containers. While primarily an application, it incorporates significant reverse-engineering and data processing research, including automatic CM detection, computer vision-based thumbnail scoring, and BML data broadcasting support. The architecture is well-structured but heavily coupled to the Japanese TV ecosystem and multiple fragile third-party dependencies (custom binary forks, hardware-specific drivers, browser automation for social feeds). These dependencies introduce medium technical drift, but the project is actively maintained with thorough CI/CD and regular third-party updates.
The LLM identified 4 files worth highlighting for reuse:
A pure-Python, zero-external-dependency module that performs binary search on PCR timestamps in large MPEG-TS files to locate keyframe start positions. This enables instant seeking in recordings without scanning or FFmpeg. Its algorithmic approach and low-level understanding of the TS container format make it a highly reusable component for any TS-based video tool.
A dependency-free parser that navigates the ISO Base Media File Format atom hierarchy (stss, stco, stsz, stsc) to extract sync sample (keyframe) offsets and sizes. This module is a clean, reusable building block for media analysis tools that need to understand MP4 structures without invoking external processes like ffprobe.
A custom Starlette StreamingResponse subclass that monitors the HTTP connection lifecycle. On client disconnection, it asynchronously shuts down the associated encoding pipeline (LiveEncodingTask, VideoStream), preventing orphan processes and resource leaks. This is an essential, reusable pattern for any robust async media streaming service.
A comprehensive implementation of the EDCB (EpgTimerSrv) binary TCP and named-pipe control protocol. It meticulously defines the request/response binary structures for all tuner, recording, and EPG operations. This module represents deep reverse engineering of a proprietary protocol and is the definitive reference implementation for building Python-based EDCB clients.