Cloudflare Stream -- Live Streaming Platform
In this tutorial, you'll learn about Cloudflare Stream. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
This tutorial explains how to set up and manage live streaming with Cloudflare Stream, covering RTMPS ingestion, live playback, recording, and the live input management API for broadcast-grade live video.
Why Cloudflare Live Streaming Matters
Live streaming has become essential for webinars, product launches, gaming, and real-time events. Traditional live streaming solutions require dedicated encoding hardware, complex protocol configuration, and multi-CDN management. Cloudflare Stream Live simplifies this by accepting RTMPS input from standard broadcasting software, automatically transcoding to multiple resolutions, and delivering low-latency streams across the global edge network. The same platform records the stream for on-demand replay, eliminating the need for separate recording infrastructure.
Real-world use: Durga Antivirus Pro hosts weekly live security briefings using Cloudflare Stream Live. The team streams from OBS over RTMPS, and Stream delivers the broadcast to thousands of viewers worldwide with under 3 seconds of latency while automatically creating a replay for on-demand viewing.
Live Streaming Architecture
flowchart LR A[Broadcaster OBS] --> B[RTMPS ingestion] B --> C[Cloudflare Stream Live] C --> D[Live transcoding] D --> E[Global edge delivery] E --> F[Viewer 1 HLS] E --> G[Viewer 2 DASH] C --> H[Recording storage] H --> I[On-demand replay] style B fill:#f90,color:#fff style C fill:#f90,color:#fff style E fill:#f90,color:#fff
Creating a Live Input
Before you can broadcast, you need to create a live input. This generates an RTMPS URL and a stream key that your broadcasting software uses to push the stream.
# Create a live input via API
curl -X POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream/live_inputs" \
-H "Authorization: Bearer API_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"meta": {"name": "Weekly Security Briefing"},
"recording": {"mode": "automatic"}
}'
# Expected output:
# {"success":true,"result":{"uid":"live123","rtmpsUrl":"rtmps://live.cloudflare.com:443/live/","streamKey":"sk_abc123def456","recording":{"mode":"automatic"}}
The response includes the RTMPS URL and stream key. The recording.mode: automatic setting tells Stream to save the recording when the broadcast ends.
Broadcasting with OBS
Open OBS Studio and configure it with the RTMPS URL and stream key. OBS is the most popular free broadcasting software and works seamlessly with Cloudflare Stream Live.
# OBS Settings for Cloudflare Stream Live
Settings -> Stream:
Service: Custom
Server: rtmps://live.cloudflare.com:443/live/
Stream Key: sk_abc123def456
# Recommended video settings:
Output Resolution: 1920x1080
Bitrate: 4500 Kbps (for 1080p)
Keyframe Interval: 2 seconds
Encoder: Hardware (NVENC or AMF) or x264
These settings produce a high-quality 1080p stream. Cloudflare Stream Live transcode the input into multiple resolutions (360p, 480p, 720p, 1080p) so viewers receive the best quality for their connection.
Playing a Live Stream
You embed a live stream the same way as an on-demand video. Use the live input ID in the player embed code.
<!-- Live stream embed -->
<iframe
src="https://customer-ABCDE.cloudflarestream.com/live123/iframe"
style="border:none;width:640px;height:360px"
allow="accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture"
allowfullscreen>
</iframe>
The player detects whether the input is live or not. If live, it plays the stream. If offline, it shows a placeholder or the last recorded video depending on your configuration.
Managing Live Input States
You can start and stop live inputs programmatically through the API. This is useful for scheduled broadcasts and automated workflows.
# Stop a live input (disconnects the broadcaster)
curl -X POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream/live_inputs/live123/stop" \
-H "Authorization: Bearer API_TOKEN"
# Expected output:
# {"success":true,"result":{"uid":"live123","status":"disconnected"}}
# List all live inputs to check state
curl -s "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream/live_inputs" \
-H "Authorization: Bearer API_TOKEN" | jq '.result[].meta.name'
# Expected output:
# "Weekly Security Briefing"
# "Product Demo Stream"
When you stop a live input, the recording is finalized and becomes available as an on-demand video within a few seconds. The broadcast is saved with the same video ID management as regular uploads.
FAQ
Practice Questions
- What protocol does Cloudflare Stream Live use for video ingestion from broadcasting software?
- How do you enable automatic recording of a live stream when creating a live input?
- What is the recommended keyframe interval for broadcasting to Cloudflare Stream Live?
Summary
Cloudflare Stream Live turns any RTMPS-compatible broadcaster into a global live streaming platform. Broadcasts are ingested over RTMPS, automatically transcoded into multiple resolutions, and delivered to viewers worldwide with low latency. The same platform records the stream for on-demand replay, making it a complete live-to-VOD solution without additional infrastructure.
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro -- security-first tools for the modern web.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro