INTEGRITY Cloudflare Docs

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: In the Cloudflare dashboard, go to the Live inputs page and create a live input.

Go to Live inputs ↗ 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
	},
	"enabled": true,
	"deleteRecordingAfterDays": null,
	"preferLowLatency": false
}

Optional API parameters

API Reference Docs for /live_inputs

The following four properties are nested under the recording object.

Manage live inputs

Update a live input

Update a live input 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 }}'

Enable or disable a live input

Live inputs are enabled by default. When a live input is disabled, it rejects incoming RTMPS and SRT connections. Use this to temporarily pause a live input without deleting it, terminate active broadcasts, and prevent new broadcasts from starting on a specific input.

To disable a live input, set enabled to false:

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

To enable the live input again, set enabled to true:

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

Rotate broadcast keys

Rotate the broadcast credentials for a live input when credentials may have been shared with the wrong audience, exposed in client code or a screenshare, or need to be refreshed as part of your security process. Rotating keys does not change the live input ID or its other configuration.

When keys are rotated, old credentials are revoked, broadcasts using stale credentials are disconnected, and refreshed credentials are returned in the API response.

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

Live input responses include keysRotatedAt, which indicates when the live input keys were last rotated. This field is omitted for live inputs whose keys have never been rotated.

Delete a live input

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

If you are experiencing buffering, freezing, experiencing latency, or having other similar issues, visit live stream troubleshooting.

Recommendations

Low-Latency HLS broadcast recommendations Beta

Requirements

Limitations