Video processing with Workflows
Choose managed Cloud Streaming for live cameras, or process webcams, camera feeds, and video files on a self-hosted Inference Server.
For managed live-camera processing, use Cloud Streaming. It connects camera sources to Workflow jobs on Roboflow-managed compute. Follow the quickstart to connect, preview, deploy, view results, and stop processing.
Use Batch Processing for stored media that should finish as a finite job. A connector-local file in Cloud Streaming loops as a live test source instead.
Self-hosted video
The Inference SDK WebRTC client below runs video through a Workflow on your own Inference Server. It keeps one session open while processing frames, supports stateful blocks such as trackers and counters, and avoids separate HTTP requests for each frame.
Start the Inference Server before running the client. Use self-hosting when processing must stay on your hardware or network. See Video Configuration for worker limits and server-side media references.
The older Serverless Video Streaming API is deprecated. Existing legacy reference remains available, but it is not the managed-live path described by Cloud Streaming. Migration is not an API URL substitution.
Install the SDK
pip install "inference-sdk[webrtc]"Stream a Workflow
This example captures video from a webcam and prints the predictions output from a saved Workflow:
from inference_sdk import InferenceHTTPClient, InferenceConfiguration
from inference_sdk.webrtc import StreamConfig, WebcamSource
client = InferenceHTTPClient(
api_url="http://localhost:9001",
api_key="ROBOFLOW_API_KEY",
).configure(InferenceConfiguration(api_key_transport="header"))
session = client.webrtc.stream(
source=WebcamSource(),
workflow="workflow-id",
workspace="workspace-name",
config=StreamConfig(data_output=["predictions"]),
)
@session.on_data("predictions")
def handle_predictions(predictions, metadata):
print(f"Frame {metadata.frame_id}: {predictions}")
session.run()Replace workflow-id, workspace-name, and ROBOFLOW_API_KEY with your values. Point api_url at your self-hosted server.
The names in data_output must match outputs defined by your Workflow. To receive an image output as video, add it to stream_output and register an on_frame handler. See the WebRTC Streaming reference for a complete example.
Choose a video source
Change the source passed to client.webrtc.stream() based on where the video comes from:
WebcamSource()
The camera is connected to the client machine.
RTSPSource("rtsp://...")
The Inference Server can reach the RTSP camera.
LocalStreamSource("rtsp://...")
Only the client can reach the RTSP or RTMP stream.
VideoFileSource("video.mp4")
You want to process a stored video file.
ManualSource()
Your application provides individual frames.
For RTSPSource, the Inference Server must be able to reach the camera URL. Use LocalStreamSource when only the client can reach it. For managed Cloud Streaming, connect the camera through the Video Connector instead of exposing its RTSP port to the public internet.
See WebRTC video sources for source configuration and consuming results for callbacks, iterators, and session cleanup.
Stream one model
You do not need to build a Workflow when you only need one model. Pass model_id instead of workflow and workspace:
See Stream a model for prediction handling by task type.
Next steps
Configure frame and data outputs in the WebRTC Streaming reference.
Start and configure a self-hosted Inference Server.
Connect a managed live camera with Cloud Streaming.
Last updated
Was this helpful?