# VideoDB × TwelveLabs: Search Any Moment Across Your Video Library

> TwelveLabs' multimodal understanding now plugs straight into VideoDB, so developers can turn live streams into searchable, alertable, playable moments.

Category: Partnerships

---

Human monitoring does not scale. A person can watch one feed for a while, maybe a few feeds with enough coffee, but fatigue always wins. The moment that matters — a baby starting to climb, a riverbed changing from quiet to dangerous, a restricted area suddenly occupied — is exactly the kind of moment that gets missed when the system depends on someone staring at pixels all day.

VideoDB's real-time infrastructure turns live streams into structured, searchable, actionable video data. With TwelveLabs' Pegasus 1.2 model available directly inside the VideoDB indexing pipeline, developers can build live video understanding apps without stitching together separate storage, streaming, model, and alerting systems.

The loop is simple: connect a stream, describe what the model should look for, index visual batches with Pegasus, define the event that matters, and receive a playable clip when the event is detected.

> "The camera stops being a passive feed. It becomes an event source your product can act on."

## The real bottleneck in video AI

The hard part is rarely one model call. It is everything around the model: ingesting RTSP or camera feeds, sampling frames, storing generated understanding, evaluating events, and delivering alerts fast enough to matter.

- **API sprawl:** video ingest, model inference, storage, playback, and notifications often live in different services.
- **Scaling pressure:** live streams produce continuous data, and visual understanding workloads are expensive if every frame is treated the same way.
- **Latency gaps:** if indexing, alerting, and playback are not part of the same pipeline, real-time products become slow review tools.

VideoDB collapses that workflow into one video-native layer. RTStreams handle live ingest and playback. Visual indexes convert batches of frames into scene descriptions. Events define what the system should detect. Alerts deliver the moment as data, including confidence, explanation, and a stream URL.

## Introducing TwelveLabs inside VideoDB

The TwelveLabs integration adds Pegasus 1.2 to VideoDB's live visual indexing path. A stream index can opt into TwelveLabs frame understanding by setting one parameter: `model_name="twelvelabs-pegasus-1.2"`.

That small line matters. You keep the VideoDB primitives around the model — RTStream ingest, visual indexing, event definitions, WebSocket or webhook delivery, and playable clip generation — while Pegasus handles frame-level understanding inside the index.

## How the pipeline works

```python
import videodb

conn = videodb.connect()
coll = conn.get_collection()

flood_stream = coll.connect_rtstream(
    name="Arizona Flood Stream",
    url="rtsp://samples.rts.videodb.io:8554/floods",
    store=True,
)

flood_scene_index = flood_stream.index_visuals(
    batch_config={
        "type": "time",
        "value": 10,
        "frame_count": 6,
    },
    prompt=(
        "Monitor the dry riverbed and surrounding area. "
        "If moving water is detected across the land, identify it "
        "as a flash flood and describe the scene."
    ),
    name="Flash_Flood_Detection_Index",
    model_name="twelvelabs-pegasus-1.2",
)

print("Scene Index ID:", flood_scene_index.rtstream_index_id)
```

The batch configuration controls how often VideoDB samples the live stream and how many frames go into each visual understanding pass. The prompt tells Pegasus what to look for. The model name selects TwelveLabs.

## From understanding to action

Events are reusable detection rules. Once an event exists, it can be attached to a stream index and delivered over WebSocket for live app experiences or webhook for server-to-server automation.

```python
event_id = conn.create_event(
    event_prompt="Detect sudden flash floods or water surges.",
    label="flash_flood",
)

ws_wrapper = conn.connect_websocket()
ws = await ws_wrapper.connect()

alert_id = flood_scene_index.create_alert(
    event_id=event_id,
    callback_url="",
    ws_connection_id=ws.connection_id,
)

async for msg in ws.receive():
    if msg.get("channel") == "alert":
        data = msg.get("data", {})
        print("Event:", data.get("label"))
        print("Confidence:", data.get("confidence"))
        print("Clip:", data.get("stream_url"))
        print("Why:", data.get("explanation"))
```

The alert payload is not just a notification. It carries the event label, confidence, explanation, timestamp, and stream URL for the detected moment.

## Demo 1: flash flood detection

[Open the Flash Flood Detection notebook in Colab.](https://colab.research.google.com/github/video-db/videodb-cookbook/blob/main/integrations/twelvelabs/Flash_Flood_Detection_TwelveLabs.ipynb)

The flash flood notebook connects a live RTSP sample stream, creates a Pegasus-powered visual index, and defines events such as `flash_flood`, `heavy_rainfall`, and `human_rescue`.

## Demo 2: baby crib monitoring

[Open the Baby Crib Monitoring notebook in Colab.](https://colab.research.google.com/github/video-db/videodb-cookbook/blob/main/integrations/twelvelabs/Baby_Crib_Monitoring_TwelveLabs.ipynb)

The baby crib notebook uses the same integration pattern with a different prompt and event rule. The stream index describes activity inside the crib and pays attention to standing, climbing, or escape attempts.

```python
crib_scene_index = crib_stream.index_visuals(
    batch_config={
        "type": "time",
        "value": 10,
        "frame_count": 6,
    },
    prompt=(
        "Describe the activity of the baby inside the crib. "
        "Notice if the baby stands up, climbs the rail, "
        "or attempts to climb out."
    ),
    name="Baby_Crib_Index",
    model_name="twelvelabs-pegasus-1.2",
)
```

## Why this is bigger than alerts

Real-time video intelligence is a new interface for software. Instead of asking users to review footage after the fact, the system can surface moments as they happen. The TwelveLabs integration strengthens the frame-understanding layer. VideoDB makes it productizable: ingest, index, search, alert, and replay all in one loop.

---

## Build real-time video understanding. Powered by TwelveLabs Pegasus + VideoDB.

Start from a working notebook, then adapt the stream, prompt, and event rule to your own product.

CTAs: [Open flood notebook](https://colab.research.google.com/github/video-db/videodb-cookbook/blob/main/integrations/twelvelabs/Flash_Flood_Detection_TwelveLabs.ipynb) · [Open crib notebook](https://colab.research.google.com/github/video-db/videodb-cookbook/blob/main/integrations/twelvelabs/Baby_Crib_Monitoring_TwelveLabs.ipynb)
