Streamline: Custom Video Pipelines with Cloudflare Stream and Workers
Hi everyone, it's Shii-chan! Today is a design deep-dive on video processing, and a good lesson in combining Workers with containers.
Cloudflare BlogWhat was announced?
The Cloudflare Blog introduced Streamline. It demonstrates how to build long-running, continuous video processing pipelines by pairing Cloudflare Workers and Durable Objects with a containerized media engine.
Why it matters
Video processing has to keep running longer than a single request. Streamline shows a setup where processing continues even when the controlling app disconnects, along with the concrete design decisions behind it.
Dive Deep
The architecture has two parts:
- Media Engine (container): a Go-based HTTP controller translates requests into media operations, with FFmpeg doing the processing (FFmpeg is a swappable implementation detail). It handles RTMPS livestream input and output, HLS ingestion, webcam feeds, and WebSocket preview delivery
- Application (Worker): a Durable Objects orchestrator, a browser UI with identity and access policies, plus session coordination and container lifecycle management
Design decisions:
- Session independence: overriding the
onActivityExpired()callback to renew activity timeouts before expiration keeps processing alive after the controlling app disconnects - Preview delivery: WebSockets for low latency, with fMP4 fragments published to a Durable Object relay and forwarded to clients
- API abstraction: two exported packages, a high-level session-based interface (
@cloudflare/streamline/client) and Durable Object base classes you can customize per deployment
Four operations run in this fixed order:
- Filter (blur, saturation adjustments)
- Overlay (PNG images referenced by URL or updated dynamically)
- Subtitle (burned-in captions)
- Encode (codec, bitrate, resolution, framerate)
Limits and constraints:
- A maximum session duration is enforced to prevent indefinite container usage
- Only one session is active per container instance at a time
- Container CPU limits higher-quality or high-framerate processing
- PNG overlay update rates are constrained by size, bandwidth, and processing capacity
On security, stream credentials are stored as secrets, and applications reference named profiles rather than direct keys. Previews use two-tier authentication (an Access service token plus a per-session capability), and sessions bind to verified principals to prevent hijacking across users.
Wrap-up
- Workers, Durable Objects, and a containerized media engine form a long-running video pipeline
onActivityExpired()renewal keeps processing going when the controlling app disconnects- Four operations (Filter, Overlay, Subtitle, Encode), with constraints such as one session per container
A good design read if you want to learn how to combine containers and Durable Objects!