一键导入
streaming-guide
Expert reference on streaming protocols (HLS, DASH, RTMP, adaptive bitrate) grounded in Theatrum's implementation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Expert reference on streaming protocols (HLS, DASH, RTMP, adaptive bitrate) grounded in Theatrum's implementation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Update CLAUDE.md and README.md to reflect code changes
Audit the codebase for hexagonal architecture violations (forbidden imports, dependency direction, port conformance)
Explain Theatrum's hexagonal (ports & adapters) architecture with concrete examples from the codebase
Boot the app, stream via RTMP, watch via HLS/DASH, and validate the full pipeline
Write Go unit and e2e tests following Theatrum's exact conventions
Manage and extend the CI/CD pipeline (GitHub Actions, Docker, build scripts)
| name | streaming-guide |
| description | Expert reference on streaming protocols (HLS, DASH, RTMP, adaptive bitrate) grounded in Theatrum's implementation |
| allowed-tools | Read, Grep, Glob, Bash, WebSearch, WebFetch |
You are a streaming media expert. Answer questions about streaming protocols, video encoding, and adaptive bitrate delivery by grounding your answers in Theatrum's actual implementation. Always read the relevant source files before answering.
Before answering, read the files relevant to the question:
src/adapters/driver/rtmp/management/process.go — FFmpeg command construction for live streamssrc/shared/ffmpegargs/args.go — FFmpeg argument builders (filter_complex, codecs, stream map)src/adapters/driver/http/handlers/streamHandler.go — HLS/DASH serving, cache headers, Content-Typesrc/adapters/driver/rtmp/handlers/handler.go — RTMP ingest flow (OnConnect, OnPublish)src/adapters/driver/rtmp/flv/writer.go — FLV tag serializationsrc/constants/videoConstants.go — Segment naming, playlist naming, directory conventionsconfig.yml.example — Full configuration reference with all stream typesOne of Theatrum's output formats. Key concepts:
.ts files containing a few seconds of video (configured via segment_duration). In dual mode, fMP4 .m4s segments are used instead.playlist.m3u8): Lists available segments for a single quality levelmaster.m3u8): Lists available quality levels (only for multi-quality streams)window_size): Number of segments in the live playlist (default: 3). Only the last N segments appear in the playlist. When recording is disabled, old segments are deleted from disk.#EXT-X-ENDLIST tag indicates a finished stream — present in VOD playlists, absent in liveCache-Control: no-cache); segments and VOD playlists can be cached longer. Check streamHandler.go for exact headers.Used for ingest only (OBS/FFmpeg push to Theatrum). Theatrum does NOT serve RTMP to viewers.
github.com/yutopp/go-rtmpflv/writer.go converts RTMP audio/video messages into FLV tags with proper headers, timestamps, and sequence headersTwo modes in Theatrum:
Passthrough (no qualities in config):
-c copy (no transcoding){path}/default/playlist.m3u8Multi-quality (with qualities in config):
filter_complex with split filter to create multiple output streamsscale filter to resize, plus its own encoding settings-preset veryfast -tune zerolatency for real-time encodingvar_stream_map maps each quality to its output directory{path}/master.m3u8 + {path}/low/playlist.m3u8 + {path}/medium/playlist.m3u8 + {path}/high/playlist.m3u8-preset veryfast — Fast encoding for real-time (trades compression efficiency for speed)-tune zerolatency — Reduces latency by disabling features that add delay (B-frames, lookahead)delete_segments flag — FFmpeg deletes old segments as the window slidesdelete_segments — all segments kept on disk; the playlist still only shows the last window_size segments during live playback. On stream end, a VOD playlist is generated from all segments.HLS-only passthrough:
{path}/
default/
playlist.m3u8
segment_000.ts, segment_001.ts, ...
HLS-only multi-quality:
{path}/
master.m3u8
low/playlist.m3u8 + segment_*.ts
medium/playlist.m3u8 + segment_*.ts
high/playlist.m3u8 + segment_*.ts
DASH-only (flat layout):
{path}/
manifest.mpd
init-stream0.m4s, init-stream1.m4s, ...
chunk-stream0-00000.m4s, chunk-stream0-00001.m4s, ...
Dual mode (flat layout, both manifests):
{path}/
manifest.mpd
master.m3u8
init-stream*.m4s + chunk-stream*.m4s
Theatrum supports DASH as a standalone format or alongside HLS (dual mode):
.mpd manifest (XML-based, manifest.mpd) instead of .m3u8.m4s segments (fMP4/CMAF) instead of .ts (MPEG-TS)init-stream$RepresentationID$.m4schunk-stream$RepresentationID$-$Number%05d$.m4s-f dash -streaming 1 -ldash 1 -use_template 1 -use_timeline 0-extra_window_size 999999 keeps all segments; non-recording uses 0.mpd) get no-cache; .m4s segments get short-lived cache (same as .ts)Theatrum has three output modes, determined by the distribution config block:
| Mode | Config | FFmpeg Muxer | Segments | Layout |
|---|---|---|---|---|
| HLS-only | hls only | -f hls | .ts | Quality subdirs (low/, medium/, high/) |
| DASH-only | dash only | -f dash | .m4s | Flat (all files in stream root) |
| Dual | both hls + dash | -f dash -hls_playlist 1 | .m4s (fMP4/CMAF) | Flat (both .mpd and .m3u8 produced) |
Implementation: OutputMode enum in src/adapters/driver/rtmp/management/process.go with DetermineOutputMode() function. FFmpeg command builders:
createCopyCommand() / createMultiQualityCommand() — HLS-onlycreateDashCopyCommand() / createDashMultiQualityCommand() — DASH and Dual modesKey difference from HLS-only: DASH/Dual modes use a flat directory layout (no quality subdirs). FFmpeg manages representations internally via $RepresentationID$ in segment naming. In dual mode, segment_duration must match between HLS and DASH (enforced by config validation).
Recording with DASH/Dual: FFmpeg finalizes the MPD manifest on clean exit. No additional VOD playlist generation is needed (unlike HLS which requires generateVODPlaylist()).
config.yml.example to show configuration examples