Design Real-Time Video Understanding
Understanding the Problem
📹 What is real-time video understanding? It's the set of models that watch video while it's being made and react fast enough to matter. On the creator's phone, models find faces, hands, bodies and objects in every camera frame so effects (a face filter, a blurred background, a sticker that follows a dog) stay locked on at 30 frames per second. In the cloud, models watch each live stream as it's broadcast and describe what's happening (cooking, a goal in a match, a product held up to the camera, what the host just said), which powers auto-generated comments, live captions, highlights and moderation.
Two requests usually show up under this name: "design real-time computer vision for live streams, like auto comments and effects," and "design object detection on edge devices." They are the two tiers of one system. The device tier has a 33 ms budget per frame and no network; the cloud tier has seconds and a GPU fleet, but has to cover hundreds of thousands of streams at once. We'll design both and the contract between them.
Video ingest, transcoding and delivery to viewers are covered in Design a Live Streaming Platform. Here we focus on the models: what they detect, how they're made small and fast enough, how they're trained, and how the cloud tier stays affordable.
Functional Requirements
Core Requirements
- Creators should be able to use real-time effects in the camera preview and in their live broadcast: face filters, background replacement, and effects triggered by detected objects or gestures, at 30 fps.
- The system should understand live streams as they happen, emitting timestamped events every few seconds: scene and activity ("cooking," "gaming," "playing guitar"), notable objects ("sneaker," "dog"), on-screen text (a scoreboard) and speech.
- The system should generate auto comments from those events: short, clearly labeled AI comments or suggested comments viewers can tap, plus live captions, within a few seconds of the moment.
- Stream events should be available to other consumers: highlight clipping, moderation, search and recommendations.
Below the line (out of scope)
- Ingest, transcoding and CDN delivery.
- The moderation policy and review workflow (we provide signals). See Content Moderation.
- Ranking live streams in the feed. See Video Recommendation.
- Identifying who someone is (face recognition). We detect faces for effects, we don't identify people.
Non-Functional Requirements
Core Requirements
- Device latency: the whole camera loop (capture, models, rendering effects) at 30 fps, so the models get roughly 10 ms per frame on a mid-range phone, running for a 30-minute stream without overheating.
- Device footprint: models of a few MB, downloadable over the air, running on phones up to four or five years old.
- Cloud scale: 500,000 concurrent live streams at peak, most with very few viewers.
- Cloud latency: stream events within 2-3 seconds of the frame reaching our ingest, and auto comments within about 5 seconds of the moment.
- Safety and privacy: faces stay on the device for effects; generated comments must be grounded in what's actually happening, labeled as AI, and never offensive; effects must work equally well across skin tones, lighting and hairstyles.
Below the line (out of scope)
- Ultra-low-latency interactive video (video calls). Live streams already have a few seconds of glass-to-glass delay.
The arithmetic for the cloud tier changes the design. Analysing every frame of every stream is 500,000 × 30 = 15 million frames per second. Even a small detector running at around a thousand frames per second per data-center GPU would need on the order of 15,000 GPUs, before any audio or language models. That's not a budget anyone will approve.
Two facts get us out of it:
- Sampling: most stream content changes slowly. One frame per second, and fewer when nothing changes, captures what a stream is about. That's 500,000 frames per second, around 500 GPUs for a light model, and less with change detection.
- Viewership is concentrated: most live streams have a handful of viewers, and a small fraction of streams has most of the viewers. Auto comments and highlights only matter where there's an audience. Spend the heavy models (action recognition, VLM captions, streaming speech recognition) on the streams people are actually watching.
The phrase "real-time video understanding" invites a design that runs a big model on every frame. The strong answer starts from the budget: 33 ms on a phone, and a GPU fleet that can afford a light look at every stream and a careful look only at the popular ones.