RTMP Streaming & Browser Recording

Introduction

RTMP Streaming can be used to live stream your video conferencing apps to platforms like YouTube, Twitch, Facebook, MUX, etc. Browser Recording can be used to record your video conferencing apps to a file, for subsequent access. You can start either RTMP Streaming or Browser Recording or both for any room

Pre-requisites

  1. Management token
  1. Single click meeting url to directly enter a room

  2. 100ms SDK logs should be logged to console for the webapp url provided above. The SDK logs will be analysed to detect any room join failures and retries will be attemped to fix the same. If SDK logs are not enabled then the server will stop recording/streaming and return error (after fixed number of retries).

APIs

Start Streaming/Recording

POST
https://prod-in2.100ms.live/api/v2/beam

This endpoint is used to start live streaming/recording

Headers

NameValueRequired
Content-type
application/jsonYes
Authorization
Bearer <management token>Yes

Body Parameters

NameTypeDescriptionRequired
operation
stringMust be "start"Yes
room_id
stringThe room id of the room which we need to start streaming/recordingYes
meeting_url
stringSingle click meeting url which we need to start streaming/recording (see below for more details)Yes
rtmp_urls
arrayList of RTMP output urls to which the meeting will be streamed.
Required when RTMP streaming needs to be started.
Supports upto 3 rtmp:// / rtmps:// urls
No
record
boolFlag to enable browser recordingNo
resolution
objectVideo resolution for streaming/recordingNo
meeting_url

This is a url which lands into the meeting directly. If you are using 100ms apps then this will be like - https://<domain>.app.100ms.live/preview/<room_id>/<role>?skip_preview=true.

There are also a few additional query params which can be used for the 100ms app link -

  • auth_token=token1234: this can be used to pass auth token generated on your side to the recording webapp
  • view_mode=activespeaker: this can be used to open active speaker mode by default for recording. In active speaker mode, the current speaker will show up in center, and rest of the peers will show up in the sidebar.

Example - https://myname.app.100ms.live/preview/61101349d0f56e684b608c08/beam?skip_preview=true&auth_token=token1234&view_mode=activespeaker

resolution
NameTypeDescriptionRequired
width
intWidth of the video.
Range: 480-1280. If height>720 then max width=720.
Default: 1280
Yes
height
intHeight of the video.
Range: 480-1280. If width>720 then max height=720.
Default: 720
Yes

cURL

curl \ --location \ --request POST 'https://prod-in2.100ms.live/api/v2/beam' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <management_token>' \ --data-raw '{ "operation": "start", "room_id": <rooom_id>, "meeting_url": <meeting_url>, "rtmp_urls": [<rtmp_url_1>, <rtmp_url_2>], "record": true, "resolution" : {"width": 1280, "height": 720} }'

Stop Streaming/Recording

POST
https://prod-in2.100ms.live/api/v2/beam

This endpoint is used to stop live streaming/recording

Headers

NameValueRequired
Content-type
application/jsonYes
Authorization
Bearer <management token>Yes

Body Paramters

NameTypeDescriptionRequired
operation
stringMust be "stop"Yes
room_id
stringThe room id of the room for which we need to stop streaming/recordingYes

cURL

curl \ --location \ --request POST 'https://prod-in2.100ms.live/api/v2/beam' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <management_token>' \ --data-raw '{ "operation": "stop", "room_id": <rooom_id> }'

Error messages in RTMP API

MessageCodeDescription
Error: beam already started1RTMP streaming or Recording already running for the room
Error: internal server error2server error
Error: room_id missing3room id is missing in the request payload
Error: room_id invalid4Room id provided is invalid
Error: rtmp_url and record missing5RTMP urls or record flag is required
Error: meeting_url missing6Meeting url is missing in the request payload
Error: meeting_url invalid7Meeting url is invalid
Error: operation invalid8Operation provided is invalid
Error: operation missing9Operation field is missing in the request payload
Error: no active beam found for the passed in identifiers10No Active beam running in the room
Error: Resolution not supported11Input Resolution not Supported

Recording upload destination

By default recordings will be uploaded to 100ms storage and a presigned URL for the same will be provided to customers via a webhook. The presigned url will expire in 12hours. Customers can also configure the recordings to be stored in their cloud storage. The configuration for the same can be provided when creating the room.

Create Room

Recording mp4 will be placed at - s3://<location>/<prefix>/beam/<room_id>/<start_date>/Rec-<room_id>-<epoch>.mp4. Example s3://test-bucket/test-prefix/beam/61101349d0f56e684b608c08/20210721/Rec-61101349d0f56e684b608c08-1626898422000.mp4

Postman Collection