OBS and SRT
Publish from OBS or a hardware encoder over SRT, with the address, the encoder settings and troubleshooting.
SRT is the recommended way in. The ingest turns the stream into MoQ for the relays without re-encoding, and also packages it as LL-HLS for the fallback. Each stream has one stream key, in the addresses the API gives you. Other routes: RTMP, WHIP, ffmpeg, the Nearglass command, a device. To pick one, see Choose how to publish.
The addresses
POST /v1/streams answers publish once, with the key in it:
"publish": {
"stream_key": "stk_...",
"srt": "srt://ingest.nearglass.com:9000?streamid=stk_...",
"rtmp": "rtmp://ingest.nearglass.com:1935/live/stk_..."
}GET /v1/streams/{id} later shows the stream without its key. Lost it, or
an encoder you no longer trust? POST /v1/streams/{id}/stream-key makes a
new one and ends the live session that used the old one. (A stream created
with "ingest":["sdk"] only has no stream key: see Devices.)
Which protocols a stream takes is its ingest list (default ["rtmp", "srt"]); an encoder on any other is refused. One encoder publishes a stream
at a time: a second with the same key is refused while the first is sending,
and takes over after 5 s without data from the first.
The streamid can be the bare key, as in the address above, or in SRT's
access control form, #!::r=stk_...,m=publish.
Settings that matter
The same rules for every encoder:
| Setting | Value | Why |
|---|---|---|
| Keyframe interval | 1 s (2 s at most) | a viewer starts at a keyframe, so it sets how long a join takes |
| B-frames | 0 | a B-frame waits for a later frame: at least a frame of delay |
| Rate control | CBR | steady frame sizes show congestion early, not in bursts |
| Bitrate | at most 70 % of the measured uplink | room for retransmissions |
| Codec | H.264, High or Main profile (Baseline on old hardware) | what browsers decode |
| Audio | AAC-LC or Opus, mono or stereo | see Audio |
SRT latency. SRT holds packets for a latency window to retransmit lost ones. Guidance: 4 times the round trip to the ingest. The ingest's side defaults to 120 ms, and a session uses the larger of the two sides' values. A short window on a lossy uplink shows as stutter; a long one is delay you add.
OBS
Settings, Stream: Service "Custom...", Server: the whole srt address,
Stream Key: empty.
Settings, Output, Output Mode "Advanced", Streaming:
- x264: Rate Control "CBR", Keyframe Interval "1", Tune "zerolatency"
(or
bframes=0in "x264 Options"). - NVENC: Keyframe Interval "1", Rate Control "CBR", "B-Frames" 0 (it defaults to 2 on GPUs that have them), Tuning "ll" or "ull", Look-ahead and Multipass off.
SRT latency in OBS: add &latency= to the server address, in
microseconds (OBS passes it on as microseconds), for example
&latency=200000 for 200 ms.
Sound: OBS's default audio encoder, AAC, is carried; the ingest turns it into Opus. Keep it AAC-LC (not HE-AAC), mono or stereo.
Hardware encoders and vMix
The same rules: keyframe interval 1 s, no B-frames, CBR, and the encoder's
SRT caller settings pointed at the host, port and streamid of the address
above.
- vMix (Streaming Quality): "Keyframe Frequency" 1, "Strict CBR" on, "Network Buffer" small. SRT is in vMix since version 23.
Checking that it arrived
curl -s $API/v1/streams/$ID/stats -H "Authorization: Bearer $SK"ingest_token_at is when the ingest last connected this stream to the
relays: it is set within a few seconds of the encoder starting. Then open a
page with the player (Quickstart, step 4).
| Symptom | Likely cause |
|---|---|
| The encoder cannot connect over SRT ("access denied" or a handshake timeout) | the streamid is not the stream key, or the stream does not take srt |
| Connected, but the player waits at "Connecting..." | the stream key was rotated or the stream deleted; or the video is not H.264 |
| The picture stutters every few seconds | SRT latency too short for the uplink, or a bitrate near the uplink's limit |
| Joining takes several seconds | the keyframe interval is long: set it to 1 s |
| Picture, but no sound | the encoder sends HE-AAC, more than two channels, MP3 or AC-3: send AAC-LC or Opus, mono or stereo (Audio) |
| Sound came on only after the encoder reconnected | the encoder announced its audio after its first video frame; the stream's track list is set when it starts |