Skip to content

Start a live stream

After you subscribe to Stream, you can create Live Inputs in Dash or via the API. Broadcast to your new Live Input using RTMPS or SRT. SRT supports newer video codecs and makes using accessibility features, such as captions and multiple audio tracks, easier.

First time live streaming? You will need software to send your video to Cloudflare. Learn how to go live on Stream using OBS Studio.

Use the dashboard

Step 1: Create a live input via the Stream Dashboard.

Create live input field from dashboard

Step 2: Copy the RTMPS URL and key, and use them with your live streaming application. We recommend using Open Broadcaster Software (OBS) to get started.

Example of RTMPS URL field

Step 3: Go live and preview your live stream in the Stream Dashboard

In the Stream Dashboard, within seconds of going live, you will see a preview of what your viewers will see. To add live video playback to your website or app, refer to Play videos.

Use the API

To start a live stream programmatically, make a POST request to the /live_inputs endpoint:

Request
curl -X POST \
--header "Authorization: Bearer <API_TOKEN>" \
--data '{"meta": {"name":"test stream"},"recording": { "mode": "automatic" }}' \
https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/live_inputs
Response
{
"uid": "f256e6ea9341d51eea64c9454659e576",
"rtmps": {
"url": "rtmps://live.cloudflare.com:443/live/",
"streamKey": "MTQ0MTcjM3MjI1NDE3ODIyNTI1MjYyMjE4NTI2ODI1NDcxMzUyMzcf256e6ea9351d51eea64c9454659e576"
},
"created": "2021-09-23T05:05:53.451415Z",
"modified": "2021-09-23T05:05:53.451415Z",
"meta": {
"name": "test stream"
},
"status": null,
"recording": {
"mode": "automatic",
"requireSignedURLs": false,
"allowedOrigins": null,
"hideLiveViewerCount": false
},
"deleteRecordingAfterDays": null,
"preferLowLatency": false
}

Optional API parameters

API Reference Docs for /live_inputs

  • preferLowLatency boolean default: false Beta

    • When set to true, this live input will be enabled for the beta Low-Latency HLS pipeline. The Stream built-in player will automatically use LL-HLS when possible. (Recording mode property must also be set to automatic.)
  • deleteRecordingAfterDays integer default: null (any)

    • Specifies a date and time when the recording, not the input, will be deleted. This property applies from the time the recording is made available and ready to stream. After the recording is deleted, it is no longer viewable and no longer counts towards storage for billing. Minimum value is 30, maximum value is 1096.

      When the stream ends, a scheduledDeletion timestamp is calculated using the deleteRecordingAfterDays value if present.

      Note that if the value is added to a live input while a stream is live, the property will only apply to future streams.

  • timeoutSeconds integer default: 0

    • The timeoutSeconds property specifies how long a live feed can be disconnected before it results in a new video being created.

The following four properties are nested under the recoring object.

  • mode string default: off

    • When the mode property is set to automatic, the live stream will be automatically available for viewing using HLS/DASH. In addition, the live stream will be automatically recorded for later replays. By default, recording mode is set to off, and the input will not be recorded or available for playback.
  • requireSignedURLs boolean default: false

    • The requireSignedURLs property indicates if signed URLs are required to view the video. This setting is applied by default to all videos recorded from the input. In addition, if viewing a video via the live input ID, this field takes effect over any video-level settings.
  • allowedOrigins integer default: null (any)

    • The allowedOrigins property can optionally be invoked to provide a list of allowed origins. This setting is applied by default to all videos recorded from the input. In addition, if viewing a video via the live input ID, this field takes effect over any video-level settings.
  • hideLiveViewerCount boolean default: false

    • Restrict access to the live viewer count and remove the value from the player.

Manage live inputs

You can update live inputs by making a PUT request:

Request
curl --request PUT \
https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/live_inputs/{input_id} \
--header "Authorization: Bearer <API_TOKEN>" \
--data '{"meta": {"name":"test stream 1"},"recording": { "mode": "automatic", "timeoutSeconds": 10 }}'

Delete a live input by making a DELETE request:

Request
curl --request DELETE \
https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/live_inputs/{input_id} \
--header "Authorization: Bearer <API_TOKEN>"

Recommendations, requirements and limitations

Recommendations

  • Your creators should use an appropriate bitrate for their live streams, typically well under 12Mbps (12000Kbps). High motion, high frame rate content typically should use a higher bitrate, while low motion content like slide presentations should use a lower bitrate.
  • Your creators should use a GOP duration (keyframe interval) of between 2 to 8 seconds. The default in most encoding software and hardware, including Open Broadcaster Software (OBS), is within this range. Setting a lower GOP duration will reduce latency for viewers, while also reducing encoding efficiency. Setting a higher GOP duration will improve encoding efficiency, while increasing latency for viewers. This is a tradeoff inherent to video encoding, and not a limitation of Cloudflare Stream.
  • When possible, select CBR (constant bitrate) instead of VBR (variable bitrate) as CBR helps to ensure a stable streaming experience while preventing buffering and interruptions.

Low-Latency HLS broadcast recommendations Beta

  • For lowest latency, use a GOP size (keyframe interval) of 1 or 2 seconds.
  • Broadcast to the RTMP endpoint if possible.
  • If using OBS, select the “ultra low” latency profile.

Requirements

  • Closed GOPs are required. This means that if there are any B frames in the video, they should always refer to frames within the same GOP. This setting is the default in most encoding software and hardware, including OBS Studio.
  • Stream Live only supports H.264 video and AAC audio codecs as inputs. This requirement does not apply to inputs that are relayed to Stream Connect outputs. Stream Live supports ADTS but does not presently support LATM.
  • Clients must be configured to reconnect when a disconnection occurs. Stream Live is designed to handle reconnection gracefully by continuing the live stream.

Limitations

  • Watermarks cannot yet be used with live videos.
  • If a live video exceeds seven days in length, the recording will be truncated to seven days. Only the first seven days of live video content will be recorded.