# Live streaming Build a live program from a room or encoder, then deliver, record and distribute it. 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](/self-hosting) includes streaming, its source and output workers, an ingest gateway and private object storage. See [streaming configuration](/guides/streaming-self-hosting) 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](/installation); check the installed SDK's exports before integrating them. All Node examples use the server-only `relay` client from [quickstart](/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 | Source | Use it for | How media starts | | --- | --- | --- | | Room | Calls, interviews and guest stages | Participants publish RTC tracks; your backend starts the source | | WHIP | A compatible WebRTC encoder | Encoder connects with an ingest credential | | RTMP | OBS and other RTMP encoders | Encoder connects with an ingest credential | An [external source](/guides/external-ingest) 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: ```ts 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](/guides/streaming-ingest), then confirm source readiness. 2. Create and start a [broadcast](/guides/broadcasts). 3. Authorize viewers for [private playback](/guides/streaming-playback). 4. Add [destinations](/guides/multistreaming), [recordings](/guides/recording-and-vod), [clips](/guides/clips-and-replay) or [DVR](/guides/live-dvr). 5. Use [schedules](/guides/scheduled-broadcasts), a [mixer](/guides/cloud-video-mixer) or [guest stage](/guides/live-guests-and-cohosting) 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](/guides/usage) before combining them.