Stream Out (Egress)

Stream your BaxCloud rooms to YouTube, Twitch, Facebook Live, or any custom RTMP destination

Overview

BaxCloud Egress allows you to stream the contents of a room to external RTMP destinations like YouTube Live, Twitch, Facebook Live, or any custom RTMP server. You can also record rooms to cloud storage. Egress supports customizable layouts, quality presets, and simultaneous multi-destination streaming.

Multi-Platform

Stream to YouTube, Twitch, Facebook, and custom RTMP servers simultaneously.

Custom Layouts

Grid, speaker, PiP layouts. Full control over the composed video output.

Record + Stream

Record to cloud storage and stream externally at the same time.

Stream Out Modes

Record Only (mode: 'record')

Record the room to cloud storage as MP4, OGG, or WebM. The recording is saved to BaxCloud's S3-compatible storage and can be downloaded later via the API or dashboard.

Stream Only (mode: 'stream')

Stream the room to one or more RTMP destinations. No file is saved — the stream goes directly to YouTube, Twitch, Facebook Live, or your custom RTMP endpoint.

Both — Record + Stream (mode: 'both')

Record to cloud storage AND stream to external destinations simultaneously. Perfect for creating archives while broadcasting live to social platforms.

Layout Options

Choose how participants appear in the composed output:

Grid

All participants displayed in equal-sized tiles. Automatically adjusts grid size (2x2, 3x3, etc.) based on participant count.

Speaker

Active speaker takes the main area. Other participants shown as small thumbnails at the bottom.

PiP (Picture-in-Picture)

Screen share or primary content takes full frame with speaker in a small overlay corner.

Default

Automatic layout that adapts based on content type — uses speaker layout for calls, grid for conferences.

Quality Presets

PresetResolutionBitrateUse Case
480p854x480~1.5 MbpsLow bandwidth, mobile viewers
720p1280x720~3 MbpsStandard streaming (recommended)
1080p1920x1080~6 MbpsHigh quality, webinars
4k3840x2160~15 MbpsPremium, events

SDK Methods

All available egress (stream-out) and recording methods across every SDK

MethodNode.js (Server)React / React NativeFlutterKotlinSwift
Recording
Start recordingstartRecord()startRecord()startRecord()startRecord()startRecord()
Stop recordingstopRecord()stopRecord()stopRecord()stopRecord()stopRecord()
List recordingslistRecordings()listRecordings()listRecordings()listRecordings()listRecordings()
Get recordinggetRecording()getRecording()getRecording()getRecording()getRecording()
Download URLgetRecordingDownloadUrl()getRecordingDownloadUrl()getRecordingDownloadUrl()getRecordingDownloadUrl()getRecordingDownloadUrl()
Stream Out (Egress)
Start stream / record / bothstartStream()startStream()startStream()startStream()startStream()
Stop streamstopStream()stopStream()stopStream()stopStream()stopStream()
Get stream statusgetStreamStatus()getStreamStatus()getStreamStatus()getStreamStatus()getStreamStatus()
List streamslistStreams()listStreams()listStreams()listStreams()listStreams()
Delete streamdeleteStream()deleteStream()deleteStream()deleteStream()deleteStream()
Auto-Stream
Get auto configgetAutoStreamConfig()getAutoStreamConfig()getAutoStreamConfig()getAutoStreamConfig()getAutoStreamConfig()
Update auto configupdateAutoStreamConfig()updateAutoStreamConfig()updateAutoStreamConfig()updateAutoStreamConfig()updateAutoStreamConfig()

startStream() — Start Stream Out

Stream to YouTube, Twitch, Facebook Live, or record to cloud — or both at the same time

1import { BaxCloudClient } from '@baxcloud/server-sdk';
2
3const client = new BaxCloudClient({
4  apiKey: process.env.BAXCLOUD_API_KEY!,
5});
6
7// Stream only — to YouTube Live
8const stream = await client.startStream({
9  roomName: 'my-live-room',
10  mode: 'stream',
11  layout: 'speaker',
12  quality: '1080p',
13  stream: {
14    urls: ['rtmp://a.rtmp.youtube.com/live2/YOUR_KEY'],
15  },
16});
17
18// Record only — to cloud storage
19const recording = await client.startStream({
20  roomName: 'my-live-room',
21  mode: 'record',
22  layout: 'grid',
23  quality: '720p',
24  file: { fileType: 'MP4' },
25});
26
27// Both — record AND stream simultaneously
28const both = await client.startStream({
29  roomName: 'my-live-room',
30  mode: 'both',
31  layout: 'speaker',
32  quality: '1080p',
33  file: { fileType: 'MP4' },
34  stream: {
35    urls: [
36      'rtmp://a.rtmp.youtube.com/live2/YOUTUBE_KEY',
37      'rtmp://live.twitch.tv/app/TWITCH_KEY',
38      'rtmps://live-api-s.facebook.com:443/rtmp/FB_KEY',
39    ],
40  },
41});
42
43console.log('Egress ID:', both.id);
44console.log('Status:', both.status);
💡

Platform RTMP URLs

  • YouTube: rtmp://a.rtmp.youtube.com/live2/STREAM_KEY
  • Twitch: rtmp://live.twitch.tv/app/STREAM_KEY
  • Facebook: rtmps://live-api-s.facebook.com:443/rtmp/STREAM_KEY
  • Custom: Any rtmp:// or rtmps:// endpoint

stopStream() — Stop an Active Stream

Stop a running stream or recording

1const result = await client.stopStream('EG_abc123');
2console.log('Status:', result.status); // → COMPLETED

getStreamStatus() / listStreams()

Monitor active and past streams

1// Get single stream status
2const status = await client.getStreamStatus('EG_abc123');
3console.log(status.status, status.layout, status.quality);
4
5// List all streams
6const { items } = await client.listStreams({
7  roomName: 'my-live-room',
8  status: 'STARTED',
9  page: 1, limit: 20,
10});
11
12for (const s of items) {
13  console.log(`[${s.type}] ${s.roomName}${s.status}`);
14}

startRecord() — Start Recording

Record a room to cloud storage as MP4

1const recording = await client.startRecord({
2  roomName: 'my-live-room',
3  fileType: 'MP4',
4});
5
6console.log('Recording ID:', recording.id);
7console.log('Egress ID:', recording.egressId);
8
9// Stop recording
10await client.stopRecord(recording.egressId);
11
12// Get download URL
13const { downloadUrl } = await client.getRecordingDownloadUrl(recording.id);

updateAutoStreamConfig() — Auto-Stream Configuration

Automatically start recording or streaming when rooms meet criteria

1const config = await client.updateAutoStreamConfig({
2  enabled: true,
3  mode: 'record',
4  layout: 'speaker',
5  quality: '720p',
6  minParticipants: 2,
7  delaySeconds: 10,
8  roomNamePattern: 'meeting-*',
9});
10
11const current = await client.getAutoStreamConfig();
12console.log('Auto-stream enabled:', current.enabled);

Webhook Events

Receive real-time notifications for stream and recording lifecycle events

BaxCloud sends webhook events for stream and recording lifecycle changes. Configure webhooks in your project dashboard settings. Events use clear naming:

EventCategoryDescription
Recording Events
recording.startedRecordCloud recording has started for a room
recording.completedRecordRecording finished successfully, file available
recording.failedRecordRecording failed (error details in payload)
Stream Out Events
stream.startedStream OutRTMP stream to external platform started (YouTube, Twitch, etc.)
stream.updatedStream OutStream status changed (e.g., RTMP destination connected)
stream.completedStream OutStream to external platform completed
stream.failedStream OutStream to external platform failed
Stream In Events
live.startedStream InIngress stream from OBS/encoder started
live.endedStream InIngress stream ended
live.failedStream InIngress stream failed
1// recording.started
2{
3  "event": "recording.started",
4  "timestamp": "2026-03-29T14:30:00Z",
5  "data": {
6    "recordingId": "rec_abc123",
7    "egressId": "EG_abc123",
8    "roomName": "my-live-room",
9    "type": "record",
10    "quality": "720p",
11    "layout": "speaker"
12  }
13}
14
15// stream.started
16{
17  "event": "stream.started",
18  "timestamp": "2026-03-29T14:30:00Z",
19  "data": {
20    "egressId": "EG_abc123",
21    "roomName": "my-live-room",
22    "type": "stream",
23    "quality": "1080p",
24    "layout": "speaker",
25    "destinations": [
26      "rtmp://a.rtmp.youtube.com/live2/***",
27      "rtmp://live.twitch.tv/app/***"
28    ]
29  }
30}
31
32// recording.completed
33{
34  "event": "recording.completed",
35  "timestamp": "2026-03-29T15:30:00Z",
36  "data": {
37    "recordingId": "rec_abc123",
38    "egressId": "EG_abc123",
39    "roomName": "my-live-room",
40    "status": "COMPLETED",
41    "durationSec": 3600,
42    "fileUrl": "https://storage.baxcloud.io/recordings/rec_abc123.mp4",
43    "fileSize": 104857600
44  }
45}
46
47// stream.failed
48{
49  "event": "stream.failed",
50  "timestamp": "2026-03-29T14:35:00Z",
51  "data": {
52    "egressId": "EG_abc123",
53    "roomName": "my-live-room",
54    "status": "FAILED",
55    "errorMessage": "RTMP connection refused by destination",
56    "errorCode": "RTMP_CONNECTION_REFUSED"
57  }
58}

REST API Reference

MethodEndpointDescription
POST/v1/egress/startStart a stream, recording, or both
POST/v1/egress/:id/stopStop an active stream or recording
GET/v1/egressList all streams and recordings
GET/v1/egress/:idGet stream/recording details
DELETE/v1/egress/:idDelete a stream record
POST/v1/recordings/startStart a cloud recording
POST/v1/recordings/:egressId/stopStop a cloud recording
GET/v1/egress/auto-egressGet auto-stream configuration
PUT/v1/egress/auto-egressUpdate auto-stream configuration