Design Video Pipelines That Survive a Disconnected Browser
Design long-running video work as an authorized session with reconnect, preview, and expiry rules—not as a request that must stay open until processing ends.
Editorial note · AI-assisted
AI-assisted original explainer; sources are listed at the end. Worked examples and exercises were not run unless marked as tested. Diagrams are AI-generated. The cover is an editorial photo.
Based on Cloudflare’s Streamline architecture and complementary Google Research work on long-form video orchestration.

Key points
- A video job that lasts longer than a web request needs its own lifecycle: start it, observe it, reconnect to it, and stop it explicitly.
- Separate the control plane from the media-processing plane so that a dropped browser connection does not automatically destroy useful work.
- Bound each session with authorization, resource limits, and an expiry policy; persistence without those controls can turn into an unattended cost or security problem.
Treat a video pipeline as a session, not a request
A common prototype pattern is to send a video-processing request from a browser and wait for the whole job to finish before returning a result. That can work for a brief transformation. It becomes fragile when processing involves a live feed, a long render, a preview stream, or multiple stages. The browser may disconnect, a network request may time out, or the user may need to inspect intermediate output while the processing continues.
Cloudflare’s Streamline architecture offers a useful design lesson: treat processing as a session with an independent lifecycle. Its media engine runs in a Container, while a controlling application, built with Workers and a Durable Object for orchestration, creates and monitors the session. The media engine handles input, processing, and output; the application handles control and observation. A browser can disconnect and reconnect without being the thing that keeps the media process alive.
That separation is more important than any particular framework. It gives the work a stable identity and lets the interface become a client of the job rather than its owner. Google Research’s work on coherent long-form video offers a related reason to make orchestration explicit: its described systems track visual state across segments and use iterative evaluation and refinement. The research is about generation rather than service deployment, but both cases show that multi-step video work depends on preserving context and managing transitions, not merely issuing one prompt.
A reusable session contract
Before selecting infrastructure, define what a session means to your application. A small contract can include:
| Operation | Question the system must answer |
|---|---|
| Create | Who may create this job, and what input is accepted? |
| Start | What configuration is fixed for this run? |
| Observe | How can the user see status, metrics, or a preview? |
| Resume | Can the same authorized user reconnect after a disconnect? |
| Stop | Who can stop the job, and what cleanup follows? |
| Expire | What ends a job that nobody returns to control? |
This contract is not tied to Cloudflare. It works for a hosted video transformation, a webcam preview, or a multi-stage generation workflow. A session identifier gives the application a handle for these operations. It should not, by itself, act as proof that anyone presenting it has permission to control the session.
Streamline demonstrates the distinction with a session-oriented client API. Its example creates a session and then starts a pipeline using a configuration with an input, a sequence of operations, and an output. For instance, a livestream could be read from an RTMP profile, receive an image overlay, be encoded as H.264 at 1280x720 and 30 fps, and be sent to an RTMP output profile. Those settings are an example from the reference, not a universal recommendation: the right encode parameters depend on the intended delivery and available processing capacity.
The architectural takeaway is that the caller describes the work, while the processing service owns its execution. Keep secrets such as stream keys behind the controlling service, rather than returning them to the browser as part of a convenient configuration response. Streamline’s post describes named profiles resolved by the Worker, with keys kept in secrets or write-only storage. That is a practical boundary: the browser asks for a named input and output, but does not need the credentials that connect them.

Keep preview and control distinct
A preview is useful, but it is not the same thing as job control. Streamline’s example sends preview fragments over a WebSocket relay while the application separately starts, observes, and stops the session. This helps avoid turning a video connection into the only record of whether work is still running.
For your own design, decide what happens when the preview disconnects. Does processing continue? Can the viewer reconnect? Is the preview endpoint authorized independently? These questions expose hidden assumptions early. A broken preview should usually be a visible observability failure, not an ambiguous signal that silently leaves a costly job running—or stops one the user expected to continue.
A session should also have a clear maximum duration or another explicit termination rule. Streamline describes renewing container activity while a session remains valid, then destroying it when the session has expired. The general principle is to make persistence conditional: continue only while a valid session exists, and make the eventual cleanup path automatic.
A common mistake: tying work to a live connection
A tempting shortcut is to run the entire pipeline inside a request handler and assume that the connection will remain open. The symptom is easy to recognize: closing a tab, losing Wi-Fi, or reaching a request timeout either kills the job unexpectedly or leaves its final status unclear. Retrying may then start duplicate work because the application cannot tell whether the original run is still active.
An independent session lifecycle addresses this, but introduces responsibility. Record a session’s state and owner, make start and stop operations unambiguous, and define how a reconnect identifies the existing run. Do not let an arbitrary session ID grant control. In Streamline’s described deployment, authorization is checked and an active session is bound to a verified principal; a different principal cannot stop or replace it. That is a useful security pattern, though the post explicitly says its owner deployment is private and singleton-routed, not a general public multi-user security model.
When this approach is the wrong tool
A durable session architecture is not automatically worth the added complexity. For a short, bounded transformation with no live preview and no need to reconnect, a simple request-and-response job or ordinary background queue may be easier to operate. Persistent containers, relay connections, and per-session authorization bring their own failure modes and operational work.
Nor does session management make media processing faster. Cloudflare notes that Streamline’s current media processing uses Container CPU and can bottleneck at higher quality or frame rates. If the main problem is encoding throughput, changing the control-plane design will not remove that limit. Profile the processing workload and choose an appropriate media runtime before promising a service level.
Carry the same state across shots
- Character
Identity · costume · pose
- Props
Appearance · position
- Scene
Space · light · direction
Practical exercise: design the reconnect test
Before building a full pipeline, sketch one session for a two-minute video transformation. Write down its identifier, owner, input reference, processing configuration, status states, preview behavior, stop rule, and maximum lifetime. Then walk through this scenario: start the session, disconnect the browser, reconnect as the same user, attempt to reconnect as a different user, and let the session reach its expiry.
The checkable outcome is a table with a defined expected result for all five events. The same user should be able to discover the existing session rather than accidentally create a duplicate; the different user should be denied control; and the expired session should reach a defined cleanup state. This is a design exercise, not a claim that any code has been run. If one event has no clear answer, settle the lifecycle or authorization rule before implementing the media pipeline.
Our verdict
We recommend the session-based approach when video work is long-running, needs preview or reconnection, or must continue independently of a particular browser request. Its value comes from explicit ownership, lifecycle, and cleanup—not from adding infrastructure for its own sake. Keep the control plane separate from processing, protect credentials, and make expiry part of the design. For brief, one-shot transformations, use a simpler job pattern until the product actually needs durable sessions.
References: Cloudflare, “Streamline: custom video pipelines with Cloudflare Stream and Workers,” https://blog.cloudflare.com/streamline/ ; Google Research, “Automating coherent long-form video generation,” https://research.google/blog/coherent-long-form-video-generation/