# Realtime alert

> A reference technical solution for sub-second event detection on live feeds. Attach an RTSP source, declare an event in natural language or as a composed index, subscribe to alerts. Every payload carries the matching clip, frame, and confidence score.

---

## Hero

Path: Platform → Solutions → Realtime alert

Flow: live feed → understanding → alert

A reference technical solution for sub-second event detection on live feeds. Attach an RTSP source, declare an event in natural language or as a composed index, subscribe to alerts. Every payload carries the matching clip, frame, and confidence score.

CTAs: [Try the SDK](/developers) · [Talk to architecture](/company#contact)

---

## Architecture

**The detection pipeline.**

RTSP frames are normalized on ingest, sampled at a configurable rate, and run through the index stack (including BYO classifiers). A match builds an alert envelope (event, confidence, clip URL, frame, source tags) and dispatches it via your subscriber.

Stages: CAPTURE (RTSP, cam-04 aisle, 30 fps, h.264, live) → PERCEPTION (indexes · custom event · BYO classifiers, on normalized frames sampled on ingest) → EVENT LOG (e.g. `fall_in_aisle`, conf 0.94, ~110 ms; clip URL, frame, source tags) → POST (subscriber webhook to /ops/page + clip.m3u8).

---

## The three stages

**Attach. Define. Subscribe.** Three SDK calls. No frame pipelines to operate. No model serving to manage.

### 01 — Attach a live source

RTSP, ONVIF, RTMP, screen + audio capture, WebRTC. One ingestion path; VideoDB handles the codec normalization and clock alignment.

```python
# attach
feed = vdb.stream.attach(
    rtsp="rtsp://cam-04"
)
```

### 02 — Define the event

In natural language or as a composition of indexes. Confidence threshold, cooldown, scope. The platform compiles it into a continuous index pass.

```python
# define
feed.define_event(
    name="fall",
    prompt="a person falls"
)
```

### 03 — Subscribe to alerts

Webhook, WebSocket, or pager. Every alert carries the matching clip URL, the frame timestamp, and the source context. Auditable by default.

```python
# subscribe
feed.on_event(
    webhook="https://ops/page"
)
```

---

## Full implementation

A complete fall-detection pipeline across a 1,000-camera fleet.

```python
from videodb import connect

vdb = connect(api_key="<your-key>")

# 1. Attach the fleet. Same call shape per camera.
#    VideoDB normalizes codecs and clocks on ingestion.
for cam in fleet:
    feed = vdb.stream.attach(
        rtsp=cam.url,
        tags={"site": cam.site, "zone": cam.zone},
    )

    # 2. Define the event. Natural language or composed indexes.
    feed.define_event(
        name="fall_in_aisle",
        prompt="a person falls or slips on the floor",
        custom_index="action_classifier_v3",  # BYO model
        confidence=0.85,
        cooldown="30s",  # debounce repeats
    )

    # 3. Subscribe. Every alert ships a clip + context.
    feed.on_event(
        name="fall_in_aisle",
        webhook="https://ops.example.com/page",
        include=["clip_url", "frame_url", "site_tags"],
    )

# Each alert delivered as: {event, conf, ts, clip_url, frame_url, tags}
```

---

## Data flow

**What runs continuously, per camera, per frame.** The entire pipeline runs inside VideoDB. Your application only sees the alerts.

| Stage | Detail | Note |
|---|---|---|
| RTSP IN | cam-04, 30 fps, h.264 + aac | |
| EXTRACT | keyframes + audio chunks | @ 5 Hz default |
| INDEX RUN | scene, object, custom (BYO) | ~180 ms p95 |
| MATCH | confidence threshold, cooldown | debounced |
| ALERT BUILD | + clip.m3u8, + frame.jpg, + tags | |
| DELIVER | webhook, WebSocket, pager | |

End-to-end alert latency: ~280 ms typical.

---

## What to know before you ship

- **Latency — Sub-second, end to end.** Extract + index + match + deliver typically lands under 300 ms. Configurable sample rate (default 5 Hz) trades latency vs. cost.
- **Cooldown — Built-in debounce.** A defined event won't refire for its cooldown window. Prevents alert storms when the underlying condition persists across many frames.
- **Evidence — Every alert is auditable.** Each alert ships with the matching clip URL, a still frame, the confidence score, and your source tags. Forwardable to a SIEM or case-management system.
- **Fleet — Scales to 1,000+ feeds.** Same SDK shape per camera; the platform handles fan-out, GPU scheduling, and back-pressure. Per-camera or fleet-wide event policies.

---

## Use cases

What teams ship with this solution.

- **Industrial safety.** Fall detection in warehouses, PPE compliance on factory floors, hazard alerts on construction sites. Custom-trained classifiers plug in as indexes; the platform runs them on every frame.
- **Surveillance and security.** Loitering, intrusion, perimeter breaches across fleets of cameras. Each alert lands as a webhook with the matching clip URL and the source frame, ready for triage in a SOC.
- **Healthcare operations.** Patient-fall detection in hospital rooms with per-room confidence thresholds and cooldown windows. Alert payloads carry the clip, frame, and ward context for the on-call nurse.
- **Broadcast moderation.** Detect unsafe content, sponsor-logo violations, and brand-safety flags across live broadcast feeds. The standards desk gets a clip plus the frame; the platform handles cooldowns per policy.

---

## Closing

Wire your camera fleet to alerts in an afternoon. Same SDK as the rest of the platform. Same six primitives underneath.

CTAs: [Start building](/developers) · [See Personalized streaming](/platform/personalized-streaming)
