Why Bunryu is built the way it is, and why some obvious alternatives are not used. Each entry gives the decision, the reasons, the evidence behind them, and what would make it worth revisiting. Most of the evidence comes from tests run in October 2026 against SRS 6.0-r2, MediaMTX v1.21.2 and the pinned FFmpeg 7.1. The short decision records (rules and rejected refactors) are in the decision records.
Current architecture in one paragraph
SRS accepts RTMP and plain SRT publishes and authorizes them through its HTTP
hooks. Bonded SRT goes through goryu, which merges the legs and
forwards one SRT stream to SRS. Every output is its own FFmpeg process that
pulls its input from SRS over loopback, in the input's own protocol, and pushes
to one destination (outputs that need the same encode pull one shared encode
instead). The diagram is in the
Introduction.
Media server
Use SRS for ingest, from the official release
Decision: SRS handles RTMP ingest, plain SRT ingest, the publish/play hooks, the stream API and the local fan-out to outputs. The installer pins the official release binary (currently v6.0-r3) by SHA-256.
Why:
- These are SRS's core features: widely deployed, and stable in production here.
- v6.0-r3 bundles libsrt 1.5.6 (as r2 did), which fixes CVE-2026-55868/55869.
- A custom build was tried (a 6.0 branch with one patch, built by CI). It was
dropped once its only patch turned out to be in a feature Bunryu doesn't use
(
srt_to_rtmp, below).
Revisit when: Bunryu needs an SRS change before upstream releases it, for
example per-client SRT stats (ossrs/srs#4769). The release pipeline for a
patched build still exists (bunryu/6.0 in live-miracles/srs).
Keep SRS's srt_to_rtmp off; FFmpeg converts SRT inputs
Decision: SRT inputs stay native MPEG-TS inside SRS. Anything that needs RTMP from an SRT input gets it from FFmpeg, not from SRS's built-in bridge.
Why: the bridge failed in several independent ways (tested on the official v6.0-r2):
- Video frames dropped. A plain H.264 + AAC SRT stream came out at about 13 fps instead of 25, with regular gaps over 200 ms. The same stream pulled over SRT, and the same source published over RTMP, both kept 25 fps.
- Multiple audio tracks are interleaved into the single RTMP audio track, producing garbage audio. They aren't reduced to one track.
- Non-AAC audio (MP2, as many hardware encoders send) gives a silent RTMP side, and SRS logs about 8 warnings a second for as long as the input is live.
- 48 kHz AAC got wrong frame timestamps, which broke the audio. A fix was submitted upstream (ossrs/srs#4765, backport #4774) but isn't in a release.
FFmpeg's MPEG-TS demuxer handled all of these cases correctly, including HEVC and a 33-bit timestamp wrap.
The bridge looks immature. These aren't corner cases: a 48 kHz AAC track, a second audio track or MP2 audio are ordinary encoder output.
- The 48 kHz bug has been present since the SRS 5.0 SRT rewrite.
- Its audio is only audibly broken where players place audio by timestamp (HLS in a browser, YouTube ingest). Players such as ffplay and the HTTP-FLV web player hide it.
This suggests few people run the bridge in production. FFmpeg's MPEG-TS demuxer, by contrast, handles damaged broadcast streams every day, in Bunryu's own outputs too.
Revisit when: a release fixes the issues above and passes the same tests: frame count, two audio tracks, MP2/AC-3, HEVC, timestamp wrap.
Don't use SRS's built-in forwarding for outputs
Decision: outputs are FFmpeg processes, not SRS forward destinations.
Why:
- SRS 6.0 can't add or remove a forward destination on a live stream without kicking the publisher, which cuts every other destination. A runtime API was proposed upstream (ossrs/srs#4760) and declined.
- A forward runs inside the SRS process, so a bug there affects every stream. An FFmpeg output can only fail on its own.
Don't use MediaMTX for SRT ingest or SRT→RTMP conversion
Decision: MediaMTX isn't in the ingest path.
Why:
- Its SRT stack is gosrt, which is much less used and maintained than Haivision's libsrt (used by SRS, FFmpeg and the relay). On public ingest, SRT's loss recovery is the part that matters most.
- Its SRT→RTMP conversion was tested behind the libsrt relay, so MediaMTX
only ever saw a clean loopback connection. Results:
- Readers are disconnected under realistic loss. With 80 ms one-way delay
and 5–10% loss, MediaMTX closed the RTMP reader within seconds (
too many reordered frames). It rebuilds DTS from the H.264 bitstream for RTMP output, and missing frames break that calculation. Every output of the pipeline would reconnect at once. The FFmpeg path stayed connected through 10% loss. - HEVC video is dropped for RTMP readers that don't announce enhanced-RTMP codecs. FFmpeg 7.1 can't announce them when reading.
- An MP2 audio track makes the whole RTMP read fail, video included.
- It cleanly kept the first of two audio tracks and handled a timestamp wrap.
- Readers are disconnected under realistic loss. With 80 ms one-way delay
and 5–10% loss, MediaMTX closed the RTMP reader within seconds (
- Less mature than FFmpeg on damaged input. With realistic packet loss, holes
remain in the MPEG-TS stream after SRT's retransmissions; this is common for
SRT over real networks. MediaMTX's conversion did worse than FFmpeg's in every
loss test:
- it disconnected readers under random loss, where FFmpeg kept going;
- after long outages it passed on more out-of-order timestamps (9 against 1);
- it logged nothing about the holes.
Don't build on datarhei Restreamer
Decision: Restreamer was tried first and was not adopted as the base.
Why:
- Its SRT server is gosrt, not libsrt. Restreamer's Core uses datarhei's own Go
implementation (gosrt, v0.6.0 in its
go.mod). On a flaky network we saw heavy pixelation in streams passing through it that did not appear through libsrt under the same conditions. This was an observation in a trial; it was not measured and no recording was kept. The MediaMTX entry above is the measured counterpart. - The interface did not suit many outputs. Adding an output took many clicks, the output list grew long, and each output's bitrate and health were not shown beside it, so an output with a problem or one that had restarted was hard to find. A judgement from a trial, not a benchmark.
- Upkeep (checked October 2026): the UI repository (
restreamer-ui) has had one commit since January 2025 and its last release is v1.13.0 (June 2024). Core is more active, with 19 commits in the same period.
Revisit when: its SRT server moves to libsrt, or a controlled test (packet loss and delay on the same stream through both) shows gosrt matching libsrt, and its overview shows each output's bitrate, health and restarts at 50 inputs and 500 outputs.
Don't build our own media server
Decision: no in-house RTMP/SRT server, and no adoption of new projects as the core server until they have production history.
Why: a small server is feasible in line count, but the cost is in encoder compatibility (RTMP handshake and command variants, chunking, extended timestamps, enhanced RTMP) and behavior on bad networks, which only show up in real use. A new server carries every input at once, so its bugs reach every stream.
Growing goryu into that server was considered (October 2026) to drop SRS,
have one fewer process and remove the loopback SRT hop on bonded inputs. It was
rejected:
- It moves code in-house rather than removing it. Goryu would grow from about 2,000 to an estimated 9,000 to 12,000 lines of C: SRT fan-out, an RTMP server, publish authorization, kick and stream stats. The control plane would barely shrink, because it still needs the same stream registry, stats, hooks and kick from goryu instead of SRS.
- SRS's code can't be lifted into goryu. The RTMP stack, AMF0, handshake, FLV and SRT connection code in SRS 8.0 is about 13,000 lines of C++ built on SRS's own classes and its state-threads coroutines. Goryu is C with a thread per session, so reusing it means a rewrite or a fork of SRS.
- The hop it removes isn't where bonded inputs fail. goryu to SRS is loopback; bonded inputs fail on the public legs. The hop costs about 200 ms (see Outputs pull from SRS, not from the relay), which doesn't matter for the platform outputs Bunryu serves.
Tradeoffs: every output is an FFmpeg process, so a copy output costs about 65 to 90 MB of RAM, where a MediaMTX forwarding hub used about 10x less (and about 1.5x more CPU; see One FFmpeg process per output). That is acceptable at the tested 500 outputs. In return the control plane stays small (about 11,000 lines of TypeScript) and FFmpeg and libsrt handle the damaged-input cases.
SRT ingest
A separate relay accepts bonded SRT, because neither FFmpeg nor SRS can
Decision: bonded SRT (several network links carrying one stream, as cellular
bonding units and AJA Bridge Live send it) goes to goryu, its own service on
10081. It listens with SRTO_GROUPCONNECT=1, accepts each bonded session, reads
its streamid and publishes a normal SRT stream to SRS with the same streamid.
It connects to SRS only after an encoder has connected, so SRS's idle-publisher
timeout is not triggered by an empty publisher at boot.
Why a relay at all:
- FFmpeg's SRT handler does not set
SRTO_GROUPCONNECT=1on its listener socket, so bonded connection attempts are rejected at the handshake. - SRS accepts normal SRT publishers but not bonded groups.
Revisit when: SRS accepts SRT groups natively (filed upstream as ossrs/srs#4771), which would make the relay unnecessary.
The dashboard offers SRT through the relay only; SRS's own SRT port stays open
Decision (November 2026): the Publish card has two modes, RTMP and SRT, and
SRT is the relay's port (10081) with a single-link and a bonded URL. The direct
SRT port of SRS (10080) is no longer offered in the dashboard. It is still open
and accepts publishers (an encoder already pointed at it keeps working, and its input
card says it has no link statistics and which mode to use for them); nothing in SRS's
or the control plane's configuration changed. Before this, the card offered three modes
and direct SRT was the default.
The relay's listener accepts a plain single-link SRT caller as well as a bonded
group, and the dashboard shows such an input as a single link with the encoder's address
(input.peer in the relay's /status), without the bonded-leg redundancy warnings.
Why the relay is the one offered: only through it does an SRT input have loss, retransmit and drop statistics, per-leg health and the link alerts (SRS exposes none for an SRT publisher; see the next decision), and offering both left operators choosing between a stream they can watch and one they cannot.
What choosing the relay costs, accepted:
- SRS's SRT is also libsrt, so a bad network is handled by the same retransmission code either way.
- Through the relay, SRS only sees
127.0.0.1. That hides the encoder's IP from the publish hook, the dashboard's SRS-side views and rejected-publish tracking, and turns SRS's per-client SRT stats into stats of the loopback hop. The relay's own status carries the encoder's address, which is what the dashboard shows. - It adds ~200 ms of latency and a second process every SRT input depends on; a relay restart drops all SRT inputs instead of only the bonded ones.
Revisit when: the relay's extra hop or its being a single point of failure for every SRT input causes an incident, or SRS exposes SRT link statistics (ossrs/srs#4769), which would make the direct port as visible as the relay.
Link stats for a direct SRT input are not read from SRS's log
Decision: not implemented. A direct SRT input (port 10080) has no loss, retransmit
or drop stats or alerts, and its card says to use the SRT mode of the Publish card for them. The
only source in SRS 6.0 is its log, which would need srs_log_level trace, and that
is too risky for the journal.
What was tried: SRS logs <- SRT_CPB Transport Stats # pktRecv, pktRcvLoss, pktRcvRetrans, pktRcvDrop for each SRT publisher. A prototype followed
journalctl -u srs.service -f -g ..., matched the line's [cid] to publish.cid
(also the hook's client_id; verified on SRS 6.0-r2) and fed the input card and the
relay's srt-packet-loss, srt-retransmissions and srt-packets-dropped alerts. It
worked end to end, including a reader that could not affect a stream (bounded buffers,
a malformed line only counted, a dead journalctl restarted with backoff).
Why it was dropped:
- Needs
trace. Atsrs_log_level warn, the setting since 2026-06-14, there are no such lines (0 in 60 s with an SRT input connected). The setting came with the log rotation commit and records no reason; log volume is the likely one. - Steady state is acceptable (measured on the test stack with one input and four outputs, the rest from SRS's source). About 4 lines/s (~40-60 MB/day) at idle, mostly SRS logging each of the app's own API polls (about 5 lines per request). SRS's periodic lines are limited to about one per stage per 10 s however many clients share the stage, so 50 inputs and 500 outputs should not change it. That was not run at that scale.
- Failure storms are the problem. Measured per rejected publish on the test
stack (10 attempts each):
warnalready logs 9 lines (1.4 KB) for RTMP and 5.7 (1.2 KB) for SRT;tracelogs 30 (4.3 KB) and 19 (2.8 KB), about 3 times as much. The app already throttles rejected publishers that retry every 10-40 ms (seen in production; that rate is from a code comment, not measured here), i.e. 25-100 attempts/s. Either mode can then reach journald's default rate limit (about 333 lines/s per service, which the installer does not change), after which it drops lines, warnings and errors included, and can fill the 1 GB journal in about 6 hours and push out the history of an earlier incident.warnreaches that limit at about 37 attempts/s,traceat about 11, and below ittracefills the journal about 3 times faster. - No safe mitigation verified. A journald
LogFilterPatternsrule could drop theINFOlines and keep warnings, errors and the stats lines, but it needs systemd 253 or newer (Debian 12 has 252), and a test with a user unit did not filter anything; a system unit could not be tested without root. Docker would also needwarnpinned: it has no journal anddocker logsis not rotated by default. - Little gained. Counters only (no RTT, bandwidth or latency), one sample per input about every 10 s times the number of SRT inputs (50 inputs: ~8 min), and a stalled connection logs nothing.
Revisit when: SRS 8 with per-client SRT stats in its API (ossrs/srs#4769, PR #4770) is deployed: read the API, which needs no log level. Or when a journald filter is verified on the production OS, if a stats line is wanted sooner. Meanwhile an operator who needs link stats for an input sends it through the relay port.
A lost bonded leg is found by counting legs, because the relay drops it instead of reporting broken
Decision: the health poll remembers the most legs a bonded input has had since it
connected (expectedLegs). Fewer legs than that is a down leg: a bonded-leg-down
alert, a warning on the input, and "N of M bonded legs down" in the dashboard. A leg
count only raises that figure once it has held for 15 s, and the figure resets when the
input goes away or the group has no legs left.
Why the hold and the reset: on 2026-11-18, restarting a two-leg encoder within one poll left the relay listing the old connection's leg beside the two new ones (three legs, two from one encoder address) for one poll. The figure became 3 and the alert "1 of 3 bonded legs is down" stayed, through a later full disconnect and reconnect, because the relay still called the input active and nothing reset it. A stale leg lasted about one 5 s poll; a real leg that stays is counted after three. A leg that dies within 15 s of joining raises no alert (the pipeline log still records it joining and leaving). Revisit when the relay's status says which connection a leg belongs to.
Why: the relay's /status documented a broken leg state but never sent it. It
skips broken group members, and with that filter removed a pulled LAN cable still
never showed broken: libsrt dropped the leg from the group within the relay's
one-second sample (2026-10-21, bonded stream over two legs, polled every 0.25 s). The
dashboard's broken-leg checks therefore never fired, and only a group down to one leg
raised a warning, so a three-leg group that lost one showed nothing.
Why a count and not the leg's address: cellular legs change IP often, so a leg that comes back on a new address would stay "lost" if tracked by address.
The history does name addresses. The alert counts legs, but the pipeline log and
the diagnostics record which link changed, because "which one" is what an operator
needs after the fact: Bonded legs went from 2 to 1: lost 198.51.100.7:49152 (now: ...)
in the pipeline log, and a bonded-legs-changed diagnostics event with the legs
before and after. A leg that returns from a new port is logged as one lost and one
joined; that is accurate, and it does not touch the alert. The pipeline log keeps only
100 entries, so a link that flaps would push the online/offline history out of it: it
gets 4 lines a minute and one "N more changes not shown" line afterwards, while every
change still goes to the diagnostics (one per 5 s poll at most). A bonded input that
disconnects resets the remembered legs, so reconnecting is "connected with N legs", not
a run of lost legs. The relay logs the same changes itself with one-second timing
(Bonded leg joined|left in its journal); this view is the 5 s sample of it.
A leg's health changes are logged too, because the alert is gone once it clears.
The quality alerts (bonded-leg-quality, bonded-leg-no-flow) last as long as the
condition; afterwards only the diagnostics file had them (as an episode per alert code,
so a second leg degrading during the first's episode started nothing) and the 30-minute
SRT chart (in memory, coloured by health). A warning at 3 am therefore left nothing in
the dashboard's Logs or Events. Each leg's health transition is now one line in the
pipeline log (leg_degraded, leg_failed, leg_recovered, shown as warning, error
and ok) and one bonded-leg-health diagnostics event naming the leg and the reason.
A worsening is logged at once; an improvement only after the leg has held it for 30 s,
so a leg that swings around the 1% loss threshold is one episode (a recovery line per
swing would be noise). The lines have their own budget of 4 a minute per pipeline with
a "N more not shown" line after it, separate from the join/leave lines but of the same
size; every change still reaches the diagnostics. Connecting (pending) and standby
(idle) legs are not logged: they are a state of the connection, which the join/leave
lines and bonded-leg-transition already record, and logging them added two lines to
every join. A leg that leaves while degraded gets no recovery line, since its leaving is
logged. Plain SRT inputs are covered the same way (they are one link). The thresholds
are unchanged; this only records them.
Plain inputs log their address too. Each new publisher writes one pipeline-log line
(Publisher: rtmp from 198.51.100.4) and a publisher-source diagnostics event, so the
history says who connected, not only that someone did. SRS reports the address for RTMP
and for SRT sent to port 10080, but an SRT input through Goryu reaches SRS over loopback
(SRS sees 127.0.0.1), so its address is taken from the relay's peer
(srt via relay from 203.0.113.9:40123). The relay status can lag SRS by a poll or two,
so the line waits up to 15 s for the peer and then logs the loopback address (an encoder
on the same host). It is one line per publisher, the same rate as the online/offline
lines, so it needs no throttle of its own.
An idle leg is not a fault while another leg runs. In a main/backup group the relay
reports the standby leg as idle (carrying nothing) and the main leg as running; when
the main leg fails the standby becomes running (checked 2026-10-22 against the relay with
a 4 Mbps stream: main 4.4 Mbps, standby 0.000 Mbps, and no gap when the main leg was
closed). The leg health used to mark every idle leg as a warning, which turned a healthy
backup group's pipeline status to warn permanently. An idle leg is now a warning only when
no other leg is running, and pending still is one.
Cost, and when to revisit: an encoder deliberately run with fewer legs keeps the warning until the input reconnects. Revisit if the relay starts reporting lost legs itself.
SRT loss, retransmit and drop figures cover the last 10 minutes, not the session
Decision: the SRT Relay card and the Overview table show loss / retransmit / drop
as growth over the last 10 minutes (recent in /api/health, computed from the 5 s
poll's cumulative counters). The totals since connect stay in the
details dialog. A bonded group fills in only its Drop (L and R show a dash), marked when above zero; per-leg
drops are not marked.
Why: the relay's counters only grow, so on a long event they say nothing about the link now. The bonded stream on the production VM (2026-10-25, two legs, about 9 Mbit/s, 10.4 h of per-minute snapshots) showed 10.1 k lost and 3 k dropped packets on one leg, which reads as a bad link, while most minutes had no loss at all and the rest came in bursts.
Why 10 minutes and not 1: over those 623 minutes, 39 % had loss on a leg and 8 % had a leg drop, in bursts. A 1-minute figure is zero most of the time and a burst is gone from it a minute later, so an operator glancing at the card misses it; 10 minutes keeps a burst on screen long enough to see, and matches the dialog's 10-minute history step. The alerts keep their own 1-minute window, which is for reacting, not for looking back.
Why the group's Drop is the one marked: a leg's drop is a packet that leg did not deliver in time, and the other leg usually did. Leg drops happened in 52 of the 623 minutes but the group's only in 2 (286 packets in total), and only those reached the stream.
Revisit when: operators ask for another window (the window is SRT_RECENT_WINDOW_MS
in src/utils/srtRecent.ts), or the dialog's cumulative graphs are changed to rates.
Relay stream errors go to the pipeline log, merged while they repeat
Decision: the health poll writes the error Goryu holds for a stream (lastError)
to the pipeline log as a relay_error line and to the diagnostics (relay-stream-error).
A repeat of the same error within 10 minutes of its last occurrence updates that one
line to "(seen N times over …)" and sends diagnostics at most once a minute. An error
already held when the dashboard starts is not logged again unless it is under 30 s old.
Why: Goryu keeps one error per stream and zeroes it when the session ends
(remove_stream_state) or a new one starts, so after an incident nothing shows what
the relay had said. Its journal has it, but not next to the pipeline's other events.
Why merge: read in Goryu (session.c, backoff.c): a stream that cannot publish
downstream retries on a 1, 2, 4, 8, 16 s backoff, then every 16 s without end, and sets
the error each time. A rejected stream key is the realistic case, and it would add
about 225 lines an hour to a log that keeps 100. The text also differs between
occurrences ("retrying in 4000 ms", the input peer's port, which changes on every
reconnect), so the merge compares the text without the delay and with ports masked.
The stream id (it holds the key) is dropped from the logged line.
Not done: a separate persisted History list or API route for relay errors. They are rare and one-off in practice, and the pipeline log already is the history; the relay card's History button shows the one error the relay holds now.
Revisit when: the log shows a relay error merged many times a day, which would point at a cause worth an alert of its own.
Outputs pull from SRS, not from the relay
Decision: the relay stays a byte-level pipe (one input, one downstream SRT connection) and doesn't serve readers.
Why:
- Serving pulls would make the relay a media server. It would need fan-out with isolation for slow readers, play authorization, a stream registry for health checks, and the ability to kick publishers.
- RTMP inputs would still be on SRS, so the control plane would track streams in two places.
Cost of the SRS hop: about 200 ms per SRT hop, and CPU in SRS. One 3 Mbps stream with 50 copy readers measured 17% CPU and 68 MB for SRT readers, against 5% and 30 MB for RTMP readers.
Revisit when: SRT fan-out in SRS becomes a measured bottleneck. The cheaper fix is then one FFmpeg remux per SRT input published back into SRS as RTMP, not a relay fan-out.
Keep goryu in its own repository
Decision: the relay stays a separate repository with its own releases, and Bunryu pins a release binary like it pins SRS and FFmpeg.
Why:
- It's a different toolchain (C, libsrt, a Docker build) from Bunryu's Node.js and TypeScript.
- It's useful on its own as a standalone SRT relay.
- It changes much less often than Bunryu.
- Each release bundles its own libsrt (v3.0.6 and later have 1.5.6, which fixes CVE-2026-55868/55869), so a libsrt security fix needs a relay release and a pin bump here.
The coupling is the relay's config file and its /status JSON. Treat /status
as a contract: add fields, and bump the relay's major version for anything
else.
Raise the kernel UDP buffer ceiling, but don't alert on it
Decision: the installer sets net.core.rmem_max and wmem_max to 16 MB. There is
no health alert or startup check for the value.
Why:
- libsrt requests a 12 MB UDP buffer per socket. Prod had the Linux default
ceiling of 212992, so SRS (10080) and goryu (10081) ingest sockets ran with
rb425984(the kernel doubles the capped value), about 70 ms of a 50 Mbps feed. A stall longer than that, such as an encode starving the ingest thread, drops packets and costs SRT retransmits. - Raising a ceiling is cheap. It changes nothing for sockets that don't ask for
more, and memory is only used while a queue is full (bounded by
udp_mem).
Evidence: no drops were observed, so this is headroom, not an incident fix.
A 2 vCPU / 2 GB prod VM (outputs stopped, host about 85% idle) receiving a
bonded SRT feed at 6.6k then 11k packets/s over 33 minutes showed
UdpRcvbufErrors 0 and every ingest socket's d 0. The default ceiling was
enough at that load, but nothing ran under CPU contention. With the 16 MB ceiling
the same sockets got rb24576000 (12 MB doubled) after a restart and again
after a reboot, so the sysctl file is applied at boot.
Why no alert: an alert needs a recorded incident to justify it. Without drops there is nothing to calibrate it against.
Revisit when: UdpRcvbufErrors rises or an ingest socket shows d above 0
(the per-minute health-snapshot records both as host.udp, with host.cpuPressure
to tell whether the host was starved at the time; then add a health check for the
ceiling and the counter), or inputs carry
4K SRT at 50 Mbps or more with encodes running on the same host.
Outputs and preview
One FFmpeg process per output
Decision: each output runs in its own FFmpeg process with its own watchdogs.
Why:
- A stalled destination, a corrupt input frame or a memory blow-up affects only that output, and it can be restarted on its own (see Reliability).
- FFmpeg also does every transcode and audio-track selection.
Cost: about 35 MB of RAM and, on production, about 4% of a vCPU per 8 Mbps copy-mode output (0.4% per Mbps sent), and about 1.2–2 vCPUs per custom video encoding of a 1080p50 input, far more for 4K (once per distinct encode on a pipeline, since outputs with the same encode share one: see Outputs with the same encode share one FFmpeg). That's acceptable within the supported envelope (Introduction).
Not planned: a MediaMTX forwarding hub for copy outputs. It used about 10x less RAM but about 1.5x more CPU than FFmpeg for RTMP→RTMP copy outputs. It would mean a second media server in the output path, while FFmpeg would still be needed for every transcode and SRT destination. Outputs stay on FFmpeg.
Outputs with the same encode share one FFmpeg (shared encodes)
Decision: outputs on the same pipeline that need the same encode, meaning the
same video preset and the same single audio track, share one upstream FFmpeg, the
rendition (the dashboard calls it a "shared encode"). It encodes once and
publishes into SRS as an internal RTMP stream on loopback
(rtmp://127.0.0.1:<port>/internal/r<pipelineId>_<video>_a<audio>); the sharing
outputs pull that stream in copy mode.
Why:
- Before, every output with a track selection or a video preset ran its own encode: ten RTMP outputs on track 1 of an SRT input meant ten SRT pulls and ten identical AAC encodes, and ten 720p outputs meant ten x264 encodes (about a core each). Operators worked around it by looping the SRT pipeline into a second pipeline.
- RTMP readers are cheap for SRS: 50 RTMP readers measured 5% CPU against 17% for 50 SRT readers (SRS 6.0-r2).
How it's built:
- A rendition is an output row of the same pipeline, recognised by its URL
(
rtmp://127.0.0.1:<port>/internal/r<id>_<video>_a<audio>). It reuses the output service's supervision, watchdogs, retry back-off, History, stats and health unchanged. A reconciler (one tick per second) creates, removes, starts and idle-stops the rows. - No schema change and no config option, so the production database is not wiped. A hidden pipeline or a new table would have needed new supervision, health and history paths for the same behaviour.
- Which outputs share: not plain copy, not multi-track (
0,1, since RTMP/FLV carries one audio track). And only when at least two outputs of the pipeline are configured with the same recipe (desired state does not matter, so the rule is a pure function of the saved configuration). A first version shared even a lone output, for one code path; a lone output then paid an extra process (about 28 MB, 0.4% CPU), about 5 s of extra start-up (0.02 s direct, measured), an extra SRS hop, and the input-outage restart cycle (see Known issues) for nothing. The rule is evaluated when an output starts and by the reconciler; a running output never switches mid-run, so a changed configuration settles the next time an output starts. Two consequences are accepted because outputs are normally all configured before an event: adding a second output while the first runs direct starts the shared encode at once (two encodes, and an idle one if the second is never started); and removing the second leaves the encode in place while any output still reads it, so a live output is never interrupted by an edit to another. - The internal app is reserved: users cannot create, edit, start, stop or delete renditions or point an output at the app; SRS's publish hook accepts it only over RTMP from loopback for a running rendition row.
- Readiness is local (process running and data written), not the 5 s health poll. When a rendition exits on its own its readers are restarted and wait for it; each gets a History record naming the cause. After 15 s with no running reader it stops, so a quick stop/start does not restart the shared encode.
Evidence (local isolated stack, 2026-10-17, SRS 6.0-r2, FFmpeg 7.1.4, one 1280×720 SRT input with two audio tracks, two outputs on track 1, CPU summed over 60 s):
| Processes | CPU | RSS | |
|---|---|---|---|
| Before: each output pulls SRT and encodes AAC | 2 | 29.5% of a core (14.6% + 14.8%) | 74 MB |
| Shared: one encode (12.3%) and two copy readers (0.4% each) | 3 | 13.1% of a core | 93 MB |
CPU more than halves with two outputs and the saving grows with each further output (a reader costs 0.4%); memory is slightly higher for few outputs, from the extra process. In the same stack the end-to-end behaviour matched the design: killing an encode restarted its readers after one back-off step with one record each (about 6 s outage); a restart from the dashboard did not count a failure; the encode idle-stopped at 15.0 s; a crashed app's orphaned encodes were swept at startup and everything was running 7 s later; and stop-all then start-all restarted each encode exactly once. An input outage over 5 s costs one failure cycle (SRS drops the idle internal publish; see Known issues).
Tradeoffs:
- A failed rendition affects every output that shares it. The blast radius is one recipe on one pipeline.
- Starting a shared output takes a few seconds longer (the encode must be writing first).
- Output ids have gaps, since a rendition takes a number in the pipeline's sequence.
Not done: sharing across pipelines; shared multi-track encodes (they would need an SRT/MPEG-TS internal stream); GOP or bitrate tuning (a rendition uses the same encoder settings as before and joiners start at SRS's cached GOP).
Revisit when: a shared encode's blast radius becomes a problem in practice (then split by destination group), or multi-track outputs need sharing.
Preview copies the video; only audio is encoded
Decision: the dashboard preview is an HLS stream made by FFmpeg that copies the input's video unchanged and re-encodes only the audio to AAC (one rendition per audio track). Only Chrome is supported. Previews are stopped automatically when no viewer remains.
Why:
- CPU: the previous 480p video transcode took about 80% of a core per open preview for a 1080p input, which made previews unusable on a 2 vCPU server. With video copy the same preview takes about 9% (3% for a single-track input).
- Audio is still encoded because it's cheap and keeps the timestamp smoothing for SRT inputs, MP2/AC-3 inputs playable in the browser, and audio track switching.
- Same pipeline for RTMP and SRT inputs, played by the existing hls.js player.
- No SRS feature needed: SRS's native HLS was used briefly but depended on
srt_to_rtmpfor SRT inputs.
Costs:
- Bandwidth: each viewer receives the source bitrate (e.g. 6 Mbps for a 1080p input instead of ~1 Mbps).
- Keyframe interval: HLS segments can only start on a keyframe, so an input with a long keyframe interval starts slower and runs further behind live.
- HEVC inputs preview only where Chrome can decode HEVC; there is no transcode fallback.
Give up on a blocked RTMP/RTMPS destination with an output -rw_timeout
Decision (October 2026): every RTMP and RTMPS destination gets -rw_timeout 10000000 (10 s) as an output option, placed directly before the destination URL
(buildFfmpegArgs). SRT destinations do not.
Why: a destination that accepts the TCP connection and then goes quiet leaves the socket ESTABLISHED. The socket watchdog treats that as healthy, and FFmpeg waits forever, so only the progress watchdog (45 s without progress, after a 90 s warmup) ends it. Measured with the pinned FFmpeg n7.1.4 on loopback, 100-110 s cap per run:
| Case | Without | With 10 s |
|---|---|---|
| Connect never completes (accept queue full) | 5.2 s | 5.2 s |
| Accepts, never answers (RTMP and RTMPS, also a completed TLS handshake) | never | 10.2-10.3 s |
Frozen mid-stream, RTMP (SRS SIGSTOP; ss showed ESTAB with 2.7 MB queued) |
never | 30.8 s |
| Frozen mid-stream, RTMPS (TLS proxy in front of the frozen SRS) | never | 10.6 s |
| Healthy destination, 70 s at real pace, RTMP and RTMPS | publishing | publishing (also at 3 s) |
- How each case was produced (all on loopback, FFmpeg copying a local file with
Bunryu's real arguments, runs in parallel):
- connect never completes: a listener with a full accept queue, so the kernel drops further SYNs;
- accepts, never answers: a listener that accepts and sends nothing; for RTMPS also a TLS server (self-signed certificate) that completes the handshake and then says nothing;
- frozen mid-stream: SRS as the destination, stopped with
SIGSTOP, so the kernel keeps accepting until the socket buffers are full and then advertises a zero window. For RTMPS a TLS proxy sat in front of the frozen SRS. FFmpeg ran unthrottled so the buffers fill at once and the block starts right away; - healthy: SRS behind the same proxy, FFmpeg paced at real time (
-re).
- Scaling: for RTMP mid-stream the give-up time is three times the value (5 s gave 15.6 s, 10 s gave 30.9 s twice, 20 s gave 60.9 s).
- 10 s is a compromise: 30 s of fully blocked writes is under the progress watchdog's 45 s, so it adds no new kind of restart, only an earlier one. A smaller value would restart outputs sooner on a platform that merely pauses reading.
- The connect case needs nothing: FFmpeg's own connect timeout already ends it after 5 s, long before the 45 s socket watchdog.
- Regression test:
test/outputTimeout.test.tsruns real FFmpeg on the arguments Bunryu builds against a destination that never answers (RTMP and RTMPS, no certificate needed), plus a control without the option; it passed on FFmpeg 7.1.4 and the development machine's 8.0.1.
Not adopted:
-timeout. It is not a TCP timeout for RTMP: it implies listen mode and FFmpeg tries to bind the destination port ("Address already in use").- SRT destinations. The option is a different setting for
srt://; they need no timeout, see below. - A shorter progress-watchdog stall. It would also restart outputs fed by an idle input, which the watchdog deliberately ignores.
Not tested: a real platform ingest, and RTMPS certificate verification (FFmpeg's default does not verify).
Revisit when: outputs restart with "Connection timed out" against a healthy platform (raise the value), or FFmpeg is upgraded (the regression test checks the mechanism).
An output that never connected is reported as waiting for input, and restarts record the input source
Decision (October 2026): when the socket watchdog finds no destination socket on
an output that has written nothing, it reports "No input data" instead of "Destination
socket unhealthy". Before the socket or progress watchdog restarts an output, it reads
the output's stream from SRS (at most 2 s, /api/v1/streams) and, for a shared
output, the shared encode's state, and puts both in the History record and the
ffmpeg-restart diagnostic event. The input's -rw_timeout stays at 10 minutes.
Incident (2026-10-25, pipeline 12): a shared encode ran and wrote at 2.4-2.5 Mbps
for 25 minutes (its health snapshots) while the YouTube output reading it from SRS
failed 19 times in a row; a second key on the same pipeline failed the same way. Every
attempt ended with an empty stderr but Error opening input file rtmp://127.0.0.1:21935/internal/r12_copy_a0, and its only socket was the one to SRS:
it never connected to YouTube. The watchdog blamed the destination ("RTMP socket
missing") because that is the only thing it checked. Three other pipelines started in
the same 15 s with the same settings worked. Once the outputs were stopped and the
shared encode idle-stopped, the next start worked. SRS ran at log level warn and
logged nothing about the stream, so the state inside SRS was not recorded.
Why these changes: the misleading wording sent the investigation to YouTube; and the one fact that would have told an input fault from a destination fault (what SRS held for the stream at that moment) was not captured.
Where the evidence is recorded: in each output's own History and in the diagnostics, per output. Recording it once per source stream (in the pipeline History, with the other outputs pointing at it) would stop the repeats and the SRS calls, and is the same fault for outputs that read the input directly; it was left out for now because the 3 s shared request already bounds the load and per-output records are enough while this has been seen once. It would relax the convention that outputs do not write to the pipeline History. Revisit if many outputs failing together make the repeats a problem.
Why not a shorter input -rw_timeout: it also bounds every read while running, so
a brief gap in the input would restart outputs and eat their 5-attempt budget. The
10 minutes exist for publisher-less pulls (see the entry on blocked destinations
above); the watchdogs end a stuck open after about 45-50 s anyway.
Later (2026-11-30): the fault was reproduced and its cause found in SRS 6.0; it is not specific to shared encodes, and a plain disconnect of the publisher cures it, with no gap and no reader restarted. The automatic recovery is the next entry.
A stream SRS receives but does not serve is found from SRS's byte counts, and its publisher reconnected
Decision (November 2026): every 5 s poll checks each live input and each running
shared encode's internal stream against SRS's clients list (utils/streamServing.ts). A
reader that joined during the current publisher session, is at least 10 s old and has been
sent under 64 KB is starved. Two different starved readers, none fed, and a publisher
sending at least 100 kbps make the stream not served: an input gets a stream-not-served
error alert, and the publisher (RTMP or SRT) is disconnected through SRS's API so that it
publishes again. At most one reconnect per stream per 10 minutes, at most 3 in a row for sessions
stuck again. SRS 6.0 is not patched.
The fault: SRS 6.0 creates a source with stream_die_at_ = 0, so its 3 s cleanup tick
can remove a new source before the publisher reaches on_publish; the publisher keeps it,
and every player gets an empty one. Fixed upstream in 7.0.127 (ossrs/srs#4449), never in
6.0. On the production VM about one of ten loopback inputs was stuck after each of 4 full
restarts; on a private SRS the stuck share followed the hook delay (1 of 20 streams at
0 ms, 20 of 20 at 4 s) and was 0 of 80 with the fix. Only a publish that finds no source
is at risk (SRS keeps one about 132 s after its publisher and players leave), so it also
happens at the start of an event, after an encoder's longer break and when a shared encode
starts, not only after a restart
(fail report).
Why SRS's byte counts and not ffprobe: a probe timeout says only that ffprobe gave up,
which a stream with data it cannot use also causes. SRS's send_bytes for each reader says
whether anything was sent: 4,438 bytes (the handshake) for a stuck reader, megabytes for a
healthy one. SRS refreshes it every 3 s for RTMP and SRT players alike, hence the 10 s age.
It is cumulative per connection and a player outlives a publisher session, so a reader older
than the publisher is ignored: its bytes may be the last session's. Two readers, not one, so
one odd client cannot trigger a reconnect. Every reader counts (outputs, the input probe, a
shared encode, a preview), so no probe was added: an input with no outputs is judged from
its own probe in about a minute, a shared encode from its outputs in seconds.
Why reconnect the publisher: it is what cured every occurrence, it needs no output restart (readers waiting on the stream were served by the next session: 4,438 bytes to 11.6 MB in 20 s), and a shared encode's FFmpeg then exits and the existing path restarts it with its outputs. The output start path and readiness gate are unchanged: a gate on the shared encode was considered and left out, as it adds a state to the start path.
Why RTMP and SRT alike: the first version reconnected RTMP publishers only, because the
fault had been seen only there. On the production VM, with the on_publish hook slowed to
2.5 s (tc netem on loopback port 8082), the SRT input of a pipeline (the relay's publish
into SRS, with a bonded encoder behind it) was stuck after 3 of 3 full restarts: SRS listed
it as publishing at 12 Mbps and sent its ten readers nothing. Detection fired about 25 s
after the publisher went live. The outputs' stall watchdog then restarted every output twice
and the stream stayed stuck for the whole 200 s, with every Track input fed by it down.
Disconnecting that publisher through SRS's API cured it: the relay published again within
about 6 s and the new session was served. With the shipped reconnect, and the delay removed
as soon as the kick was logged, 3 of 3 full restarts recovered the same way: detection 25 s
after the publisher went live, the relay publishing again 6 s later. The outputs that had
been waiting on the stuck SRT stream did not resume by themselves (unlike RTMP readers), so
the Track inputs came back when their stall watchdog restarted them, 95 s after they
started (about 75 s after the kick). With the delay left on, the new session was stuck
again (each publish loses the race about 2.5 s in 3 s) and the 10-minute interval applied;
a hook that stays slow is not the case this covers. Without any delay, 8 further full
restarts (hook round trip 1-2 ms, 15 ms at most) stuck nothing, so the SRT case is the same
race and only the window differs. No separate rule for SRT.
Why not patch SRS: a fork release to carry a three-line fix, against an upgrade that brings it. The check is generic (any SRS fault where a publisher and its players end up apart looks the same), reads data the poll already fetches, and stays silent once SRS is fixed.
Revisit when: SRS is upgraded to 7.0.127 or later (keep it if it never fires and costs nothing, remove it if it gets in the way); or it reconnects a stream that was being served (raise the age or the byte threshold).
A repeated crash is one History record, and recovery is a field on it
Decision (October 2026): an output's History keeps at most 10 records. A crash
with the same signature as the previous crash record (first and last line, numbers and
addresses blanked, nothing but warnings in between) increments count and lastTs
on that record instead of adding one. When an output with a current crash has run for
60 s and is writing data, the crash gets recoveredTs, which ends its time as the
current error. No separate "recovered" record is written.
Why: a failure that repeats gets one slot instead of up to ten: on 2026-10-25 the first output failed 19 times in a row the same way, which with one record per attempt leaves only the last ten copies and none of the records before them. And an output that restarted by itself stayed red until someone stopped and started it, because nothing but a stop or a start supersedes a crash. A separate recovery record would have taken a slot per episode for no information the crash does not carry.
Choices: the first crash keeps its message (nearest the onset, the most useful),
and later ones are in the diagnostics events; lastTs is what the card shows as the
time of the error. 60 s is the limit that already ends a failed-attempt streak, so an
output that crashes again seconds after restarting does not flash normal in between.
The retry count starts over at recovery. A crash after a recovery is a new record even
with the same text, so a flapping output is still visible as separate episodes.
Revisit when: distinct failures are being merged (widen the signature) or a flapping output fills the History with episodes.
Don't add an ss -ti ack-progress check; -rw_timeout is the knob
Decision (October 2026): the socket watchdog keeps reading only the socket state
from ss -tanp. It does not read ss -ti to notice a connection that stays
ESTABLISHED but stops being acknowledged. How fast a blocked RTMP destination is
given up on is set by -rw_timeout (see the entry above).
Measured on the production VM (Ubuntu 22.04, FFmpeg n7.1.4) with a 4.2 Mbps copy
push of a looped clip to a destination SRS on a private loopback port, with the
output's -rw_timeout 10000000. The fault started at t=20 s; "ack stall" is the time
bytes_acked has not advanced while data is queued. The silent drop was one
iptables DROP rule on the destination port.
| Fault | First ack stall of 3 s | 10 s | Exit by FFmpeg |
|---|---|---|---|
| Silent drop (nothing delivered) | +3.2 s | n/a | +34.6 s |
Frozen receiver (SRS SIGSTOP, zero window) |
+9.8 s | +16.9 s | +40.1 s |
| 8% of packets dropped, still working | never | never | never |
| 30% of packets dropped, still working | +22.0 s | never (max 6.1 s) | never |
Why not:
- The gain is about 25 s on a rare failure. A rule of "10 s without ack progress"
would end a dead connection at about +10 s instead of +35 s. That is more aggressive
than the 30 s of blocked writes the
-rw_timeoutdecision accepts, so it would restart sooner on a platform that merely pauses reading. A threshold that respects that decision (about 25 s) gains 10-15 s. - The same trade-off is already one constant.
-rw_timeout 5000000gives up after about 15.6 s on mid-stream RTMP (measured above), with no new code. - It cannot see the other cases. A destination that never answers has an empty send queue, and SRT destinations are UDP.
- The signals overlap. The 30% loss run stalled acks for 6.1 s while the stream kept flowing, and the frozen receiver and a lossy path are not cleanly separable from the ack counters alone.
- Cost: multi-line
ss -tiparsing across up to 500 sockets and per-socket ack state in the highest-risk loop.
Seen in the same runs: after about 4.6 s the destination SRS closed its side
(probably its idle-publisher timeout; not checked), leaving the output's socket in CLOSE-WAIT with
1.78 MB queued, which the existing socket watchdog already acts on.
Not tested: a real platform ingest. Everything above ran on loopback, so how long YouTube or Facebook pause reading before they resume is unknown.
Revisit when: a silently dead connection costs more than the current give-up
time in a real incident, or outputs need to give up in under 15 s without the
false restarts that a shorter -rw_timeout risks.
SRT destinations need no output timeout
Decision (October 2026): SRT destinations get no equivalent of the RTMP
-rw_timeout. FFmpeg's libsrt already ends a dead one within seconds.
Measured on the production VM (Ubuntu 22.04, FFmpeg n7.1.4) with a 4.2 Mbps copy
push of a looped clip, -c copy -f mpegts srt://127.0.0.1:<port>?streamid=…, no extra
options, to a private loopback port:
| Destination | What ffmpeg did |
|---|---|
| Never answers (a bound UDP socket that replies to nothing) | exit after 4 s with "Connection … failed: Input/output error" |
SRS as the SRT listener, SIGSTOP'd mid-stream |
exit 6 s later (Error writing trailer: Input/output error) |
| SRS as the listener, every packet of the port dropped in both directions mid-stream | exit 6 s later, the same error |
| A libsrt receiver (FFmpeg) whose output pipe nobody drains, so it stops consuming the stream mid-stream | kept sending for 150 s: progress advanced, no stall, RSS flat at 35 MB, no exit |
- Why 6 s: libsrt's peer idle timeout (5 s by default) closes a connection that
hears nothing from its peer, and a send on it fails. That is far tighter than the
30 s that RTMP needed
-rw_timeoutfor, so the retry loop takes over on its own. - A receiver that stays connected and stops reading is not a hang. The sender keeps sending (probably because live mode drops at the receiver instead of blocking the sender; not checked), so the output looks healthy and nothing restarts it. No sender-side signal tells that case apart from a working destination, as with an RTMP destination that acknowledges data it never uses.
- A destination URL that sets
timeout=(or another libsrt timeout) changes these numbers; the runs used no options.
Regression test: node scripts/test-faults.mjs srt reproduces the first, second and
last rows on the local stack (the silent path needs iptables and root, so it was only
measured on the VM).
Not tested: a real SRT platform, a one-way loss (packets dropped in one direction only), and a libsrt version other than the one built into the pinned FFmpeg.
Revisit when: SRT outputs hang or restart late against a real destination.
Translation outputs were removed
Decision (October 2026): the beta translation output (mixing a translator
pipeline's audio over the source, with speech detection, ducking, delay and
restore timing) is removed: the code, the translation_config column (schema
version 3), the translator_meter_stale_ms setting and the zeromq npm
dependency, together with the amix and azmq filters the FFmpeg build check
asked for.
Why:
- It was a beta that no production event used, and it was not clear that one would.
- It was a second path through the system. Its own module (868 lines) ran and
supervised a separate FFmpeg per output, copying the output service's kill
escalation, memory watchdog, stall watchdog and exit handling.
outputs.tshad six places that skipped translation outputs, and its interface carried three methods only the mixer called. The two supervisors had already drifted. - Reading the mixer before removal turned up two faults the regular output path does not have. A mixer that crashed was started again by its 1 s reconcile tick with no back-off, so a destination that refused connections would cost one FFmpeg spawn per second, indefinitely (regular outputs back off from 1 s to 16 s). And the bulk create route accepted translation audio without translation settings, which saved an output that nothing would ever run and nothing reported.
- It tied one pipeline's output to another pipeline's live state, a coupling no other output has.
- Keeping it meant keeping and testing all of that for no user: about 830 lines of tests of its own plus cases inside the output, health, database and API tests.
Restoring it: the last commit that has it is 55a7c40
(git show 55a7c40:src/services/translationMixer.ts; its usage page was
docs/2-usage/3-translation.md). A restored version should supervise its FFmpeg
through the same code as regular outputs, with the same retry back-off, instead of a
second supervisor.
Moving a database: production was moved from schema version 2 to 3 on 2026-10-29
with a one-off script (back up, delete translation outputs, drop the column, stamp
version 3), then deleted. Another version 2 database is wiped by the installer, or
migrated with git show 79d20ce:scripts/migrate-db-2-to-3.mjs.
Revisit when: a real event needs interpreter audio mixed into the program.
An output that publishes into its own pipeline, directly or through other pipelines, is saved and marked, not refused
Decision (November 2026, replacing an October 2026 rule that refused to save it): an
output whose destination is this server's own live/<key>, where that key is the
pipeline's own input or the chain of such outputs leads back to it, can be created,
pasted and edited. Its card shows a yellow advice line
("Loops back into this pipeline's own input, so it cannot work"); it is not an error in the
output's History. The output form's restream dropdown does not
offer the pipeline itself or one on its stream key; a custom RTMP/SRT URL or a pasted
output is the way to get a loop. Start and Start all are not changed, moving a pipeline
to another stream key is still refused when one of its outputs would then loop, and the
startup re-check still stops a loop (below), so a loop that runs does not survive a
restart. It is decided by stream key, not pipeline id: pipelines may share a key (the
dashboard warns but allows it), and then they read the same stream, so an output of
either one publishing into that key still feeds itself.
Why saved, not refused: pasting a pipeline's outputs into another pipeline failed as a whole ("Output 2: destination loops back into this pipeline's input through pipeline "Pipeline 3""), with no way to see which output it was or to fix it afterwards: the operator had to edit the clipboard by hand. A saved output with the warning on its card can be corrected in the edit dialog.
The line is the dashboard's: it is worked out in the browser from the publish URLs
it knows (the public host and the loopback one, RTMP and SRT), like the
duplicate-destination line, so it costs the server nothing per health poll. The server
resolves any spelling of the address (localhost, a decimal IP, a name of this
machine), which needs DNS and so is not run for every output on every poll; an address
only the server recognises gets no line. Refusing to start such an output, and recording
the loop as a stopped error, were tried and dropped as more logic than the case
needs: the failure below is already contained.
Why: the destination rules allowed loopback on the server's own ports so pipelines
can restream into each other, and nothing stopped an operator pasting the pipeline's
own publish URL. Observed on the test stack (2026-10-31, SRS 6.0-r2, FFmpeg
7.1.4): a copy output pulling a live pipeline and pushing to the same key is refused
by SRS (Error opening output ... Input/output error) while the input keeps running,
so the stream is not corrupted, but the output could never work, and it would sit in
the retry loop for as long as the event runs. Marking it on the card tells the operator
before they start it.
Limits: only outputs on this server's own ingest are followed. A destination that reaches the server through a NAT-ed public address that is not on one of its interfaces, or through another machine, looks like a remote host and is not recognised.
Revisit when: a loop shows up that the check misses (for example through a relay on another host) or SRS starts letting a second publisher take over a live stream, which would turn a failing output into a feedback loop.
Sizing
Sizing guidance is a measured table, not a calculator
Decision: Sizing a server gives per-item CPU and RAM costs, a formula and example GCP machine sizes. There is no calculator in the dashboard, and no cost model for individual machine families.
Why:
- The inputs are few. CPU is dominated by the number of distinct video encodes. Copy outputs and audio re-encodes are small, so a table answers "which VM?" as well as a form would.
- A single number would imply precision the data does not have. An encode's CPU varies by about 1.5x with the content (1080p: 1.5 vCPUs on a clean test pattern, 2.5 on noisy motion), and only one machine family was measured. The table shows ranges and a headroom rule instead.
- Less to maintain. A dashboard widget is code to test, ships in every install and reaches only people who have already installed it; the audience is the person choosing a VM.
- Docs are plain Markdown, rendered by GitHub and the org site, so an interactive widget has nowhere to live in them.
Evidence: two sources, both on the production VM (GCP n2, 4 vCPU, 4 GB,
FFmpeg 7.1.4). The benchmark ran on 2026-10-18 in an idle window. A private SRS pair on loopback ports with copies of
the production binaries was fed a generated 1080p30 ~6 Mbps stream. FFmpeg ran with
the application's own arguments, each case 15 s warm-up and 45 s measured, CPU from
/proc/<pid>/stat, nice 19, aborting if production FFmpeg or a live stream
appeared. It ran as two per-origin scripts, now merged into
skills/benchmark-sizing/sizing-benchmark.py (the benchmark-sizing skill), which
is how to repeat it.
- Copy output: 0.005 vCPU on an RTMP input, 0.02 on SRT (plus 0.01 in SRS); 30 outputs: 0.16 and 0.93 vCPU.
- Audio re-encode: +0.03 (RTMP) and +0.04 (SRT).
- Encodes at 30 fps (clean / noisy):
720p1.1 / 1.7,1080p1.5 / 2.5,vertical_rotate0.6 / 0.8 vCPUs. The production feeds are 50 fps, so these understate the real use (below). - Saturation: four
720pencodes ran at 0.52x real time, three1080pat 0.48x.
Observed on production from the per-minute health snapshots (10 to 19 October 2026, read-only, before shared encodes were deployed there):
- Copy output at 7–10 Mbps on an RTMP input: 0.039 vCPU to an RTMP destination and 0.036 to RTMPS, 34 MB, against 0.005 in the benchmark. The extra is sending, not TLS: about 0.004 vCPU per Mbps sent, which with the benchmark figures reproduces the observations to within about 0.04 vCPU.
- Audio re-encode on an SRT input: 0.077 at under 4 Mbps, 0.072 at 7–10 Mbps and
0.167 on a 4K feed (about 20 Mbps); 47–61 MB. These come from
skills/benchmark-sizing/observe-prod.py. - Ingest: a 4K (19.9 Mbps) and a 1080p (9.1 Mbps) SRT feed cost SRS 0.10 and the relay 0.20 vCPU, about 0.01 vCPU per Mbps; Node 1% and 217 MB.
- A dry run on 2026-10-19 sent the 4K feed to YouTube primary and backup (copy video,
audio track re-encoded): 0.181 and 0.185 vCPU, 56 MB (129 MB at start), 19.95 Mbps
at 1.0x for 4 minutes; SRS rose 0.058 vCPU for the two readers and the relay did
not change. Two 4K encodes were run for memory on a development machine (FFmpeg 8,
synthetic 20 Mbps input):
vertical_rotate472 MB and720p608 MB. With the production figures for copy and for1080p(940 MB, below) they confirmed the 4K memory limit of twice the HD limit (3x above copy, 1.9–2.1x above the encodes), so it was left unchanged. - The encodes in their real use, on the live 1080p50 and 4K50 feeds with the
application's arguments:
720pfrom 1080p 2.05 vCPU and 270–280 MB (60 s, 1.0x),vertical_rotatefrom 1080p 1.19 vCPU and 175 MB (90 s, 1.0x).1080pfrom 4K ran at 0.53–0.58x on the 4-vCPUn2and the SRT pull then broke after about 20 s, while decoding alone kept up at 1.83 vCPU (1.1x), so a 4-vCPU host cannot do it. On the same VM resized to 8 vCPUs (2026-10-19, 24 Mbps feed) it ran at 1.0x for 90 s at 5.94 vCPU and 930–940 MB, leaving the host about 90% busy. - The 2026-10-18 event (21 outputs on average, 17 Mbps in): all processes together averaged 1.07 vCPU, peaked at 2.40, and the host used 1.15 GB of RAM on average, 1.28 GB at the peak.
This replaces the earlier "about one core per encode", "negligible" copy cost and "hundreds of outputs on modest hardware" statements, which did not match these measurements.
Costs: the numbers are for one machine family. 720p and vertical_rotate were
measured on the production feeds, 1080p from 4K only for speed and memory (it does
not keep up on 4 vCPUs), and the benchmark input was 1080p30. Copy outputs on an SRT
input and audio re-encodes on an RTMP input have no clean production observation.
They exclude previews.
Revisit when:
- FFmpeg, x264 or an encoding profile changes, since every cost above depends on them.
- Other machine families (
c3,n4) are measured. - People keep asking for an interactive tool: a spreadsheet linked from the page is the cheapest next step before a dashboard feature.
No hard cap on inputs or outputs; the stream key count is a setting
Decision: the server refuses neither a pipeline nor an output because of a
count. The 50 inputs and 500 outputs in the
introduction are the
tested envelope, as a recommendation. The number of stream keys is
stream_key_count in bunryu.json (default 100), and since each pipeline uses one
key it is the most inputs there can be.
Why:
- The machine is the limit, and the operator knows it. Whether 500 outputs fit depends on bitrate, protocol and audio re-encodes (about 4 vCPUs per 100 copy outputs at 8 Mbps, see Sizing a server). A fixed number is too high for a small VM and needlessly low for a large one.
- A cap refuses work during an event. The old output limit (500, enforced in the
database layer) answered the 501st with
409, and the bulk create refused a request of more than 500 outputs, on a server that might have had room. - The stream keys needed a number anyway. 99 keys were generated whatever the deployment; a setting lets a small server have fewer and a large one more, and it adds no API field or dashboard control.
Behavior: on startup the missing keys up to the count are generated. Lowering the count removes the keys above it that no pipeline uses; a key a pipeline already uses stays, and new pipelines only get keys within the count. A value that is not a whole number from 1 to 10,000 falls back to 100: the upper bound only stops a typo from generating a million keys at startup. A request body is still limited to 1 MB, which bounds a bulk create.
Costs: nothing stops an operator from adding more than the host can run. The protection against that is the sizing guidance and the output and host-memory watchdogs, not a refusal.
Revisit when: a deployment overloads itself with outputs added in good faith, and a warning in the dashboard (rather than a refusal) would have helped.
Dashboard
Installable as an app with a manifest only, no service worker
Decision: public/manifest.webmanifest and the icons in public/icons/ let
Chrome and Edge install the dashboard as a standalone window. There is no service
worker.
Reasons:
- Chrome does not require a service worker to offer install on desktop.
- The server sends
no-storeon every JS and CSS file so a deploy never leaves a browser on an old module graph (seesrc/index.ts). A service worker is a second cache that could undo that. - An offline shell would be useless: the dashboard is only meaningful with the live API.
- The manifest link uses
crossorigin="use-credentials". Production sits behind Cloudflare Access, and a manifest request without the Access cookie is redirected to the Access login and silently ignored.
Revisit if push notifications or an offline page are wanted; both need a service worker and a cache policy that keeps deploys from going stale.
Every two-half status dot has the same hover
Decision: the pipeline list and a shared encode row share one renderer
(public/ts/features/status-tooltip.ts). The hover has a heading per half
(pipeline: Input, Outputs; shared encode: FFmpeg, SRS input), then that half's problems
or one muted line, "OK" or why it is off. A switched-off encode shows a single "Idle"
line. The gradient comes from one helper too. The hover says what is wrong and has no
advice: the advice is an info icon on the line where the problem is listed on the pipeline
page (the output card, the input's stats, the SRT Relay card) and in the Overview's Issues column. The SRT Relay card has
no hover: it lists its problems in the card, as the input does, and its circle is only
the colour.
Why: the three had grown apart: the pipeline dot listed problems in one mixed list and showed nothing when healthy, the relay dot listed problems or one sentence, and the shared encode dot had headed halves. With the same dot shape on all three, a reader expects the same hover, and a mixed list does not say which half to look at. The advice left the hover (November 2026) because it made it long and the line it belongs to is where somebody acts on it.
In the pipeline's hover the relay's problems sit under Input, because the dot's left half already takes the relay's colour; the outputs sit under Outputs.
The Overview filters in the browser, and searches names, keys and URLs
Decision: each Overview table has its own search box on its heading line, matching as plain, case-insensitive text: an input's name, stream key and publish URLs, an output's own name, its pipeline's name and its destination URL. It filters the rows already in the browser and combines with the All/Active/Issues tabs. The Issues tab also lists an offline input when outputs of its pipeline are in trouble, and the heading badges show "shown of total".
Why:
At 50 inputs and 500 outputs the Overview is about 32 screens (Sizing), and finding one output meant scrolling. The page already holds all 500 rows (about 18 KB gzipped each refresh), so a server-side search would add an API route for nothing.
Two boxes, not one: the tables have different rows and an output matches on its pipeline's name too, so one box would filter two lists by different rules.
An offline input stays "off" everywhere else. An idle pipeline before a show is normal, so marking it a warning would turn the sidebar yellow for every unused pipeline. It is an issue only where an operator is looking for causes: the Issues view with affected outputs. Before, that view listed 20 affected outputs and "No input issues" while two inputs were down.
A heading that says 500 above a list of 20 hid how much a filter had removed.
URLs and keys were added at the operators' request (October 2026). The first version matched names only, because a destination URL can hold a platform stream key. But finding "the output that sends to this URL" or "the input with this key" is what operators search for, and the search shows nothing new: the rows still display what they did, and anyone who can type in the box can already open the output or input to read the same URL. The match is local to the browser; nothing is sent.
Not adopted: matching statuses, regular expressions, and a search that also covers the SRT Relay table.
Tested: 50 pipelines and 500 outputs on the test stack, typing during the 5 s refresh (focus, text and caret survive it).
Revisit when: operators ask to search by status, or the output limit rises.
The Outputs list has a filter bar, and a pipeline's Problems filter means what the card shows
Decision (October 2026): above a pipeline's outputs sit a filter box (name or destination URL), a Problems toggle and badges counting errors, warnings, running and stopped, with "8 of 44" while a filter hides outputs. Problems keeps an output with an error or any warning its card shows: a crash being retried, a stop after repeated failures, a warning from the running output, "Same destination as …" and the encoding advice. The filter is per browser, starts empty for each pipeline, and cards cannot be dragged while it hides any.
Why:
- A failing output among 100 meant scrolling about 6 screens (a healthy card is 56 px). The Overview already filters, but only across pipelines and without the card's warnings.
- The sidebar's counts are not enough. They count each output's live status, so they leave out the card-only warnings (a same-destination warning on a running output, advice on a stopped one). The badges and the filter use the card's rule, so what is yellow or red is what Problems keeps. The two sets of counts differ for that reason.
- Running and stopped are the outputs' own state, and errors and warnings overlap them. A first version put each output in its most severe bucket only, so the badges added up to the total, but a stopped output with a warning was missing from "stopped". That read as lost outputs; the overlap is easier to read than the sum.
- No dragging while filtered: the saved order lists every output, so a drag of only the visible cards would drop the hidden ones from it.
Not adopted: a one-line row mode (a healthy output is already one row in a normal width; the height is in warning lines), and a sort that puts problems first (the saved manual order stays).
Revisit when: repeated warnings across many outputs keep filling the list (grouping identical warning lines was left out), or the sidebar counts confuse operators.
An output's figures are shown only when they are off
Decision (October 2026): the output card shows a figure only when it is abnormal, as its own badge with its own tooltip and colour (a red memory badge next to a yellow speed one), and nothing for a healthy output: the bitrate outside 60% to 140% of the pipeline input's (when the output copies the video and the input's rate is known) or below 200 kbps; the CPU from 50% of a core on an output that copies the video, and always on an output with a video encode (November 2026: it was never shown there, but an encode is what the host's CPU goes on, so each one's cost should be visible); the memory from 70% of its limit; the speed outside 0.95x to 1.05x, with no mention in the tooltip. A shared encode's badge is judged the same way and leaves out only an expected bitrate. The full per-output figures stay in the Overview's Outputs table.
Why:
- Every healthy copy output printed the same "8.0 Mbps / 0.4% / 35 MB", which carried no information until it differed, and it was clutter on 100 rows. A copy output costs 1 to 4% of a core and about 35 MB (sizing), so 50% of a core is far outside normal; an output with a video encode runs at 100% or more by design, which is why its CPU is shown always and not as an alert.
- The band is wide because the numbers differ for normal reasons. On an SRT input
SRS reported 8.9 Mbps and the goryu legs 9.2 (libsrt counts 44 header bytes in each
1316-byte packet, +3.3%), while copy outputs read 8.2 and 8.0: FLV carries less
container overhead than MPEG-TS. FFmpeg's
bitrate=is also an average since the output started, not the current rate. - A faulty output is caught elsewhere too: below the 200 kbps minimum or with no bitrate the card warns, and the stall watchdog restarts a frozen output.
Limit: because the figure is a lifetime average, a drop in a long-running output
moves it slowly and may not leave the band. A rate over the last 30 s (the delta of
total_size, as the speed already uses out_time) would react in seconds but changes
what bitrateKbps means in the API, the Overview and the low-bitrate warning, so it was
not done.
Revisit when: operators miss a slow drop (switch to the windowed rate), or the band hides a real fault.
Alert sound beeps for new problems only, in the browser
Decision: the dashboard beeps once a second for 5 s when a problem appears that was not there at the previous 5 s poll:
- the server, SRS or the SRT relay becoming unreachable;
- an error-level pipeline alert;
- the host's memory or disk reaching 90% (an error in
hostAlerts; a warning is silent); - an input going offline while its outputs are meant to run;
- an output crashing or being restarted by a watchdog.
A problem that lasts stays silent. The bell in the navbar mutes it, and its slider sets the volume (0–500%); both are kept in browser local storage and shared by tabs on the same site. The page tries to resume audio on startup; if browser autoplay policy blocks it, the bell still reflects the saved mute setting. The beep and control are ported from live-gallery's alert beeps, so both tools sound alike.
Why:
- Beeping while a problem lasts gets the sound muted. A destination that is down
for an hour retries every 16 s. A crash within 60 s of the same output's previous
one counts as the same episode (the server's
STABLE_RUN_MS), so a failing output beeps when it starts failing, not on every retry. Tested on the test stack: an output to a destination refusing connections beeped once and stayed silent through its next five attempts. - The first poll after opening the page only records what is already wrong, so a reload does not beep for problems already on screen.
- In the browser, not the server. The dashboard is on a visible screen during events, so its sound reaches the operator without push permissions, Do Not Disturb or a phone. The 5 s poll already carries everything needed, so the server is unchanged.
- Warnings do not beep (timestamp floods, falling behind, SRT loss): they are frequent and usually recover on their own.
- Host memory and disk errors beep, host CPU and warnings do not. Low memory ends with the kernel killing FFmpeg or SRS, and a full disk breaks the database, diagnostics and journal, and neither clears on its own. The CPU alert's thresholds come from a desktop measurement, not production (see Host resource alerts), so a beep on a healthy event would get the bell muted. It still shows in Server events.
Not adopted: a "silence for N minutes" button (mute is simpler, and the operator decides when to unmute); keeping a background tab's polling unthrottled (the dashboard is on top during events); push notifications.
Revisit when: operators mute it because it beeps too often, a problem worth a
beep reaches the dashboard only as a warning, or the CPU alert has fired only on real
trouble in production (then add cpu to the beeping host alerts).
The Status view is one page without the sidebar, drawn in parts
Decision (October 2026): a Status view (?view=status) shows every pipeline as a
card with a dot per output, the host graphs and the recent warnings and errors, in the full
width with the pipeline list hidden. A plain click on a card opens the pipeline, and
Ctrl-click opens it in a new tab. The page is built once and each part (counts, cards,
problems list) is replaced only when its HTML changed; the graphs are drawn again on every
poll.
Why:
- The Overview is about 32 screens at 500 outputs (Sizing), and the sidebar shows counts per pipeline but not where in a pipeline the failing output is. Our pipelines are a fan (100, 80 and 50 outputs, then 4 to 5), where a block of dots shows a run of failures that a count hides.
- The sidebar is hidden there because the view lists every pipeline itself. With it, the cards had three columns and scrolled; without it, four columns hold all 50 pipelines and 501 outputs on 1920×1080.
- Parts are replaced only when changed because rebuilding all 500 dots every 5 s reset a hovered dot's tooltip and dropped a text selection. It also cut a poll from a median of 57 ms to 16 ms (worst of 20: 205 ms before, 27 ms after).
- The problems list is fetched on its own every 15 s while the view is open, not on every poll: it is one small query (the Events table), and the warnings it shows change slowly.
- Cards are real links so the browser's own Ctrl-click and middle-click work and a second screen can stay on Status while changes are made on the first.
Not adopted:
- A separate wall mode (larger type, no navbar, automatic login, a sound button, a periodic self-reload). The screen is a TV on a PC's HDMI output that a person sits at, so none of it is needed. The navbar stays so Settings, Logs and the pipelines are one click away.
- Cards that re-order by severity: a layout that moves between glances is harder to read. The Issues tab is the filter.
- A tooltip per dot as page elements: 500 hidden nodes for something the browser's own
titledoes. A failed poll shows the existing connection banner.
Revisit when: a screen has to run unattended (needs a login that outlives the 7-day session, a way to enable sound, and a periodic reload so a page left open for days cannot grow), or the supported size grows past what fits a screen.
The Events table is built on request from what is already stored
Decision (October 2026): the Logs page's Events table (GET /api/events) merges the
pipeline log lines, each output's History and the Server events when it is asked for.
Nothing new is stored. The page loads it when it opens and on Refresh, and does not
refresh itself.
A crash that is only an exit status (exit=0) gets the first failure line of its FFmpeg
stderr added to the row's first line, with the URL's path cut (it may hold a stream key).
The table shows only that line until the row is expanded, and an exit=0 from SRT input
that broke under CPU overload told the operator nothing. The History keeps the message
as stored.
Why:
- "What just happened" meant opening each pipeline's History and each output's. At 50 pipelines and 500 outputs that is hundreds of places during an incident.
- No new table or write path. Writing events as they happen would add a write to the start, stop, restart and retire paths, which are kept plain on purpose (ADR 0001). Reading what is already stored cannot leave a state wrong.
- It is cheap, so it needs no cache or timer. At the ceiling (50 pipelines with 100 log lines each, 500 outputs each with a full History, 100 Server events) the merge took about 5 ms (median 5.3, worst 6.3 of 20 runs, measured in process): one indexed query and parsing the History the health poll already parses.
/api/srs-logsis not reused because it runsjournalctlthree times per request.
Limits: it shows what the server still holds: an output keeps its last 10 History
records (at most 5 of them warnings), a pipeline its last 100 lines, and the Server
events are the last 200 in memory. The complete record is in the diagnostics files under
/var/lib/bunryu/diagnostics/, which the API does not serve.
Not adopted: a refresh timer (the page rewrites the log tails below the table on each load, which would reset their scroll position), and a table of events kept just for this feed.
Revisit when: operators need events older than those caps, or a wall display needs a live feed; either points to storing events or serving the diagnostics.
Don't probe platform hosts from the server
Decision (October 2026): the host connectivity probes were removed: a dashboard
tab that opened a TCP connection every 5 s from the server to up to 10 configured
host:port targets (for example a platform's RTMP ingest) and charted the latency.
Destination failures are diagnosed from the outputs themselves.
Why:
- It left no evidence. The samples were kept only in memory (6 h) and never written to the diagnostics, the journal or the pipeline log, so a service restart erased them and nothing could be read back after an incident. Only someone with the tab open at the time saw them.
- It raised no alert. Nothing in the health poll, the alerts or the beeps used the result, so it could not warn during a live event.
- The outputs already say the same. A destination that refuses or times out shows in that output's History (FFmpeg's stderr tail and exit reason), in the socket watchdog's findings and in its retry state, per output and with a timestamp. The probe added only "is the platform down or just this output?", and only for someone who looked.
- It has not helped. The one incident it could have explained was a live event where a platform's RTMP ingest was unreachable, and no fail-report cites it. General network problems are watched by a separate monitor (Ping Monitor), which does not cover the path from this VM to the platforms.
- Cost: a service and loop, a settings form, a dashboard tab and chart, two API routes, a database table and several hundred lines of tests, for a view that has not been useful.
Existing databases: the table is dropped from the schema and SCHEMA_VERSION is
bumped to 2, so an install with a version-1 database is asked to wipe it on the next
install, like any schema change (see
Database schema version).
The pipelines and outputs have to be created again from the .bak copy.
Not measured: how often operators opened the tab.
Revisit when: an incident shows that "the platform was unreachable from the VM" could not be told from the output's own error. Then log one TCP connect check to that destination in the output's existing failure event, which needs no configuration, loop, table or UI.
The server decides the status of an input or output; the dashboard shows it
Decision (November 2026): the status of every saved input and output (good, warn, error
or off) and the problems behind it, its verdict, is worked out on the server
(src/utils/healthVerdicts.ts, with the rules in outputStatus.ts and inputStatus.ts)
and sent in /api/health as verdicts. The dashboard reads it and works out nothing: its own
copy of the rules (outputHealth, inputHealth) is deleted. The Key Vault report uses the
same rules. See ADR 0006.
Why:
- There were two copies of the rules. Key Vault needed the verdict on the server, and the
server cannot import
public/ts/core/status.ts: a probe file insrc/that imported it failedtsc -p tsconfig.backend.jsonwithTS6059(the importedhints.ts,utils.tsandtypes.tsare outsiderootDirsrc) andCannot find name 'document'(utils.tsuses the DOM; the backend has no DOMlib). So the server got a second copy, about 400 lines with 390 lines of tests that ran both on every combination of state. Tests catch only the combinations they list, and the copies had already drifted in shape (the dashboard'soutputHealthhad anincludeInputswitch the server's lacked). - The join was a third copy. The dashboard assembles each output's view from the config
and the health response (
parsePipelines, including which shared encode it reads); the server assembles the same view (buildOutputViews). Sharing only the verdict function would have left that twin. - It costs the dashboard nothing it had. The verdicts are worked out when
/api/healthis asked for, from the saved rows as they are then and the last poll, so a change just made (an output started) shows at once, as it did when the dashboard worked it out from a fresh/api/pipelinesand the polled status. - A bad row cannot fail the health response. A verdict that throws is
warn, "The status could not be worked out.", is logged once a minute per input or output, and the rest are unaffected; if the database cannot be read there are none and the dashboard shows each as unknown.
Not adopted: one source file compiled into both builds. A shared folder needs a common
rootDir, which moves the backend output from dist/index.js to dist/src/index.js
(the start script, the systemd unit, docker/entrypoint.sh, the install docs); a copy step
that generates a second copy at build time avoids that but still leaves the join twin.
Tradeoffs: a dashboard tab left open across a server upgrade shows each status as unknown
until it is reloaded. The relay path's verdict (relayHealth) is still worked out in the
browser. So is the advice about how an output or pipeline is configured (a destination
another output uses, audio settings that do not suit the input, a stream key two pipelines
share, which shows as a yellow line in the pipeline's Publish card): it is not a status, only the dashboard shows it, and its wording is the dashboard's to
change, so it is a pure dashboard module (public/ts/core/output-advice.ts) and a change to
it needs no server change. Every line is the same: one yellow line on the output's card (the
same destination as another output, a loop, a track selection the input cannot supply, Track 1
costing CPU, SRT to RTMP with copy audio). It does not tint the card, colour the status dot
(which stays the server's verdict) or count in the pipeline list, the Overview, the Status view
or Problems. An operator may mean them (the same destination on two pipelines is a primary and
its backup), and amber on every other view for something intended would teach people to ignore
amber, the reason Key Vault leaves advice out. The dashboard repeats three values for display: the input alert codes, the
200 kb/s floor and the 30 s warm-up for SRS's zero bitrate; test/statusConstants.test.ts pins
them to the server's.
Checked on the isolated test stack: a healthy pipeline showed every dot green; with the timestamp-discontinuity flood on, each output showed its warning and the pipeline dot was half yellow; with the publisher killed, each output said "Output is running but input is not live" and the input half went grey.
Revisit when: a second client needs the advice (an API consumer, notifications, a check when an output is saved), or tabs left open across upgrades turn out to matter.
One dashboard module decides what is a Problem and what a pipeline's dot shows
Decision (November 2026): public/ts/core/problems.ts works out, once per render, each
pipeline's input half, each output's Problem and the group roll-up, and the sidebar, the Status
view, the Overview and the Outputs list draw its answer. The input half is the server's input
verdict raised to the relay's warning or error, so an unstable or lost leg, or a relay that
cannot reach SRS, shows on the dot even while the input is off; the relay never turns an input
that is off into a healthy one. Status (dot colour, the counts beside it) and Problem
(lists, filters, "has issues") stay separate in the code, though both now follow the verdict.
An output stopped after repeated failures (status off, error kept) is neither: its card shows
the error as a yellow line and the pipeline is not marked (November 2026; before, it was an
error Problem that put a red outline on the pipeline's Status card). There are always a few
broken outputs, and one a person has stopped is not a reason to flag the whole pipeline; Key
Vault still reports it as an error, so an outside monitor learns the output gave up.
Why: the rules had been written out in four places and had drifted. A verdict of warn with a relay error was yellow in the sidebar (it folded the relay in only for a good verdict) and red in the Status view; the Status view skipped the relay for an off input, which hid a relay that could not reach SRS; the group header ignored the relay; the sidebar's output counts, the Overview and the Outputs filter each had their own idea of a Problem, and only the filter counted a stop after repeated failures (since dropped, see above). Six commits had moved or patched this rule before it had one home.
Not changed: a relay connected to SRS that SRS has not yet listed as the input stays a
warning (the gap after a new publisher connects is normal, and an error would flash on every
connect; relay-forwarding-stalled catches one that never starts). The Overview's input rows
stay on the server's verdict, because the relay has its own table there. The sidebar's output
badges stay status-only so they match the dots.
Revisit when: a second client needs the roll-up, or the server takes over the relay path's verdict.
The dashboard keeps its own copy of the shared-encode recipe rule
Decision (October 2026): public/ts/core/renditions.ts stays a hand-kept twin of
encodeRecipe and RENDITION_URL_RE in src/utils/renditions.ts. test/renditions.test.ts
runs both over every video and audio combination and fails if they disagree.
Why: the twin is about 25 lines. Removing it means either publishing each output's
shared encode to the browser (a new field in the API, which the dashboard could not
otherwise do without) or compiling one source file into both the server and the
browser (a build change across two tsconfigs). Either costs more than the test that
keeps the copies equal. The two server-side dependentsOf functions are not the same
rule written twice: one asks which outputs are reading a rendition now (running state),
the other which outputs need one (saved configuration).
Revisit when: the recipe rule changes again, or the API gains a field that already carries each output's shared encode.
The dashboard has its own small design system instead of daisyUI
Decision (October 2026): public/input.css defines the dashboard's tokens and the few
components it uses (buttons, badges, fields, dialogs, tabs, tables, the pipeline list,
banners) on top of Tailwind's utilities. daisyUI is removed. Colour is for status: green,
amber and red mean status and nothing else, so a problem stands out on a console read for
hours. Each token is a light-dark() pair, so there is no second copy of the palette. The
dashboard opens dark the first time, whatever the system prefers; the navbar's sun/moon
toggle pins the other theme per browser (features/theme.ts). Status dots, split dots and
card tints use brighter --dot-* tokens than the status text colours (an amber that reads as
text on white is brown as a dot), and the charts resolve --chart-* through the browser
because a canvas cannot read var() or light-dark(). The Japanese motif is kept only where
no data is read, the login page's layered swells: a static SVG mask in the accent, so no
animation cost on a dashboard open for hours. Glows and patterns behind the data were tried
and competed with it.
Why: daisyUI's dim theme was one dark look with its own radii and colours, and the
dashboard overrode it in about 190 lines (menu wrapping, table header and tab contrast, the
wave background). The markup uses only a dozen of its components, so owning them is less
CSS than overriding the rest. The class names the markup already uses (btn, badge,
modal, select, fieldset, and the base-*, success, warning, error colours) are
kept and mapped onto the tokens, so the redesign did not have to touch the rendering code.
Revisit when: a component the dashboard needs is not in input.css (a dropdown or a
date picker); write it there rather than bringing the library back.
Key Vault link
Bunryu pushes a status report to Key Vault, with hashed destinations and redacted text
Decision (November 2026): Key Vault (the stream-key manager, whose key colours used to
be set by hand) gets the status of every configured output from Bunryu. Every minute, and
on a status change at most once per 10 s, the app POSTs one JSON report to an HTTPS
endpoint with a bearer token, all set in Settings (see below). An output is named by HMAC-SHA256(secret, normalised URL) cut to 32 hex characters, never by its URL, and the message has URLs, streamid=,
passphrase=, key= values and long token-like strings removed and is cut to 300
characters. The status is worked out on the server by the same rules as the dashboard
dot, minus the advice (see
Configuration).
Why:
The link is a setting, not part of
bunryu.json. The first version read akey_vaultblock frombunryu.jsonat start-up. That made the operator edit a file on the server and restart the app to change a token, and, to catch typos, a bad block had to stop the start (exit 78, which systemd does not restart): a typo in optional telemetry would have kept every stream down after a reboot, against the rule that one misbehaving side channel must not take down the rest. In Settings the value is checked when it is typed (the route answers 400 and saves nothing), so the stored one is always usable, nothing about the link can stop the start, and a stored value that is unusable anyway (the database edited by hand) only leaves the reports off, with an event. The reporter reads the setting at start and again when the route saves it (reconfigure()): it cancels the report on its way, drops the hashes (keyed by the old secret) and the failure episode, and sends to the new link at once. The token and the hash secret sit in the database, like the dashboard password's hash, so they are written only and the dashboard reads backsecretSet; an empty field keeps the saved value. The host is checked with the output destination policy's address classes (link-local and unspecified are refused) because an operator-typed URL is a server-side request like an output destination. A "Send test report" button (one attempt, no retries, showing the receiver's answer such asHTTP 401) was removed: saving already sends a report at once, and a failure is logged and the next heartbeat sends the state again. A report is not retried within itself (the first version retried twice, after 2 s and 5 s): every report carries the whole state, so the heartbeat is already the retry, and Key Vault tolerates two missed ones before it mutes.One secret, two derived values (November 2026). The first version asked for two random secrets, a token and a hash secret, and they had to be copied to Key Vault and here without a mix-up. Now there is one, Key Vault's
KEY_VAULT_SECRET, and both sides derive the two values asHMAC-SHA256(secret, label)in hex (key-vault/ingest-token,key-vault/hash-secret). They stay independent: the token travels in a header every minute, and seeing it says nothing about the hash secret, which never leaves this server and Key Vault. A split of one long value into a left and a right half was rejected because it needs a fixed length and a short value silently gives weak halves; the derivation takes any secret of 32 or more characters. Only the two derived values are saved, so the reporter and the saved format did not change and the secret is not kept. The derivation is pinned by the same two values in both repositories' tests (test/keyVaultConfig.test.ts). A link saved before this change keeps working with its old token and hash secret until Key Vault is moved to the new secret.Push, not pull. Key Vault runs on a free serverless tier and Bunryu sits behind a tunnel with a login, so Key Vault cannot call in without a second credential and a new public route. One outbound request a minute is about 43,000 a month against the 500,000 the tier allows, and its steady arrival is also the proof that Bunryu is alive (Key Vault mutes its colours after 3 minutes of silence).
A hash, because the destination is the secret. An output URL contains the platform's stream key. Key Vault already holds the same server and key, so it only needs to recognise a URL, not read it. HMAC rather than a bare hash because stream keys come from small formats that could be guessed, and a keyed hash cannot be checked offline by someone who sees a report. 32 hex characters (128 bits) keep a collision out of reach with the 500 outputs at most. The URL is normalised (trimmed, lowercase scheme and host, no trailing
/) because Key Vault builds the same string from a server and a key and must not differ by spelling; both sides check the vectors intest/fixtures/key-vault-hash-vectors.json.Redaction, because the text is FFmpeg's. An output's error line is stderr, which names the destination (
Failed to open rtmp://…/<key>), and the SRT streamid and passphrase appear in relay errors. Logs here are private and unredacted; a report leaves the machine, so it is cleaned at the point of sending, after the text is chosen and before it is cut, so a secret cannot be left half-cut. It errs towards removing: any 16-character run with a digit goes.Advice is not a warning to Key Vault. The dashboard's Problems filter also counts a destination shared with another output and encoding advice ("Track 1 re-encodes the audio"). Neither means the stream is not being delivered, and a key shown amber for a working output would teach people to ignore the colour. A running output with an unresolved crash is an error, as in the Problems filter.
The reporter uses the dashboard's status rules. The statuses are the verdicts the dashboard shows (
outputStatus.ts,inputStatus.ts; see The server decides the status), mapped torunning,warning,errorandstoppedbyreportedState: a stop after repeated failures and an unresolved crash on a running output are errors, and the advice is left out, as above.Inputs are reported too, matched by name (November 2026). The report also carries the state of each pipeline's input, so Key Vault can say that a stream is failing because the signal is not arriving, which is not the platform's fault, instead of sending the media team to chase the vendor. The match is by the pipeline's name, ignoring case and extra spaces, because an id would have to be configured on both sides and a link that cannot be mistyped is not worth that; Key Vault's input form tells the team to name them alike, and a pipeline that matches nothing is ignored. Outputs already carry their pipeline's name, so Key Vault can also warn when a stream's link runs in a differently named pipeline, with no new data. No signal with an output set to run is an error, not
stopped: that is what makes the feature useful, since an input nobody is sending to would never otherwise read as a problem. The cost is that before an event, with outputs set to run and no encoder connected yet, every input reads "Not arriving"; Bunryu runs during events and this is the state somebody wants to know about, so it was accepted. Alerts count only when they are about the input (INPUT_ALERT_CODES); the SRT relay link alerts do not. The report carries nohint: Key Vault writes its own advice for the media team (see Hints are a dashboard lookup, not an API field).
Revisit when: matching inputs by name causes a wrong match in practice (then configure an id on both sides).
Evidence: a report for 50 pipelines with 10 outputs each is 91 KB and builds in 3.4 ms
once the hashes are cached (31 ms the first time), cheap enough for the check Bunryu
makes after every 5 s health poll to see whether a status changed. The first hash vector
was recomputed with openssl dgst -sha256 -hmac and matched. Tests run the reporter
against a local HTTP receiver that is down, returns 500, 401 and 429, never answers,
redirects and recovers, and check one log line per episode, bounded retries and a
request that never blocks the health poll.
The Settings link is covered by tests that a wrong value is refused with nothing saved
or applied, that the token and secret are never in a response, that a change made while a
report hangs cancels it without logging a failure, that new settings reach the next
report (URL, token, hash secret), and that an unusable stored value leaves the reporter
off with one event.
Not adopted:
- Pulling status through the dashboard API: needs a public route and a second credential.
- Sending the URL over HTTPS and hashing at Key Vault: the stream key would sit in Key Vault's logs and database.
- A queue of unsent reports: only the latest state matters, and the next report carries it.
- A dashboard indicator for the reporter: the log and Key Vault's own offline banner cover it; add one if operators ask.
Revisit when: Key Vault needs history rather than the latest state (send changes with a timestamp), a second consumer wants the status (move it behind a documented API route), or operators want advice shown as a colour.
Tooling
ESLint checks promise handling; Prettier stays the formatter
Decision: npm run lint runs ESLint with the typescript-eslint recommended
rules plus four type-aware ones: no-floating-promises, no-misused-promises,
await-thenable and only-throw-error. eslint-config-prettier turns off every
rule that overlaps with Prettier. CI runs lint as its own job.
Why:
tscmisses crashes that matter here. It accepts anasynccallback passed tosetTimeoutor an event emitter. If that callback rejects, nothing handles the rejection and Node exits, taking every pipeline's control plane with it.- The type-aware rules are cheap at this size. A full run takes about 10 s.
Evidence: the first run, in October 2026, found about 30 issues in 18,000
lines. One was a real crash path: the scheduled ffprobe in health.ts had
try/finally with no catch, so a throw while recording the result would have
been an unhandled rejection. It is now covered by a test. The rest were unused code
and small cleanups.
Not adopted: stylistic rule sets and the strict presets. They would mostly
churn working code.
Revisit when: the lint run gets slow enough that people skip it, or a bug reaches production that a rule would have caught.
Logging and diagnostics
Keep the process running after an uncaught error
Decision: uncaughtException and unhandledRejection are logged (journal and
a diagnostics event) and the process keeps running. Each background loop (health
poll, output watchdog) also catches its own errors and logs the
first failure and the recovery. The diagnostics writer handles its own stream
errors. Shutdown steps and staggered restarts run through runLogged, which records
a throw as step-failed and carries on. Requests answer errors in JSON.
Why:
- Exiting kills every output. The FFmpeg processes exit by SIGPIPE when the control plane dies (by design, so none are orphaned). A bug in one timer or a full disk would otherwise end every forward of a live event, and systemd's restart would not bring them back for several seconds.
- The loops are independent. A throw in the health poll leaves the output processes and their watchdog untouched. The next tick starts from fresh state.
- Surviving an error must not leave the process half-stopped. A throw inside the SIGTERM handler would be swallowed by the same handler and a second SIGTERM is ignored, so the process would never exit. Each shutdown step is isolated.
- One bad row must stay one bad row. An unparsable
outputs.last_errormade everylistOutputs()throw (watchdog, health, API). It now reads as empty history. - A server error must not look like a lost connection. Express's default 500 is HTML; the dashboard failed to parse it and showed the connection banner. Errors are JSON and the dashboard shows the status of a non-JSON answer.
Evidence: before this, nothing listened for errors on the diagnostics
WriteStream, so a full disk would have crashed the app, and so would an
unwritable diagnostics directory at startup. The health poll and the host-probe loop
(since removed, see Don't probe platform hosts from the server)
had try/finally with no catch, the same pattern the ffprobe fix (see the
ESLint entry above) removed. Regression tests cover a write-stream error, an
unwritable directory, a throwing health poll, a corrupt History row, runLogged
and the JSON error handler.
Revisit when: an incident shows the process kept running in a broken state
after an uncaught error. Then exit on uncaughtException and rely on systemd.
Diagnostics ideas taken from SRS, MediaMTX and restream-krsna
Decision (October 2026): adopted:
- a per-run id on every output event (SRS tags every line, hook and API entry of a connection with one context id);
- the first occurrence plus a count of the rest for repeating events (SRS's error pithy print, MediaMTX's 1 s counter dumpers), applied to rejected publishes, loop failures and repeated exit stderr tails;
- alert episodes with a start and an end, derived from the 5 s poll (krsna derives alerts from its health snapshot);
- a random id per server start (SRS's heartbeat
service_id).
Not adopted:
- A Prometheus
/metricsendpoint (both SRS and MediaMTX have one). Nothing scrapes it yet, and it would be a new port or route to secure. - Delivery ratio (destination-acknowledged bytes ÷ offered bytes) and layered root-cause diagnosis (krsna). Both are useful, but each needs new state and UI.
- Logs in SQLite (krsna). JSONL plus journald is enough at this size.
Reviewed again on 2026-10-25, when krsna had added alert notifications, picture and sound checks, destination anomaly baselines and a keyframe-interval verdict. Adopted: the keyframe check, as a one-time ffprobe per publisher. Not adopted:
- Alert notifications (Slack, Discord, signed webhooks, Web Push). The operators do not need the server to send them.
- Picture and sound checks (frozen or black picture, silent track).
live-galleryalready checks the outputs this way, and krsna's own cost is about 2 % of a core per checked pipeline. - Destination anomaly baselines (each output learns its usual delivery, round
trip and retransmits and is flagged when it drifts). None of the six incidents in
fail-reports/(2026-07-10 to 2026-10-25) was a slow degradation: each was a step change or an outright failure (an OOM kill, a log flood, a 30 s timestamp offset, a shared encode that delivered nothing), which the existing watchdogs and alerts already catch. A baseline adds three tuned thresholds (warm-up, deviation, run length) with no incident behind them.
Its rebuilt dashboard (a fleet console for thousands of outputs, with roles, tours and a command palette) mostly does not fit a 50-input, 10-viewer tool. Three small things did, adopted on 2026-10-26:
- Secondary text meets WCAG AA contrast. Measured on the pipeline page, 15 of 73
texts were below 4.5:1 (labels and timestamps dimmed with
opacity-60oropacity-40were at 2.6 to 4.0, the table headers at 4.1, inactive tabs at 3.3). Onetext-mutedclass (a single grey, 4.7:1 or better on every surface in both themes since the October 2026 redesign, 82 % opacity before) now carries all secondary text, and an audit of the pipeline and Overview pages finds none below AA (66 and 140 texts). Dimming that means "inactive" (a quiet SRT figure, a disabled button) stays on the opacity utilities. - Ages instead of clock times ("probed 2 min ago", "since 3 min ago"; the exact time on hover), because "probed 14:07" does not say whether it is stale. They count from the health snapshot's own time, so a skewed browser clock does not change them. History keeps full dates and times for incident review.
- Inline validation. The output editor's port, latency, passphrase length and
custom RTMP URL carry native constraints and turn red once edited and invalid
(
:user-invalid), instead of only after Save. The Save check stays the authority.
Not adopted from the dashboard: light theme and density switch, command palette, tours and guide pages, roles, per-group charts, and a last-minute ingest-rate sparkline per pipeline (the low-bitrate warning already covers the serious case).
Revisit when: someone wants external alerting (add /metrics, loopback-only),
or an incident shows outputs connected but not keeping up (add the delivery
ratio; outputSockets.ts already reads ss), or an incident shows a destination
getting steadily worse while staying green (add the baselines).
Warn when an output falls behind realtime, measured from its media clock
Decision (October 2026): every output gets a "falling behind" card warning when
its media clock runs below 0.9x wall time over two 30 s windows in a row. The speed
is computed from FFmpeg's out_time progress, not read from its speed= or fps=.
It is a warning only, like the other card warnings.
Why:
- The existing watchdogs miss it. The progress watchdog fires only when progress stops for 45 s, and the socket watchdog only when the socket is gone. An output whose destination or encode accepts data slower than realtime has both, yet gets further behind live every second until SRS's play queue drops data.
speed=andfps=are whole-run averages (measured with the pinned FFmpeg on a copy output:speedandfpsafter 2.5 s still carried the initial burst). After hours of healthy running a slowdown would barely move them.- Two windows, and a gap resets. One slow window is what an input hiccup looks like. A pause of more than 10 s is a stall, which the progress watchdog owns.
- Warn, never restart. A restart does not fix a slow destination or a slow encode, and would drop the platform session for nothing.
Not adopted: killing a slow output; a per-output speed field in the API (the
warning text carries the number).
Revisit when: the warning fires on healthy outputs (then widen the window or lower the threshold), or operators want to see the speed continuously.
Host resource alerts: CPU, memory and disk
Decision (October 2026, revised November 2026): the health poll raises an alert with two levels, a warning from 70% and an error from 90% of the same percent-used figure the dashboard's top bar shows, and ends it only under 65% (warning) or 85% (error). CPU also has a pressure error. They are reported (journal, diagnostics events, the dashboard's Server events table, a banner and the top bar's colours) and nothing is acted on. The numbers are in Reliability.
Why:
- Before this only memory had an alert. A CPU-starved host (the sizing page shows a
1080pencode of a 4K input not keeping up on 4 vCPUs) makes outputs fall behind and SRT ingest drop packets, and the operator saw only each symptom per pipeline. - The operator keeps production under 65% and wants to hear about it above 70%, well before memory runs out (the first memory alert started at 85% used) or the disk is full. The bar already turned yellow at 70% and red at 90% by a rule of the dashboard's own, which drifted from the server's alerts (a red bar with no alert, an alert under a yellow bar). The rule now lives only on the server, and the dashboard shows its result.
- Start and end thresholds differ, and the CPU alerts also need the reading to hold for 30 s (start) and 60 s (end), so a reading that hovers near the line is one episode, not a stream of them. The same idea ends a pipeline alert after six quiet polls.
CPU uses both busy and pressure. The first version used pressure (PSI) alone,
because an encode is meant to use the CPUs (a 720p encode takes about 2 vCPUs) and a
busy alert looked like it would fire in normal use. The 65% target changes that: a host
sized for its encodes is meant to have headroom, and a host at 70% busy has little left
for a second encode or a spike. Busy percent says how much is used, which is what the
operator sizes against; pressure says whether work is already being starved, which stays
low until the machine is full, so it is kept as an error on its own. A kernel without
/proc/pressure/cpu gets the busy alert only.
Evidence for the pressure threshold (8-CPU development host, busy loops, some avg10):
| Busy loops | Load | Pressure after 45 s |
|---|---|---|
| 8 | 1.0x | 25-30% |
| 10 | 1.25x | 46-53% |
| 16 | 2.0x | 68-70% |
A first draft used 90 to start and 85 to end; that never fires, since pressure stays
near 70 even with the host twice oversubscribed, and a threshold of 70 would stay
silent at about 1.5x oversubscription, where the sizing page has a 1080p encode of a
4K input no longer keeping up (about 55-60% by interpolating the table). 50 is about
1.25x oversubscription, and 30 sits just above the reading of a fully busy but
unstarved host, so its noise does not hold an alert open. These come from a desktop with background load, not from the
production VM.
Disk: the filesystem of the database directory (database, diagnostics, HLS previews) and the root filesystem (journald, SRS logs), by percent used. Diagnostics are size-capped and previews stop when idle, so this catches the journal, logs or database growing, or another tenant of the disk.
Not adopted: acting on the alert (stopping outputs, shedding load), which could take down streams on a reading that may be harmless; a beep for a warning or for CPU (the beep is for what needs someone now, see below); a threshold in the dashboard (the drift above).
Revisit when: a production incident shows the CPU thresholds firing late or on
healthy load (compare host.cpuPressure in the health-snapshot with the alert
times), or the 70% warning is noisy on a host that is meant to run hot.
Failures that need an operator exit with status 78, which systemd does not restart
Decision (October 2026): a database stamped with another schema version, or a
missing or invalid config file (bunryu.json, srs.conf, goryu.json), makes the
app print why and exit with status 78 (EX_CONFIG). bunryu.service sets
RestartPreventExitStatus=78, so it stays failed instead of restarting.
Why: the units set StartLimitIntervalSec=0 so a crashing service always comes
back, and that would turn an error only a person can fix into a restart every 2 s,
filling the 1 GB journal with the same message and pushing out older, useful logs.
Verified on systemd 259 with throwaway units: exit 78 stays failed with no
restarts, and any other exit keeps restarting. SRS and the relay Require the app,
so they stay down too, and nothing accepts a publish it cannot authorize.
The installer reads the database's stamp (byte 60 of the SQLite header, so it needs
neither sqlite3 nor the node modules an update has not rebuilt yet, see
scripts/db-schema-version.sh) after pulling the new code and refuses to continue on a
mismatch unless WIPE_DB=y (or Enter at its default-yes prompt) agrees to the wipe, so the failure
shows up at deploy time with the running service untouched. The Docker supervisor
treats 78 the same way: it does not restart the app, does not start SRS or the relay,
and keeps the container up (unhealthy, with the message in docker logs) rather than
exiting into the restart policy, which would repeat the message.
Config files. The three files are read once at startup and kept until the next
restart, so a wrong one has to be found at that moment, before any module uses it.
Before this, a broken bunryu.json crashed and restarted every 2 s forever, a
missing srs.conf left the dashboard half working (/api/config answered 500), and
a missing or malformed goryu.json silently fell back to the defaults: an empty
passphrase and the default relay ports, with nothing in the log. Only a missing file
or invalid JSON exits 78, because the next attempt would fail the same way. Any
other read error, such as an I/O error, crashes the process and is restarted after 2 s,
so a transient fault cannot leave the server down. Checked on the built app: each of
the three files missing, and an invalid bunryu.json, exits 78 with a timestamped
message naming the file.
The judgment call is goryu.json: it only affects bonded SRT, yet a typo in it
now stops RTMP and plain SRT too, because SRS and the relay require the app.
Accepted because the files change only between events, when a restart shows the
error at once, and one rule for the three files is simpler than a fallback that
hides the fault. The call to read the files has to be the first import of
src/index.ts (startupGate.ts): imports run before the importing module's own
statements, so calls in index.ts would come too late, and one run found the check running after a module that had already
read bunryu.json and crashed with exit 1.
Not adopted:
- A migration path, which AGENTS.md rules out; the schema version only turns a confusing failure into a clear one.
- A dashboard alert with the app running on the wrong database: login, sessions and the SRS publish hook all read that database, so it would need a special mode guarding every route, and an app that is up but cannot work passes liveness checks and lets SRS and the relay start.
- Wiping automatically under
-yor without a terminal: it discards the pipelines and outputs (a backup copy is kept), so it needsWIPE_DB=yor an interactive answer. The prompt defaults to yes because declining only ends the install, but only a person at a terminal can accept it.
Revisit when: a mistyped goryu.json takes down ingest that did not need the relay
(the fallback, with an error logged once, would be the alternative), or another failure
class needs the same treatment.
Keep a fixed 2 s systemd restart delay, with no back-off
Decision (October 2026): the units keep Restart=always, RestartSec=2 and
StartLimitIntervalSec=0. A service that crashes right after it starts is restarted
every 2 s until someone fixes it.
Why:
- The loops that matter are already bounded: an error only an operator can fix exits with 78 and is not restarted, SRS waits for the app's readiness check (up to 60 s) before it starts, and the journal is capped at 1 GB.
- A crash during a live event is back in 2 s. A back-off would only add delay to the case that matters most.
- No crash loop has happened, so there is no incident to size a back-off against.
Not adopted:
RestartSteps=andRestartMaxDelaySec=: they need systemd 254. The production VM runs Ubuntu 22.04 with systemd 249, where a throwaway unit withRestartSec=1,RestartSteps=4andRestartMaxDelaySec=8restarted 21 times in 25 s at a constant gap of about 1.2 s. The directives are silently ignored.- A delay computed in
ExecStartPrefromNRestarts: systemd only resets that counter on a manual start or stop, so a crash a week into an event would inherit the delay. StartLimitIntervalSecandStartLimitBurst: the unit would give up and stay down, which is whatStartLimitIntervalSec=0exists to prevent.
Revisit when: the production VM moves to systemd 254 or later (Ubuntu 24.04 ships
255), or a crash loop fills the journal or loads the host. The Docker supervisor has
the same fixed 2 s delay (docker/entrypoint.sh).
Hints are a dashboard lookup, not an API field
Decision (October 2026): the hints on known errors, warnings and alerts come from patterns in public/ts/core/hints.ts, matched against the text the
server already sends. There is no hint or recommendedAction field in the API.
Why: the advice is presentation (it can change wording without touching the server or its diagnostics), and an API field would be one more thing to document and keep stable. Matching the stderr text is as fragile as the FFmpeg messages it matches, so an unmatched error is shown as it was, with no hint, which costs nothing.
Not adopted: restream-krsna's evidence and recommended_action on every alert,
which needs structured causes the server does not have for FFmpeg output errors.
Revisit when: a client other than the dashboard needs the advice, or a hint should depend on state the dashboard does not have.
Restart outputs when a reconnecting encoder changes format, not when it merely reconnects
Decision (October 2026): after a new publisher's ffprobe succeeds, its format (video codec, resolution, audio track count) is compared with the pipeline's last successful probe. If they differ, the outputs that were running before that publisher connected are restarted, 200 ms apart, at most once per pipeline per minute. Outputs are still not restarted for a plain reconnect.
Why:
- It is a deterministic signal. The decision to never restart on a reconnect rests on there being no reliable way to tell an encoder restart from a network drop (see Reliability). A different format needs no such guess; a stream copy cannot follow it, so a restart repairs something already broken instead of dropping a working destination.
- It reuses the existing re-probe, which already runs once per new publisher, so there is no new polling.
- Failed probes and the first probe never trigger it, since neither shows a change.
- The cooldown bounds it, so an encoder that alternates formats does not cause a restart storm. A change inside the cooldown restarts the outputs when it ends, rather than being skipped: an encoder that reconnected twice within a minute (to a new format and back) otherwise left the outputs restarted for the first change on its stale header until something else restarted them.
Not adopted: restarting on a frame-rate or bitrate change (copy outputs carry both);
restarting every output on every new publisher (the rejected approach above); a
bunryu.json switch (the restart only fires on a stream that was already breaking).
Revisit when: a format change turns out not to need a restart for some destination type, or probes after a reconnect prove unreliable enough to report a change that did not happen.
Measure the keyframe interval once per publisher, in a second ffprobe, and only report it
Decision (October 2026): 60 s after a publisher's first successful probe, a second
ffprobe -select_streams v:0 -show_entries packet=pts_time,dts_time,flags -read_intervals %+12
reads 12 s of video packets and measures the gaps between keyframes. The result is
input.keyframes in /api/health, a Keyframes row in the pipeline panel and a
diagnostics event. A longest gap over 4.25 s raises the input-keyframe-interval
warning alert. Nothing is restarted or rejected.
Why:
- A long keyframe interval is an encoder setting that breaks a destination without any error on our side: YouTube needs a keyframe at least every 4 s and recommends 2 s, and copy-mode outputs forward the gaps unchanged. Before this nothing showed the interval, and the only trace was a slow preview start (a documented side effect). krsna's flight recorder judges the same thing continuously.
- Once per publisher is enough and cheap. The interval is an encoder setting, so it is fixed until the encoder is reconfigured or reconnects, and a reconnect is a new publisher and is measured again. Demuxing only: 0.03 s of CPU for the whole window on a 1080p50 6 Mbit/s clip.
- 60 s after the probe, not right away. Measured straight after connecting, a
chained input showed a start-up transient as if it were its setting. On 2026-10-26 a
pipeline fed by another pipeline's output read 5 keyframes in 12 s, mean 2.5 s and
longest 4.0 s (one keyframe missing), while its source was still recovering from a
reconnect (the shared encode restarted every ~6 s with
non-existing PPS 0 referenced); minutes later both read a clean 2 s GOP, but the value stayed on the panel until the next reconnect. Waiting means one measurement of a settled stream, not a second one to correct the first. It also spreads the checks after a mass reconnect. - A second ffprobe, not a longer first one. Reading packets for 12 s in the first probe would delay the media state and the input-format check that restarts outputs, both of which depend on it.
- Checks run at most 4 at a time. A live input is read in real time, so a check
holds its ffprobe for about 10 to 12 s, and it has about 12 MB of private memory
(measured from
/proc/<pid>/smaps_rollup; the rest of its 29 MB RSS is the shared binary). After a mass reconnect the 200 ms probe stagger would start about 50 at once, which is about 600 MB on a host that has been 1 GB. The queue drops a job whose publisher changed while it waited. - 12 s and 4.25 s. 12 s holds at least two keyframes for any interval up to 4 s with margin; 4.25 s is the platform limit plus frame-rate rounding. A window under 10 s (the stream ended while it was read) cannot raise the alert.
Evidence: the test stack's publisher at -g 50 (2 s) measured 6 keyframes, mean and
longest 2.0 s, no alert, in 10.6 s; republished at -g 150 it measured 2 keyframes,
longest 6.0 s, and raised the alert. Unit tests cover the parsing (2 s, 4 s, 6 s,
one keyframe, none, a cut-short window, N/A timestamps), the alert, once per
publisher, the 60 s wait (and a publisher that changes during it), a failed check,
shutdown killing an in-flight check and the concurrency limit; removing the limit, the
wait or the shutdown kill fails its test. The 2 s and 6 s runs above were made with
the check running right after the probe; with the wait, the end-to-end run below.
Not adopted: measuring right after connecting and again later if the result looks irregular (two probes, and a rule for "irregular"); a continuous check (a snapshot is what an encoder setting needs, and a rolling one needs a long-lived reader per input); an alert at 2 s (platforms recommend it, only 4 s is a limit); measuring from the SRS log or the live packets of the outputs (neither carries keyframe flags).
Revisit when: an encoder is found changing its keyframe interval mid-stream (re-measure periodically), 60 s turns out too short for a source that takes longer to settle, or the 4-at-a-time queue makes the result arrive too late on a very large reconnect.
Re-probe an input when an output's watchdog finds it stuck, not on a timer
Decision (November 2026): an input is probed once per publisher, and again only when
one of its outputs is killed by the "no input data" or "output progress stalled"
watchdog while the input's last probe passed. The output service records the kill
(takeInputFault), the health poll takes it, and the probe scheduler runs one ffprobe at
once (suspect()), at most once per pipeline per 5 minutes. A failing result turns the
input red (probe_failed in the pipeline log, media-probe-failed and a
media-probe-requested event with reason: "output-watchdog"), and the ordinary 30 s
retry then watches for its recovery. Outputs are not gated on the result: they keep
retrying as before, so they come back on their own as soon as the input does.
Why: an SDI encoder whose source is switched off keeps sending constant-bitrate SRT
with nothing decodable in it. On 2026-11-24 the Tamil input stayed green (mediaOk: true
from the probe made when it connected) for over 30 minutes while its YouTube output failed
34 times with "No input data". SRS read 50 MB in 48 s into that output's FFmpeg, which
found streams with no codec parameters; a manual ffprobe pull returned nothing in 20 s.
Evidence: on a test pipeline through the SRT relay, the minutes before and after the
source was removed were identical at the SRT level: 51.76k to 51.77k packets per minute
before, 51.76k after, 1316 bytes each, a 9.3 Mbps receive rate, leg health ok. So
neither the input bitrate, SRS's counters (frames and the codecs are always 0 or null for SRT)
nor the relay's statistics (SRT counters only; it does not read the TS) can tell. The
three outputs of that pipeline were killed by the watchdogs, two for no input data and one
for a progress stall, within a minute of each other. Unit tests cover which kills count,
that a fault is taken once and dropped after 30 s, the 5 minute limit, a probe that
is running, failing or not done yet, and the poll's call.
Not adopted: a periodic ffprobe of every input (removed in July for its CPU and SRT play churn; a period short enough to be useful costs the most on the many healthy inputs, and a long one detects late); counting TS packets per PID in the relay (cheap in C, and it would detect within seconds, but only for relay inputs, and what this encoder sends on signal loss is not known yet); gating output starts on the probe (a probe that fails on a good input would leave an output that should be running down).
Limits: it needs a running output, so an input with none stays green; a stall caused by the destination also triggers one probe, which passes and changes nothing.
Revisit when: a source is found that loses its payload while its outputs keep making progress, or detection after about one watchdog window (50 to 60 s) is too slow.
Warn about interlaced input, do not convert or refuse it
Decision (November 2026): when ffprobe reports the publisher's video as interlaced
(field_order tt, bb, tb or bt), the pipeline gets an input-interlaced
warning alert with the scan (1080i25tff) and the advice to send progressive. Nothing
is restarted, de-interlaced or rejected. The output card's status dot also lists its
problems on hover, and a yellow dot always has a line on the card.
Why:
- YouTube does not support interlaced video. Its help page "Live streaming error messages" lists "The current video is interlaced, but interlaced video is not supported" and says to send progressive video, otherwise "you will see artifacts on the video which severely impact the quality". It does not say whether the video is shown, deinterlaced or dropped, and RTMP itself carries H.264 without a scan type, so the stream is accepted on ingest.
- A warning matches the other input faults (keyframe interval, frame rate): an encoder setting only the operator can fix, shown on the input where they look.
- The yellow dot had no text because the card listed only the warnings the output reported itself, not the verdict behind the dot.
Not adopted: de-interlacing in copy mode (it is a video encode, which is the cost the copy path avoids); refusing the publish (an interlaced input is valid for SRT destinations).
Revisit when: an interlaced input is found that plays fine on YouTube, which would make the alert noise.
Copying a configuration to another server matches by pipeline name, so names are unique
Decision (November 2026): Settings' Copy / Paste configuration puts the groups, the pipelines with their group and their outputs on the clipboard, and a paste adds to another server what it lacks. Groups and pipelines are matched by name, ignoring case, which is why pipeline names are now unique (creating or renaming to a taken name is a 409; a database from before may still hold two with one name and keeps working, as saving a pipeline's own name is never refused). An existing pipeline keeps its group, or gets the pasted one when it has none; its outputs are added by the same rule as pasting outputs (a destination it already uses is skipped). Stream keys are not copied: every server has its own, and a new pipeline takes the next free one.
Why the last key when the keys run out: skipping the pipelines would drop outputs silently, and refusing the whole paste leaves the operator with nothing. A new pipeline on a key another pipeline already has is allowed on purpose (see the stream key rule in the pipeline API) and the dashboard flags the two pipelines, so the operator sees it and decides; the paste's message says how many pipelines were affected.
Why the dashboard applies it: every step is an existing call (save groups, create a
pipeline, bulk-create outputs), so the server has no new endpoint beyond an optional body
on POST /api/pipelines. It validates the whole clipboard first (names, outputs, the group
limit) and then applies it pipeline by pipeline; a step the server refuses is counted and
shown and the rest go on, because a database transaction across pipelines would need a new
endpoint for a rare case. The clipboard holds destination URLs and passphrases, like the
copy of one pipeline's outputs.
Revisit when: a paste should also carry the pipelines' order, or a failure partway through shows up in practice.
Ingest protection
Don't ban abusive ingest clients with fail2ban
Decision: the repo does not install or manage fail2ban. The app logs rejected
on_publish and on_play attempts (publish rejections throttled per key), and
that is where the built-in protection stops.
Why:
- It was tried and removed. Earlier versions used fail2ban as a narrow RTMP/app-hook protection. It added root-owned config, sudo helper scripts, a dashboard whitelist/status UI and extra test surface, and still left the most important gap, SRT, uncovered.
- Neither SRT listener logs a bad-passphrase rejection in a form fail2ban could
act on:
- SRS's SRT server (port
10080) rejects a handshake that fails itspassphrasecheck, either because the peer declares no encryption or becauseSRTO_ENFORCEDENCRYPTIONfails the key exchange. The rejection happens inside the SRT handshake, beforesrt_accept()returns, so SRS's own log (ERROR:UNSECURE/ "Password required or unexpected") never records the peer's IP. goryu's listener (port10081) used to log a matchable[srt-relay] rejected connection (bad passphrase) from <HOST>line from its ownsrt_accept()KMSTATE check, and a dedicated jail watched it. As ofgoryuv2.1.0 that line is no longer logged, so a jail would have nothing to match.
- SRS's SRT server (port
- The part that can be matched is only a partial defense. The logged rejected-publish lines would be enough for a jail on repeated bad RTMP stream-key attempts from one IP. That does not cover SRT bad passphrases, does little against distributed attackers, and is no substitute for an edge or firewall deployment at a high-risk event.
- Brute force is not a practical risk. The passphrase is a long random string and each guess needs a live SRT handshake round trip, so online guessing is computationally infeasible whether or not anyone is banned. The real effect is log and CPU noise from a misconfigured device or scanner that retries forever.
What to do instead: for small events rely on strong stream keys, a strong SRT
passphrase and the non-default RTMP port (21935). For larger or higher-risk
events keep the origin private and put a media-aware ingest edge or a provider
firewall/DDoS layer in front of it.
Revisit when: SRS or goryu logs a rejected SRT peer's IP in a matchable
form, or an incident shows repeated bad-key or bad-passphrase attempts causing
real load.
Install and secrets
The initial dashboard password is supplied, never kept in a file (the Docker image generates one); the app config lives in /etc/bunryu
Decision (October 2026, password storage November 2026): a fresh install must be
given the initial dashboard password: the installer asks for it, or takes
BUNRYU_DASHBOARD_PASSWORD when unattended. Without one it stops before changing
anything. A run that keeps the database needs none. The Docker image is the one exception
(December 2026): on an empty /data volume without BUNRYU_DASHBOARD_PASSWORD the
entrypoint generates a random password, hands it to the app through the environment
and prints it once in the container log. A password the operator supplies is still
never logged. Only the scrypt hash is stored, in the
database, by the set-password command (dist/setPassword.js), which
server-set-password.sh also runs to recover a forgotten password. bunryu.json moved
from /opt/bunryu to /etc/bunryu, and the app finds it through BUNRYU_CONFIG
(unset means ./bunryu.json, so dev checkouts are unchanged). The installer and the
Docker entrypoint set only port and the file paths in that file and keep every other
key.
Why:
- Install output is copied. The old installer printed a generated password at
the end, and the container logged one. Startup scripts, SSH session logs,
docker logsand pasted tickets all kept it. A password the operator chose is never shown. - A password kept in a file outlives its use. It is needed once, to set the hash,
yet a copy in
bunryu.jsonstayed in config backups and copies of/etc/bunryulong after it was changed in Settings. Setting the hash directly leaves nothing to leak, and recovery is one command instead of editing the file and then resetting. - The file was inside the git checkout.
bunryu.jsonis tracked, so the installer'sgit reset --hardrestored the repo copy and lost any value the installer had put there.srs.confandgoryu.jsonwere already in/etc/bunryu, which is why the SRT passphrase survived reinstalls. The app config now sits beside them. - Failing early beats a default. The app used to fall back to the public
adminwhen it had no password to seed an empty database with, so a wiped database or a hand-made config could silently create that login. It now exits with status 78 instead, and the installer and the entrypoint check first and say how to fix it. Onlynpm run devsuppliesadmin, for development. - Hand edits must survive an update. The installer used to write the whole
file from a template, so a value an operator added, such as
trust_proxybehind the Cloudflare Tunnel (without it every user shares one login rate-limit bucket), was lost on the next update without a message. Its template values equalled the app's own defaults, so rewriting them changed nothing except undoing edits. It now sets only what it has to (port, which the units' readiness check hardcodes, and the file paths) and keeps every other key.
Not adopted:
- Carrying over a named list of keys (first the password, then
trust_proxy): every setting someone needs next would need adding to the list. - The same merge for
srs.confandgoryu.json: they are refreshed from the repo on purpose, because the app, the units and the docs assume their hook URLs, ports and SRT settings. Only the SRT passphrase is kept. - Generate and print once, for the native install, the previous behavior: the leak above. It is kept only for Docker (see the exception in the decision).
- A first-run "choose a password" page in the dashboard, for Docker: nothing would be logged, but until someone claims it anyone who reaches port 8080 could set the password, which matters on a demo VM. A printed password has no such window and needs no new unauthenticated route.
- A prompt when the container has a terminal (
docker run -it): it does not work withdocker compose up -dor a detacheddocker run, the usual ways to start it. - Generate and write only to the file: the operator would then have to read a root-only file to log in, and the password would stay there in plain text.
- The app removing the password from the file after seeding: the app would rewrite the operator's config, and it cannot remove an environment variable.
Why Docker differs (December 2026): the image is for trying Bunryu, and a first run
that stops with an error until the user finds the right -e flag is a poor first
experience. The leak the rule guards against is smaller there: a throwaway evaluation
container, not a server whose install log goes into tickets. The password is printed
once, on the start that creates the database, and only an empty volume triggers it, so
a restart never prints it again. A short supplied password still stops the start.
Tradeoffs: the generated password stays in the container log (docker logs, the
json-file driver's rotation) until the container is removed, so a demo that is kept
should change it in Settings. BUNRYU_DASHBOARD_PASSWORD stays in the container
environment after the first start, supplied or generated, so that every restart seeds
nothing new (the app only seeds an empty database).
Revisit when: a second secret needs the same handling, or the Docker image is
used for real deployments and docker secret support matters.
SRS and Goryu run as their own user in a locked-down unit
Decision (November 2026): SRS and Goryu run as bunryu-media, with the service
user's group so they can read srs.conf and goryu.json (mode 640) and nothing else of
the app's. Their units hide /var/lib/bunryu (TemporaryFileSystem), make the system
read-only (ProtectSystem=strict), drop every capability, filter system calls to
@system-service, allow only IP, Unix and netlink sockets and add the kernel, device,
namespace and personality protections. SRS writes its pid file to a runtime directory.
The dashboard and FFmpeg stay as bunryu.
Why:
- They are the code reached first from the internet. SRS parses RTMP and SRT, and Goryu SRT, before any stream key is checked. As the service user, a flaw in either could read the database (every destination's stream key) and the dashboard's files.
- Hiding files from one user is not enough. A process may read
/proc/<pid>/rootof any process of its own user, so with one user a sandboxed SRS could still reach the database through the dashboard's process. A second user closes that. - Nothing needs them to share the user. The dashboard reads their CPU and memory from
world-readable
/procfiles and the rest from their local HTTP APIs.
Evidence: a systemd container on Ubuntu 24.04 with the installer's units, the pinned
SRS 6.0-r3 and Goryu: RTMP, direct SRT and SRT through Goryu publish and go live, SRS's
summaries and Goryu's status still answer, and bunryu-media cannot read the database,
bunryu.json or the dashboard's /proc/<pid>/root, nor see its process.
Not adopted:
MemoryDenyWriteExecutefor SRS: the official SRS build marks its stack executable, so every thread stack it starts needs writable and executable memory and SRT fails to listen. Goryu has it.ProcSubset=pid: SRS reads/proc/statand/proc/meminfofor the summaries.- A separate user for each of SRS and Goryu: they read the same SRT passphrase, so splitting them would protect nothing more.
Revisit when SRS is upgraded: check that the new build still starts and accepts SRT under these units, and whether its stack is still executable.
The SRT passphrase is reset from Settings by rewriting both files; the app does not restart SRS or Goryu
Decision (October 2026): Settings has a Reset button, like the stream-key
one, that writes a new random passphrase to srs.conf and goryu.json and shows a
banner until the restart. It is refused (409) while an input is live or an output is not stopped.
It changes files only: SRS and Goryu pick the value up at their next start, which
the operator causes by rebooting the server or restarting the container.
Why:
- Restarting from the app is the riskier code. It would mean signalling SRS and Goryu, waiting for both to answer with a new PID and handling one not returning: about 150 to 250 lines of new process supervision, in the area this project treats as high-risk, for something done between events a few times a year.
- The reset happens between events anyway. With no stream running, a reboot straight afterwards restarts SRS, Goryu and the app together, so the three agree again and nothing needs to be signalled.
- The two files are written together or not at all. Both new contents are built
first, so a file the app cannot parse changes nothing. Each is written to a temp
file in its own directory and renamed, and
srs.confis put back if the second rename fails, so a crash or full disk cannot leave SRS and Goryu with different passphrases (bonded SRT would stop working). The installer already makes/etc/bunryuwritable for the service user, so no unit change was needed. - The dashboard keeps the old value until the restart. The app caches both files at startup, so the publish URLs match what SRS and Goryu enforce rather than a file they have not read yet. An open dashboard picks the new value up by itself after the restart, because the app's config revision starts from the clock on every start.
- The restart reminder is a banner, derived from the files. A note on the Settings
page was gone after a reload and invisible from every other view, and the restart is
the step that matters.
/api/configcompares the passphrases now in the files with those read at startup (srtPassphrasePending), so the banner survives reloads, shows on every open dashboard and clears by itself when the app starts again. It stores no flag that could go stale. If only the app restarts, SRS keeps the old value and the banner still clears, which is why it says to restart the server or container. - The new value is not shown or returned. It could not be used before the restart anyway, so showing it would only put the secret on screen and in a response. The dashboard's copy buttons give it after the restart.
Not adopted:
- Restarting SRS and Goryu from the app: see above. Resets are not needed during an event today.
- Clearing the cache so the dashboard shows the new value at once: the direct and bonded URLs would then show a passphrase nothing enforces yet, and a stray SRS crash or watchdog restart would silently apply it in the middle of an event.
Tradeoffs: a reset that is not followed by a restart leaves the new value armed on disk: any unplanned restart of SRS or Goryu applies it, and every encoder with the old URL then fails at the SRT handshake. The dialog and the Settings text say to restart straight away. If only one of the two services restarts, it and the other disagree until the second does too.
Revisit when: a reset is needed while streams are running.
Checked on the isolated test stack: a reset with a live input and four running
outputs returned 409 and left both files byte-identical; after stopping them it
returned 200, both files held the same 32-character value and no temp file
remained, the API still showed the old value with srtPassphrasePending changed from
false to true, the banner showed on the Overview, and the log and diagnostics
recorded srt-passphrase-reset without the value. That the flag clears after a restart
follows from the comparison, which unit tests cover; it was not run through a restart.
The Docker image is x86_64 only; ARM hosts run it emulated, for development
Decision (October 2026): no native arm64 image. Production is Linux x86_64, and
compose.yaml sets platform: linux/amd64, so Docker on an Apple Silicon Mac or
other ARM host runs the same image emulated. That is enough to try Bunryu or
develop against it.
Why: production doesn't need ARM, and two of the three pinned binaries have no
arm64 build to pin: goryu's releases are x86_64 only, and the FFmpeg 7.1 we mirror
has no arm64 counterpart (BtbN now builds arm64 only for 8.1 and later; FFmpeg 8.0.1
stalled pulling SRT from SRS on a development machine). SRS does publish an arm64
ossrs/srs:v6.0-r2. The emulated run was not tested, because the development host
is x86_64.
Tradeoffs: emulated timing and CPU say nothing about real capacity, so the sizing numbers are x86_64 only.
Revisit when: developers need to debug media behavior on ARM, or production
moves to arm64 VMs. It needs an FFmpeg 7.1 arm64 build mirrored like the amd64 one,
an arm64 goryu release, the arm64 SRS from ossrs/srs, and a multi-platform image
build.