RelayrtcDocs
Get started
Documentation
Streaming

Live streaming

Build a live program from a room or encoder, then deliver, record and distribute it.

On this page

RelayRTC turns a room, WHIP publisher or RTMP encoder into a private HLS program. Use broadcasts to manage individual events, distribute that program to external platforms, and retain media for recordings, clips or DVR.

Before you start

The standard RelayRTC installation includes streaming, its source and output workers, an ingest gateway and private object storage. See streaming configuration for addresses and verification. Keep the API, workers and SDKs on compatible builds. Streaming methods described here extend the older npm packages listed in installation; check the installed SDK's exports before integrating them.

All Node examples use the server-only relay client from quickstart. They run behind your application's authentication and resource authorization. Never expose a management key to an encoder or viewer.

Use an environment-scoped key with only the permissions your backend needs: streams:read for status, streams:write for configuration and broadcast commands, streams:publish for ingest credentials, and streams:playback for viewer grants. Recording operations use recordings:create and recordings:read. Guest grant issuance also needs tokens:create.

Choose a source

SourceUse it forHow media starts
RoomCalls, interviews and guest stagesParticipants publish RTC tracks; your backend starts the source
WHIPA compatible WebRTC encoderEncoder connects with an ingest credential
RTMPOBS and other RTMP encodersEncoder connects with an ingest credential

An external source can also pull an authorized HLS feed into an RTMP-backed stream.

Create a room stream

After creating a room and publishing its tracks, call this backend helper with the room ID stored by your application:

TypeScript
import { relay } from './relay.js'
 
export async function createRoomStream(roomId: string) {
  const stream = await relay.streams.create({
    name: 'Town hall',
    source: { kind: 'room', roomId },
    profile: { width: 1280, height: 720, fps: 30 },
    maxDurationSeconds: 14400,
  })
  const operation = await relay.streams.start(stream.id)
  return { stream, operation }
}

Save both IDs. A start response accepts work; poll streamingOperations.get(operation.id) and streams.getPlayback(stream.id) to follow progress. A connected publisher is not proof that viewers can play video: check readiness.viewerReady and the returned playback state.

Streams and broadcasts

A stream holds reusable source and encoding configuration. A source session represents an ingest/encoding attempt. A broadcast is one event with a saved source/profile/destination configuration and its own lifecycle. Create a new broadcast for each event; a terminal run cannot restart.

Stopping a broadcast stops its outputs, while preserving its source. Stopping the source interrupts dependent media and revokes source playback access. Deleting a stream also retires its dependent resources and assets.

Build your workflow

  1. Connect a room or encoder, then confirm source readiness.
  2. Create and start a broadcast.
  3. Authorize viewers for private playback.
  4. Add destinations, recordings, clips or DVR.
  5. Use schedules, a mixer or guest stage when the event needs them.

Media and limits

The canonical program is single-rendition H.264/AAC fragmented MP4. Default encoding is 1280 × 720 at 30 fps, 2.5 Mbit/s video and 128 kbit/s audio. Audio-only programs are supported. This is not a per-viewer adaptive quality ladder.

Stream duration defaults to four hours and can be configured from one minute to 24 hours. Admission also depends on deployment quotas and available worker capacity. Source, broadcast, destination, recording and viewer delivery measurements describe different work; consult usage before combining them.