Video delivery as libraries, one npm package over mediabunny: a just-in-time HLS and DASH origin you mount in the
server you already have (beeframe/packager/Serve), live ingest, ad breaks, DRM, CMCD, SCTE-35 and rendition
filtering — and a studio that tests players against it.
The studio tests video players against the faults real streams have: a fault-injecting origin. A developer POSTs a playback scenario (a stream plus faults), plays it in their own player, and reads back how the player handled it. Each play is a run, and runs of one scenario are compared while you tune the player.
Requires Node 24.
The origin is a function you mount in the server you already have:
npm install beeframeimport { SERVE_DEFAULTS, serve } from "beeframe/packager/Serve"
import { streamsOf } from "beeframe/packager/Stream"
/** Every stream is served as `/<stream name>/<file>`, its files read by `Range` through the fetch you pass. */
const origin = serve({
...SERVE_DEFAULTS,
fetch,
streamOf: streamsOf({ sintel: { source: { files: ["https://media.example/sintel/video-720.cmfv", "https://media.example/sintel/audio.cmfa"] } } })
})
const response = await origin.fetch(new Request("https://cdn.example/sintel/master.m3u8"))The studio is a library you start, and every setting is read from the environment it is given.
// server.mjs
import { STUDIO_DEFAULTS, studio } from "beeframe/studio/platform/Http"
const { port } = await (await studio(STUDIO_DEFAULTS)).listen()
console.log(`Listening on http://localhost:${port}`)npm install beeframe @mediabunny/server@npm:@ahmedrowaihi/mediabunny-server@<version>
PORT=41773 node server.mjs@mediabunny/server (the mediabunny fork's FFmpeg build, at the version beeframe' peerDependencies names) is an
optional peer only the encoder and the folders over it import; the origin needs no peer at all.
A proxy stream plays as soon as it is up. A generated stream is encoded from a synthetic source video in ASSETS_DIR
(./assets); the first play that needs one that is absent generates it there, once, which takes seconds to about a minute.
Every studio setting has a name — PORT, PUBLIC_URL, DATA_DIR and the rest under Settings —
which the studio reads once from the env it is given and passes to the libraries under it as arguments. Where the value comes from is the
host's choice: STUDIO_DEFAULTS passes process.env, and a host that wants a file, a literal or a
remote source passes its own env instead. A setting nothing states keeps its default.
Durations are written as "5 minutes". Runs, the encode cache and the source videos live in ./data,
./cache and ./assets beside the process unless DATA_DIR, CACHE_DIR and ASSETS_DIR say
otherwise.
From source, with pnpm (files stay in ./data, ./cache and ./assets):
pnpm install
pnpm make-assets # optional: pre-generate every synthetic source video into ./assets (skips files already there)
pnpm dev # the studio from source, the layer under Install, on PORT (41773)In another terminal:
curl -X POST http://localhost:41773/v1/scenarios \
-H 'Content-Type: application/json' \
-d '{
"name": "404 on video segment 3",
"stream": { "kind": "generated", "renditions": ["360p", "720p"] },
"faults": [{ "kind": "status", "status": 404, "segment": 3 }]
}'201:
{
"scenario": { "id": "sc_1a2b3c4d5e6f", "name": "404 on video segment 3", "spec": { "...": "defaults filled in" }, "createdAt": 1789300000000 },
"run": {
"id": "run_0f1e2d3c4b5a", "scenarioId": "sc_1a2b3c4d5e6f", "createdAt": 1789300000000,
"playback": {
"hls": "http://localhost:41773/play/run_0f1e2d3c4b5a/master.m3u8",
"dash": "http://localhost:41773/play/run_0f1e2d3c4b5a/master.mpd",
"events": "http://localhost:41773/v1/runs/run_0f1e2d3c4b5a/events",
"watch": "http://localhost:41773/runs/run_0f1e2d3c4b5a",
"play": "http://localhost:41773/runs/run_0f1e2d3c4b5a/play"
}
}
}Open run.playback.play in a browser: shaka plays the run, and run.playback.watch shows what it recorded. The
first request for a stream encodes it, so it responds within a minute or so; every later run of that stream is served
from ./cache. A body that does not match the spec is 400 with the path of each wrong or unknown key.
The same spec always gets the same scenario id. The run id is in every playback URL, so requests are attributed without the player sending anything.
POST /v1/scenarios: get a scenario and its first run.- Load
run.playback.hlsor.dashin your player (or openrun.playback.playfor shaka in the browser). - Watch
run.playback.watch(/runs/:id): requests, timeline, metrics, findings. - Change the player's config.
POST /v1/scenarios/:id/runs: a fresh run with fresh URLs. Play it.GET /v1/scenarios/:id/runs: every run, newest first, with metrics and findings, to compare.
GET /v1/runs/:id returns one run in full; a request in its timeline is { "kind": "request", "at", "requestIndex" },
pointing into requests. To wire up shaka, Media3 or AVPlayer on a real
device, see docs/integrate-a-player.md. The HTTP API's OpenAPI document is at /openapi.json.
kind is required: "generated" for a stream beeframe encodes, or "proxy" for a real HLS stream
(see Proxy a real stream). Every other field of a generated stream is optional:
| field | values | default |
|---|---|---|
codec |
avc1, hvc1, av01 |
avc1 |
renditions |
non-empty list of 144p, 360p, 720p, 1080p, 2160p |
["720p"] |
audio |
demuxed, muxed, video-only, audio-only |
demuxed |
frameRate |
24000:1001, 25, 30000:1001, 50, 60000:1001, vfr |
25 |
dynamicRange |
sdr, hdr10, hlg |
sdr |
addressing |
segmented, byterange-indexed, byterange-listed |
segmented |
drm |
null or { system, scheme, keys }: system clearkey, widevine, playready, fairplay; scheme cenc (default), cbcs; keys single (default), per-track, rotating |
null |
subtitles |
null, webvtt, ttml, cea608 |
null |
segmentSeconds |
1, 2, 4, 6: the target segment duration and key-frame interval, VOD and live |
2 |
live |
null or { lowLatency, partSeconds, window, duration }: lowLatency (default false); partSeconds 0.5 or 1, the low-latency part length (default 0.5); window 3-30 segments per live playlist (default 6); duration seconds, at least three segments, up to 86400 (default null for endless) |
null |
A key frame opens every segment (RFC 8216bis B.1).
A live playlist lists window segments: Apple HLS Authoring 8.11 wants at least 6, RFC 8216bis 6.2.2 at least three target durations.
PART-HOLD-BACK is three part targets (Apple 14.3), and the LL-DASH latency target is two segments plus that hold-back, so the
longest segment stays under half of it (DASH-IF Low-Latency Modes 9.X.4.5 (7a)).
A live stream with duration ends that many seconds after the run was created: each media playlist gains
EXT-X-ENDLIST over its final window and never changes again, and the final window's segments stay available
(RFC 8216bis 4.4.3.4, 6.2.1). The MPD stays
dynamic, loses @minimumUpdatePeriod and gains @mediaPresentationDuration, as the endlist-early fault ends one
(DASH-IF Timing Model 13.6.1). Low latency stops listing parts and preload
hints, and a blocking reload returns the final playlist at once (6.2.5.2: directives are ignored once the playlist has
EXT-X-ENDLIST). The end counts from the run's creation, not its first request, so every request and a restarted
origin agree on it without new state: create a run right before playing it. Reloading an ended playlist is the
reload-after-endlist finding. shaka-player 5.2.10 stops reloading the ended MPD but never fires ended on a dynamic
MPD (findings); HLS ends.
| kind | fields | effect |
|---|---|---|
status |
status (400-599), segment, track |
serves that segment with the status |
truncate |
segment, track |
cuts that segment short |
delay |
ms (1-110000), optional segment, track |
holds the response; without segment, every media segment of track |
ignore-range |
none | serves Range requests with the whole file |
omit-length |
none | sends no Content-Length |
drop-segment |
segment, track |
proxy: removes the segment from every media playlist, EXT-X-MEDIA-SEQUENCE unchanged; tests the same-number, same-URI check (RFC 8216bis 6.3.4, 6.2.2) |
gap |
segment, track |
proxy, HLS: tags the segment EXT-X-GAP and serves it 404; tests skipping a gap unloaded (4.4.4.7) |
missing-segment |
segment, track |
the segment stays listed without a tag and returns 404; tests retry, skip-ahead and error policy on a lost segment (6.2.1) |
stale-playlist |
segment, seconds (1-600), track |
proxy: once the segment is listed, media playlists stop changing for seconds; tests reload cadence and stale detection (6.3.4, 6.2.1). Refused on a VOD playlist, a static MPD, or an MPD whose @minimumUpdatePeriod is longer than seconds |
sequence-shift |
segment, by (non-zero), track |
proxy: once the segment is listed, EXT-X-MEDIA-SEQUENCE jumps by by (negative rewinds) over the same URIs; tests choosing the next segment by number (6.3.5, 6.2.2) |
hide-discontinuity |
track |
proxy: removes every EXT-X-DISCONTINUITY; tests a timestamp change without its signal (4.4.4.3) |
extinf |
factor (0.1-10), optional segment, track |
proxy: scales EXTINF durations, target duration unchanged; tests timeline and buffer math on wrong durations (4.4.4.1, 4.4.3.1) |
endlist-early |
optional segment, track |
proxy: ends and freezes the playlist after the segment (default: the run's first load); tests the live-to-VOD end and reload stopping (4.4.3.4, 6.3.4) |
endlist-remove |
track |
proxy, HLS: strips EXT-X-ENDLIST; tests an ended stream that never says so (6.2.1) |
interstitial-asset |
status (400-599) |
needs a stitch with delivery: "interstitial": every file of its ad asset returns that status, as an ad server that is down does. The primary stream is untouched, so what it tests in a player is whether it keeps playing it |
init-mismatch |
segment (2 or more) |
generated HLS VOD with two or more renditions and no stitches: from the segment on, each video playlist adds EXT-X-DISCONTINUITY and an EXT-X-MAP naming the next rendition's init, so decoding fails at the swap; tests whether a player tells the application (findings) |
scte35-bad-crc |
none | needs a stitch with signal: "scte35": every served splice_info_section has a wrong CRC_32, as a public USP origin sends |
scte35-pts-wrap |
none | needs a stitch with signal: "scte35": each section's pts_adjustment is 2^33 − pts_time, so the adjusted time wraps to 0, as livesim2 sent |
Nine of these are playlist faults — drop-segment through endlist-remove: they edit a proxied stream's media playlists and are refused on a generated
stream. segment counts as for a proxied live stream below. Each served playlist a fault changed records that
fault, and the run's findings add gap-segment-requested, dropped-segment-requested, stale-playlist-reload
(an unchanged playlist reloaded sooner than half a target duration or later than 1.5) and reload-after-endlist.
curl -X POST http://localhost:41773/v1/scenarios \
-H 'Content-Type: application/json' \
-d '{
"name": "real live, 503 on segment 2",
"stream": { "kind": "proxy", "url": "https://demo.unified-streaming.com/k8s/live/scte35.isml/.m3u8" },
"faults": [{ "kind": "status", "status": 503, "segment": 2 }]
}'run.playback.hls serves the upstream's playlists with every URI rewritten under the run, and streams
segments from upstream with Range passed through. The same faults apply. For a live upstream, segment n
counts from the oldest segment listed the first time the run loads a playlist of that track. Each recorded
request adds upstreamMs and upstreamStatus.
A player joins a live stream at its edge, so on a long window a low segment is never requested and its
fault silently never fires: against a 313-segment window, faults on segments 2, 3, 8 and 12 all sat behind
the edge and only fault-never-fired said so afterwards. Pick a number near the window's end.
headers(optional, e.g.{ "authorization": "Bearer …" }) go only to the url's origin; values are redacted in every response. The player's own cookies and authorization are never forwarded.- Upstreams on loopback, private, link-local or metadata addresses are refused (
403 ProxyNotAllowed) unlessPROXY_ALLOW_HOSTSnames the host. Every redirect hop is checked again. - What a run has listed, numbered, pinned and held lives in memory, and is lost when the process restarts or the run
is evicted after 1000 later runs.
RUN_STATE=disksaves it under the data folder within a second of each playlist load, so a restarted origin serves the run as if it had not stopped. The newest 10 000 saved runs are kept. - The playlist is fetched once at
POST: unreachable is504 UpstreamUnreachable, neither HLS nor an MPD is422 UnsupportedUpstreamwith itsreasons. An MPD upstream plays atrun.playback.dash. - A body that does not match the spec is
400 InvalidRequestwith every issue:{ "_tag": "InvalidRequest", "error": "Invalid request: stitches[0].every: every must be more than duration.", "issues": [{ "path": "stitches[0].every", "message": "every must be more than duration" }] }.
curl -X POST http://localhost:41773/v1/scenarios \
-H 'Content-Type: application/json' \
-d '{
"name": "10 s ad every minute",
"stream": { "kind": "proxy", "url": "https://demo.unified-streaming.com/k8s/live/scte35.isml/.m3u8?hls_fmp4" },
"stitches": [{ "at": 20, "duration": 10, "every": 60, "timestamps": "continuous", "signal": "daterange" }]
}'Each break replaces the upstream segments whose EXTINFs cover duration with a generated clip. The slots keep
upstream's sequence numbers, sit behind EXT-X-DISCONTINUITY and the clip's EXT-X-MAP, and the playlist returns to
upstream the same way. A generated stream takes the same stitches: see Stitch an ad into a generated stream. at is seconds of upstream after the live edge of the run's first playlist load (VOD: after
its start). timestamps is reset (the clip starts at 0) or continuous (it carries on from the replaced segment's
tfdt). clip (codec, renditions, frameRate) defaults to the nearest match to the upstream.
delivery is spliced (the default: the break's segments are replaced, so the player sees one timeline),
interstitial, or interstitial-list. The two interstitial forms leave the primary timeline alone and announce the
break with an EXT-X-DATERANGE carrying CLASS="com.apple.hls.interstitial", and X-RESUME-OFFSET and
X-PLAYOUT-LIMIT both the break's duration, for the player to fetch and schedule the ad itself and skip the content
it replaces: interstitial names the ad with
X-ASSET-URI, and interstitial-list names a JSON document with X-ASSET-LIST, as an ad server returns —
{"ASSETS":[{"URI":…,"DURATION":…}]}, served at assets.json. A tag carries one or the other, never both. The asset
is served under /play/<run>/~interstitial/<stitch>/, cut to the break's own duration. Both forms are HLS only: a
DASH copy is refused, since only HLS has the tag. Verified in shaka and hls.js, which both do the whole hop — the
list, then the asset it names, then its media.
scenario.clips lists, per stitch, the clip that was built and every mismatch with an upstream rendition: profile,
level, resolution, frame rate, channels, audio codec and timescale. Mismatches are allowed; the DISCONTINUITY is what
makes them legal. Ad files are served under /play/<run>/~ad/ and recorded with a stitch marker. A fault's segment
hits a slot as the upstream segment number it replaced.
On a DASH upstream a break is an ad Period. The upstream Period is split at the break, the clip plays in Period
cb-<stitch>.<k> with its own SegmentTemplate, and upstream resumes in a copy of its Period whose
@presentationTimeOffset and @startNumber keep every segment at its time and URL
(DASH-IF Timing Model 9.1,
DASH-IF IOP Part 5). Period ids never change across
MPD reloads, and pieces behind the time-shift buffer are removed. signal: "daterange" adds an EventStream
urn:com:beeframe:ad Event spanning the ad Period.
signal: "scte35" sends a real SCTE-35 splice_info_section (ANSI/SCTE 35 2023r1 9.6): splice_insert, or time_signal
with Provider Placement Opportunity start and end descriptors via "scte35": { "command": "time_signal" }. pts_time is
the replaced segment's tfdt in 90 kHz ticks, in both timestamps modes, and the id is k × stitches + stitch. A splice
time the upstream segment does not reveal within STITCH_SPLICE_TIMEOUT is sent as splice_immediate instead, as USP
sends it, so the first playlist listing a break always carries its section and never changes it later.
"scte35": { "hls": [...] } picks the HLS carriage, ["daterange", "cue"] by default: daterange the DATERANGE pair with
SCTE35-OUT and SCTE35-IN (RFC 8216bis 4.4.5.1.1), cue #EXT-X-CUE-OUT:<duration> before the first slot and
#EXT-X-CUE-IN before the return, as USP sends them, and oatcls AWS Elemental's #EXT-OATCLS-SCTE35:<base64> on the
first slot with #EXT-X-CUE-OUT-CONT:ElapsedTime=<s>,Duration=<d>,SCTE35=<base64> on every later one, which is how a
player joining mid-break learns how far in it is. DASH gets an urn:scte:scte35:2014:xml+bin Event on
the ad Period with the OUT section in <Signal><Binary> (SCTE 214-1 7.7.2.1), and emsg
v1 urn:scte:scte35:2013:bin in the video segments that start in the segment × (1 + ceil(4 / segment)) s before the break, so one is whole 4 s ahead (SCTE 214-1 7.7.3, IOP Part 10 6.2.3.1).
A proxied stream's lead segments are the only bytes beeframe rewrites: each is read whole (at most PROXY_WHOLE_BYTES,
so its first byte reaches the player later than a relayed one), the box goes before the first moof with any sidx
offset fixed, and Range and conditional requests are served over the rewritten bytes. No player request says a cue arrived, so no finding claims it;
the /runs/<id>/play page (shaka only) posts timelineregionadded and emsg for SCTE-35 schemes, shown as cue entries
in the run's timeline. What each player reads: hls.js parses SCTE35-* DATERANGE attributes, shaka passes them and DASH
Events through timelineregionadded and emsg, dash.js dispatches MPD and declared inband events, Media3 reads only
interstitial DATERANGEs in HLS and EventMessage metadata in DASH; none decodes the section.
Refused with 422 on HLS: MPEG-TS segments, EXT-X-KEY encryption, LL-HLS (EXT-X-PART-INF), every on VOD, an every that puts more than 32 breaks in the live window, and
signal without EXT-X-PROGRAM-DATE-TIME. On DASH: ContentProtection, LL-DASH (availabilityTimeOffset),
SegmentBase or SegmentList, remote Periods, every on a static MPD, and timestamps: "continuous" (a Period maps its
own timestamps).
curl -X POST http://localhost:41773/v1/scenarios \
-H 'Content-Type: application/json' \
-d '{ "stream": { "kind": "generated", "live": {} }, "stitches": [{ "at": 4, "duration": 6 }] }'The stream's own playlists and MPD go through the same stitching, break plan and findings as a proxied upstream's,
read from its build rather than fetched. With clip: null the clip is the stream's own codec, renditions, frame
rate, audio layout and dynamic range, so mismatches is empty; name a clip to test a decoder change on purpose.
A generated run serves both formats, so a stitch is planned in each: one that only HLS or only DASH can carry plays
in that format (scenario.format), and the other returns 422 with why. timestamps: "continuous" plays only
in HLS. Generated HLS media playlists date every live segment, and a VOD playlist's first, with EXT-X-PROGRAM-DATE-TIME
on the clock the MPD's @availabilityStartTime names, so signal plays in both formats. Refused in both:
low latency, byterange-* addressing, drm, and every on VOD. A run's break plan and segment numbers are shared by
its formats: play HLS and DASH in separate runs. With live.duration, a break whose return would come after the end
is not started.
A stream that breaks one of these is refused at POST /v1/scenarios with 422 UnsupportedStream and every broken
rule in reasons:
webvtt-needs-segmented,ttml-cannot-be-indexed,cea608-needs-video(notaudio-only)vfr-needs-avc1,vfr-needs-360p-720p-1080p,vfr-needs-sdr,2160p-needs-sdrfairplay-needs-cbcs,multiple-keys-need-clearkey(per-track,rotating),per-track-keys-need-muxedlive-needs-segmented,low-latency-cannot-be-muxedpart-must-be-shorter-than-segment(lowLatencywithpartSecondsat leastsegmentSeconds),live-duration-under-three-segments(durationunder 3 ×segmentSeconds)
A playlist fault (drop-segment, gap, stale-playlist, sequence-shift, hide-discontinuity, extinf,
endlist-early, endlist-remove) rewrites a relayed playlist, so on a generated stream the spec itself is refused,
400 like any fault a scenario cannot carry.
Every response carries the scenario as one line. Paste it into a message; whoever pastes it back gets the same scenario, under the same id, with nothing to download:
curl -s localhost:41773/v1/scenarios/<id> | jq -r .share
# cb1.eyJuYW1lIjoiNDA0IG9uIHNlZ21lbnQgMyIsInN0cmVhbSI6…
curl -X POST localhost:41773/v1/scenarios -H 'Content-Type: application/json' \
-d '{"share":"cb1.eyJuYW1lIjoiNDA0IG9uIHNlZ21lbnQgMyIsInN0cmVhbSI6…"}'The id is a digest of the spec, so the match needs no coordination: the same scenario is the same id
on any machine. A proxy scenario's line is built from the redacted spec, so it never carries the
upstream's credentials: header values, URL user and password and query values are replaced with …, and the
receiver supplies their own.
The agent skill drives the HTTP API above: POST /v1/scenarios to create one, POST /v1/scenarios/:id/runs for the next
attempt, GET /v1/runs/:id for what a run recorded, and GET /v1/scenarios/:id/runs to compare.
Playback URLs start with PUBLIC_URL (default http://localhost:<PORT>).
When the player runs on a phone or TV, set it to the laptop's LAN address:
PUBLIC_URL. Browsers on any other origin get 403;
clients that send no Origin are allowed. There is no authentication, so anyone who can
reach the port can call the tools.
The skill in docs/skills/beeframe teaches an agent the loop:
reproduce, choose faults, change one player setting, compare runs. Copy it into the player repo's
project skills (Claude Code skills).
beeframe/studio/core serves a run's stream without HTTP: build it with coreOf and call playback.fetch directly,
from a test, a worker or another transport. It needs no database — a run is a folder under DATA_DIR.
import { run } from "beeframe/gen/Gen"
import { coreOf } from "beeframe/studio/core/playback/Playback"
import { ScenarioSpec } from "beeframe/spec/media/Spec"
import { coreOptionsAt } from "beeframe/studio/core/platform/Options"
import { decodeOrThrow } from "beeframe/schema/Schema"
const core = coreOf(coreOptionsAt({ dataDir: "./data", assetsDir: "./assets", cacheDir: "./cache" }))
const created = await run(core.scenarios.create(decodeOrThrow(ScenarioSpec, { stream: { kind: "generated" } })), AbortSignal.timeout(60_000))
if (created.ok) {
const response = await core.playback.fetch(new Request(`http://localhost/play/${created.value.run.id}/master.m3u8`))
console.log(response.status, Object.fromEntries(response.headers))
}
await core.close()The response is a web Response; faults, Range, live timing and recording are applied as the server applies them. See src/app/studio/core.
pnpm dev # the studio from source on PORT (41773)
pnpm test # unit tests
pnpm typecheck
pnpm lint
pnpm verify # end to end in Playwright, driving the installed Google Chrome (its HEVC and DRM), as verify-origin and verify-drm do
pnpm verify-origin # shaka plays the just-in-time origin's DASH and HLS, a filtered ladder, a trimmed window and a mid-roll ad, and decodes nothing without keys
pnpm verify-drm # a real Widevine CDM decrypts origin-encrypted content: needs the internet, so it is not part of pnpm verify
DRM_KID=… DRM_KEY=… DRM_LICENCE_URL=… pnpm licence-origin # serves one stream from a licence server's key and prints URLs for a headed browser
pnpm bench # req/s and latency per endpoint; BENCH_MODE=loop measures event-loop stalls
pnpm bench-origin # the just-in-time origin's own request path: what packaging and encrypting each response costs
pnpm verify-store # the Store port and the ingest log against a real S3-compatible bucket: compare-and-set, paged listing, compaction, no accepted push lost
pnpm soak [channels] [segments] # what a soak is meant to find, driven by operation count rather than by waiting
pnpm verify-cdn # every caching claim behind real caches: Varnish and nginx in Docker in front of the origin, and what reached the origin
pnpm distil-capture <capture dir> <fixture dir> # a recorded ingest capture reduced to what is worth committing: pushes, order, headers, responses
pnpm make-bench-video <from> <to> [fps bitrate height] # a fragmented CMAF rendition for pnpm bench-origin's BENCH_VIDEO
pnpm rendition <file.mp4> [threshold] # a rendition's NAL sizes and the share of slice bytes above the native-cipher threshold
pnpm reordering <media playlist url|file> [segments] # where a stream stopped presenting frames in the order they were shot
pnpm build # the package's JavaScript and .d.ts into dist/, what npm runs
pnpm pack-check # pnpm pack beeframe, install the tarball in a temp folder, import each folder alone, launch the published server from itOnly the studio reads the environment, and its README lists every variable. The libraries take arguments, documented with each: core (runs, builds, playlists, findings), proxy, packager, ingest and store.
Counts are positive integers (PROXY_MAX_REDIRECTS may be 0), durations are text such as 15 seconds or 500 millis, and an invalid value stops startup. OpenTelemetry export is off unless the standard OTEL_* variables are set, OTEL_EXPORTER_OTLP_ENDPOINT with OTEL_TRACES_EXPORTER=otlp, which exports a run's trace as OTLP/HTTP JSON; logs and metrics are not exported.
pnpm changeset records a change note; pnpm version-packages bumps the version and writes
CHANGELOG.md. The repository root is beeframe, the one published package; files keeps tools/ and
docs/ out of its tarball.
Publishing is a separate, manual step.
The two products in file order, so a trace has a map. Every step is a plain function or a service method; nothing on either path is reached through a framework.
The testing tool, GET /play/<runId>/v0/index.m3u8:
studio/platform/Http.tsroutes it and hands core'sPlaybackthe webRequestit is.core/playback/Playback.tsserves it: the run's scenario fromcore/scenarios/Scenarios.ts, its stream fromcore/media/Builds.ts(a bundleencoderandlivesimpackaged on a worker, orproxy/Remote.tsrelaying a real one), on the wall clock throughlivesim/Live.tswhen the stream is live.core/playlists/Playlists.tswrites the playlist the player gets: links throughmanifest/Links.ts, ad breaks throughbreaks/HlsStitch.ts, faults throughmanifest/HlsFaults.ts, with the run's own numbering and held copies incore/playlists/Runs.ts.Playbackrecords the request oncore/sessions/Sessions.ts; the run page reads it back as a timeline and findings throughfindings/Timeline.tsandfindings/Findings.ts.
The production origin, GET /ch1/v0/index.m3u8, the path starting at the stream name once the host's router
stripped any prefix of its own:
- The host's server hands a web
Requesttoserve(...).fetch— Bun, Deno and Workers as it is, Node through a dozen lines of its own.serve'sfetchinpackager/Serve.tsreads the stream name throughpackager/serve/Route.tsand the headers throughpackager/serve/Request.ts. packager/Serve.ts, top to bottom:streamResponseOfadmits the request (a streaming file), calls the deployment'sstreamOfrule for the stream name, with the request, throughStream.ts, turns a refusal into its status, and hands the stream tofinishedResponseOforliveResponseOf; an upstream is read into the same segment index byUpstream.ts.- Files are read by
Rangerequests through the deployment'sfetchinStream.tsand indexed throughEngine.ts(probe once, cut a byte range or write a progressive file's segment, encrypt it withpackager/drm/Encrypt.ts); a live stream reads itsLiveSource— here the windowingest/Ingest.tsfolded from the pushes it received (ingest/Window.ts), listed throughingest/Live.ts. - A manifest is written by
packager/Manifest.tsfrom that segment index, filtered throughladder/Ladder.ts, its ad breaks announced bypackager/Breaks.tsoverbeeframe/breaks, and delivered under the contract inhttp/Cache.tsandhttp/Range.ts. Every response is computed the same on every instance, which is what lets a second one serve the same bytes.webOfwrites the response as a webResponse, a growing segment as aReadableStreamthat errors if the segment stops being held.
Each folder of the package is a module path, beeframe/<folder>/<Module>. Only what a host imports runs, and an
optional peer is needed only by the folders that import it.
| module | what |
|---|---|
beeframe/studio |
the HTTP origin: the /v1 API, /play, the run pages and the shaka harness |
beeframe/studio/core |
scenarios, runs, fault-injecting playback, each run's playlists and findings, streams built on worker threads, with no transport |
beeframe/studio/findings |
a run's timeline, metrics and findings from what it recorded |
beeframe/studio/livesim |
the testing tool's bundle, packaged by the packager's engine, and LIVE: that bundle on the wall clock, low latency included |
beeframe/studio/manifest |
changes playlists and MPDs from any source: link rewriting, faults, MPD ad stitching, flawed SCTE-35 |
beeframe/studio/proxy |
relays a real stream with SSRF-safe fetches |
beeframe/spec |
the wire contract: ScenarioSpec, run results, errors and the route table, for typed clients |
beeframe/encoder |
ENCODE: any video file into an ABR ladder of one-track mp4s written wherever the host keeps media, trick-play thumbnail sheets and poster frames, loudness measured and normalised to EBU R 128 or ATSC A/85, WebVTT, TTML (IMSC1) and SRT converted into each other and CEA-608 read out of a video, deinterlacing, a source video into one rendition's mp4 for the studio, and the synthetic source videos it writes; requires the mediabunny fork's @mediabunny/server |
beeframe/packager |
PACKAGE: one engine from files, an upstream or a live source to HLS/DASH manifests and encrypted segments, written per request by serve (a just-in-time origin, filtered by aws.manifestfilter and trimmed per query); DRM and captions included; requires the mediabunny fork |
beeframe/breaks |
the ad half of playlist transforms: break plans, clip matching, HLS stitching and splicing, SCTE-35 placement, cues and HLS interstitials; pure, and importable alone |
beeframe/ads |
the ad decision client a stream's breaks is built with: IAB VAST 4.x (2.0 and 3.0 alike) with its Wrappers, pods and tracking, VMAP for a finished stream's schedule, ads conformed to the stream's ladder through encoder on first use, server-side beacons sent by serve or client-side tracking at /v1/tracking/<session>, bumpers, overlays, a personalization threshold, avail suppression, a live pre-roll, prefetch windows and dynamic ad variables, as MediaTailor's; requires the mediabunny fork's @mediabunny/server |
beeframe/relay |
an MPEG-TS transport relay, as MediaConnect's: a live SRT, RIST or RTP input (SMPTE 2022-1 FEC, SMPTE 2022-7 merged paths) sent byte for byte to several outputs, every PID kept, failing over between inputs with continuity counters that never jump, each input monitored to ETSI TR 101 290 priority 1 and 2 and the programs and codecs it carries, each output with its own backlog and reconnect; requires the mediabunny fork's @mediabunny/server |
beeframe/ingest |
a DASH-IF Live Media Ingest (Interface-1) and HLS (PUT/DELETE, MPEG-TS or fMP4) receiver over the fetch contract: pushed objects become a channel's sliding window, redundant pipelines chosen per segment by MQCS |
beeframe/packager/drm |
content protection: one Protection value, key providers (static, CPIX/SPEKE, minted, licence-server), PSSH and FairPlay signalling, the per-segment cenc IV, key rotation and a key wrap seam |
beeframe/packager/cpix |
CPIX/SPEKE key exchange as a Keys rule for drm, through the optional cpixts, so a deployment that holds keys elsewhere never installs a CPIX client |
beeframe/base |
what every folder shares: Result, JSON and its guards, one hex and base64 codec, the numbers media times are written with, and a bounded LRU map; imports nothing |
beeframe/ladder |
which renditions a manifest offers: a filter (FilterSpec) and the transforms it means, with MediaPackage's aws.manifestfilter grammar in Aws, importable without an origin |
beeframe/schema |
a JSON validator with static inference: decode a request body into its type with a path and a message for what is wrong, and the JSON Schema an OpenAPI document states for it |
beeframe/cmcd |
CMCD v2 read from requests and Event Mode bodies, CMSD written for responses, no dependencies |
beeframe/http |
how media bytes are delivered: RFC 9110 byte ranges and 206/416, the cache-control contract, RFC 8216bis delivery directives and blocking reload; shared by both products |
beeframe/store |
the state several instances share, behind one port with a version in its contract: a memory implementation, and one over an S3-compatible bucket so several receivers or origins over one bucket serve as one |
beeframe/gen |
the runtime the folders are written on: generator functions composed with yield*, their failure union inferred, tagged errors, cancellation by AbortSignal reaching every await and sleep with cleanup run to the end, bounded concurrency, shared lookups, permits and virtual time for tests, over beeframe/base alone |
beeframe/scte35 |
SCTE-35 splice_info_section encode and decode, and the emsg box, no dependencies |
beeframe/ts |
MPEG-TS packets read in place: header fields, PAT and PMT tables, PES starts, and the continuity counter restamp a splice or remux needs, no dependencies |
The optional peers, by the folders that import them: @mediabunny/server, the mediabunny fork's FFmpeg build, by encoder (and so ads, studio/core and studio) and relay's tests;
its RIST (simple and main profile, in TypeScript) and SRT bonding (over the libsrt it ships for each platform) are
constructed by a host of relay or encoder/Live and passed in; node-av, the FFmpeg
binding it is built on, by encoder for image encoding and filters; cpixts by
packager/cpix; shaka-player by the studio's harness page. mediabunny is an npm alias to the @ahmedrowaihi/mediabunny
fork; overriding it with upstream mediabunny breaks packaging.
tools/conformance holds verify, bench, pack-check and make-assets; it does not ship in the tarball.
Docs: integrate a player, architecture, the production origin, the CDN, the token and the origin, findings, prior art.
MIT, see LICENSE.