Cloudflare Stream Introduction -- Video Encoding and Delivery
In this tutorial, you'll learn about Cloudflare Stream Introduction. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
This tutorial explains how Cloudflare Stream ingests, encodes, stores, and delivers video content across the global edge network, handling format conversion and adaptive bitrate streaming automatically without managing encoding pipelines.
Why Cloudflare Stream Matters
Video accounts for over 80 percent of internet traffic, but delivering high-quality video is technically challenging. You need to encode multiple resolutions, support various codecs (H.264, H.265, VP9, AV1), handle adaptive bitrate switching, and serve content from locations close to each viewer. Cloudflare Stream solves all of this with a single upload-and-play workflow. Instead of managing encoding pipelines and CDN configurations, you upload a video once and Stream handles the rest -- transcoding, storage, and delivery across 330+ edge locations.
Real-world use: Doda Browser's built-in video player uses Cloudflare Stream to serve tutorial videos. A single 4GB source file is automatically transcoded into six resolutions (360p to 4K) and delivered to users worldwide with sub-200ms startup times.
Video Encoding and Delivery Flow
flowchart LR A[Upload source video] --> B[Stream ingests file] B --> C[Transcode to multiple resolutions] C --> D[Store at edge] D --> E["Generate HLS/DASH manifests"] E --> F[Player requests manifest] F --> G[Serve optimal resolution per viewer] G --> H[Adaptive bitrate switching] style B fill:#f90,color:#fff style E fill:#f90,color:#fff style G fill:#f90,color:#fff
Uploading a Video
You can upload videos to Cloudflare Stream through the dashboard or the API. The upload Process is asynchronous -- Stream returns a video ID immediately and processes the file in the background.
# Upload a video via API
curl -X POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream" \
-H "Authorization: Bearer API_TOKEN" \
--data '{"url":"https://example.com/my-video.mp4","meta":{"name":"Tutorial Video"}}'
# Expected output:
# {"success":true,"result":{"uid":"abc123","status":"queued","meta":{"name":"Tutorial Video"}}
The upload returns a unique video ID (uid) immediately. The video processes in the background. You can poll the status endpoint to know when encoding is complete.
# Check encoding status
curl -s "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream/abc123" \
-H "Authorization: Bearer API_TOKEN" | jq '.result.state'
# Expected output:
# "ready" (or "queued", "processing", "error")
Playing a Video
Once processed, you can play the video using the Cloudflare Stream player by embedding the video ID in an iframe.
<!-- Stream Player embed with a poster image -->
<iframe
src="https://customer-ABCDE.cloudflarestream.com/abc123/iframe?poster=https%3A%2F%2Fexample.com%2Fposter.jpg"
style="border:none;width:640px;height:360px"
allow="accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture"
allowfullscreen>
</iframe>
The player automatically selects the best resolution for each viewer's device and network conditions. Stream delivers HLS and DASH manifests so any compatible player can play the content.
Encoding Settings and Restrictions
Cloudflare Stream transcodes every video into multiple renditions. You can control the maximum resolution and restrict playback by domain, IP, or signed tokens.
# Set playback restrictions via API
curl -X POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/stream/abc123" \
-H "Authorization: Bearer API_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"maxDurationSeconds": 600,
"allowedOrigins": ["https://example.com", "https://app.example.com"],
"requireSignedURLs": true
}'
# Expected output:
# {"success":true,"result":{"uid":"abc123","allowedOrigins":["https://example.com","https://app.example.com"]}}
Signed URLs protect premium content by requiring a token generated with your signing key. The token expires after a set time, preventing unauthorized sharing of video links.
FAQ
Practice Questions
- What adaptive streaming protocols does Cloudflare Stream generate for video delivery?
- How do you restrict video playback to specific domains using the Cloudflare Stream API?
- What is the purpose of signed URLs in Cloudflare Stream?
Summary
Cloudflare Stream simplifies video delivery by handling ingestion, transcoding, storage, and global distribution through a single API. Videos are automatically encoded into multiple resolutions with HLS and DASH manifests and served from over 330 edge locations with adaptive bitrate switching. This removes the complexity of managing encoding pipelines and CDN configurations for video content.
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