---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

[Back to Modules](/university)

### Module 8 of 8

0 completed · 8 remaining

0%

IntermediateModule 6·11:18·By Ethan

# Video Understanding: From Frames to Contextual Search

Master video understanding and how it differs from basic image understanding. Learn frame extraction techniques, video embedding models, scene-based chunking, and building sophisticated semantic video search applications.

video-understandingvideo-embeddingsscene-detectiontemporal-analysismultimodal-searchvertex-ai

Mark as Complete

ContentTranscriptResourcesQuiz

**Video understanding isn't just image understanding at scale: it's capturing temporal context that single frames can never provide.**

You've learned how to encode images into embeddings. But what happens when you need to search video content? A person dribbling a basketball looks like "a person running with a ball" in a single frame. Video understanding captures the _motion_: the dribble, the jump, the dunk.

## What Makes Video Different?

A video is composed of three core components:

1.  **Visual Frames**: Still images captured at the frame rate (30fps, 60fps, etc.)
2.  **Audio Tracks**: Speech, music, sound effects
3.  **Metadata**: Duration, timestamps, capture source information

The challenge: videos have **redundancy**. At 60fps, consecutive frames are nearly identical. We need strategies to extract meaningful content without processing every pixel.

## Frame Extraction Techniques

Before we can understand video, we need to extract the frames. There are three primary approaches:

### 1\. Uniform Sampling

Extract frames at fixed intervals: every second, every half-second, etc.

\# Extract one frame per second from a 60fps video
sampling\_rate = 1  # seconds
frames = video.extract\_frames(interval=sampling\_rate)

# 10-minute video → 600 frames

**Pros:**

*   Simple to implement
*   Predictable output size
*   Fast processing

**Cons:**

*   May miss important scenes between samples
*   Doesn't understand visual changes
*   Treats all intervals equally (boring scenes = action scenes)

### 2\. Keyframe Detection

Capture frames at peak action moments or significant visual changes.

\# Detect keyframes based on visual change threshold
keyframe\_threshold = 0.7
keyframes = video.detect\_keyframes(threshold=keyframe\_threshold)

# Returns frames where visual content changed significantly

**Pros:**

*   Captures important moments
*   Reduces redundancy
*   Action-oriented

**Cons:**

*   Variable output size
*   Computationally more expensive
*   May miss subtle but important content

### 3\. Scene-Based Detection

The most sophisticated approach: detect when scenes actually transition.

**How it works:**

1.  Measure pixel differences between consecutive frames
2.  When the delta exceeds a threshold, mark a scene boundary
3.  Extract representative frames from each scene

\# Scene detection measures pixel transitions
frame\_a = video\[t=0\]
frame\_b = video\[t=1\]

pixel\_delta = calculate\_difference(frame\_a, frame\_b)

if pixel\_delta > scene\_threshold:
    # New scene detected
    mark\_scene\_boundary()

**Tools for scene detection:**

*   **AutoShot**: State-of-the-art shot boundary detection model
*   **PySceneDetect**: Open-source scene detection library
*   **Semantic Deduplication**: Compare frame embeddings: when cosine similarity drops below threshold, mark as new scene

\# Semantic deduplication approach
embedding\_1 = model.encode(frame\_1)
embedding\_2 = model.encode(frame\_2)

similarity = cosine\_similarity(embedding\_1, embedding\_2)

if similarity < 0.5:
    # Semantically different content - new scene
    create\_scene\_boundary()

**Pros:**

*   Semantically meaningful segments
*   Preserves complete scenes
*   Optimal for content understanding

**Cons:**

*   Variable segment lengths
*   Requires ML models
*   Higher computational cost

## Frame-Level vs Video-Level Embeddings

Once you have frames, you have a critical architectural choice: **embed each frame independently or embed the sequence together**.

### Frame-Level Embeddings

Treat each extracted frame as an independent image.

\# Frame-level: Embed each frame separately
for frame in extracted\_frames:
    embedding = siglip\_model.encode(frame)
    index.add(embedding)

# Query with text
results = index.search("person with basketball")

**What frame-level captures:**

*   Objects in the scene
*   Visual composition
*   Static concepts

**What frame-level misses:**

*   Motion and action
*   Temporal relationships
*   Transitions between frames

**Example limitation:**

`Frame 1: Person with arms down, ball at waist Frame 2: Person with arms up, ball in air Frame 3: Person with arms extended, ball near hoop Frame-level query: "person with basketball" Result: All three frames match equally What you actually want: "person dunking basketball" Frame-level: Can't capture "dunking" - that requires temporal understanding`

### Video-Level Embeddings

Encode the **sequence of frames together** into a single embedding.

\# Video-level: Embed frame sequence as one unit
frame\_sequence = \[frame\_1, frame\_2, frame\_3, frame\_4\]
embedding = video\_model.encode(frame\_sequence)

# Single embedding captures the temporal context
index.add(embedding)

**What video-level captures:**

*   Actions and motion (dribbling, jumping, landing)
*   Expressions and body language
*   Scene transitions
*   Temporal patterns

**The key insight:**

`Query: "person dribbling basketball" Frame-level: Matches any frame with person + basketball Video-level: Matches sequences showing the dribbling motion Query: "cutting an onion" Frame-level: "onion", "knife" - separate concepts Video-level: "cutting an onion" - the action itself`

### Choosing Between Approaches

Use Case

Best Approach

Object detection ("find all frames with dogs")

Frame-level

Action search ("person running")

Video-level

Content indexing for thumbnails

Frame-level

Semantic video retrieval

Video-level

Fine-grained frame analysis

Frame-level

Understanding context and motion

Video-level

**Trade-offs:**

Aspect

Frame-Level

Video-Level

**Computational cost**

Lower (per-frame)

Higher (sequence processing)

**Storage**

More embeddings

Fewer embeddings

**Temporal understanding**

None

Full

**Query precision**

Object-level

Action-level

## Video Embedding Models

Video understanding requires specialized models that process frame sequences together.

### Vertex AI Multimodal Embeddings

Google Cloud's Vertex AI provides a multimodal embedding model that supports image, video, and text in the same vector space.

**Key features:**

*   Unified embedding space for text, image, and video
*   Configurable dimensions (128, 256, 512, 1408)
*   Start/end offset support for video segments
*   Production-ready infrastructure

\# Vertex multimodal configuration
model = "multimodalembedding@001"
dimensions = 1408  # Full dimension space

# Embed video segment
embedding = vertex\_model.embed(
    video=video\_bytes,
    start\_offset=0,
    end\_offset=30  # 30-second segment
)

**Dimension options:**

Dimensions

Use Case

Trade-off

128

Fast retrieval, large scale

Lower precision

256

Balanced

Good default

512

Higher precision

More storage

1408

Maximum precision

Highest storage

### Using Feature URIs in Mixpeek

Mixpeek abstracts the complexity of video embedding models with Feature URIs:

\# Feature URI encapsulates model configuration
feature\_uri = "mixpeek://multimodal-extractor/v1/vertex-multimodal-1408"

# No need to configure:
# - Vector dimensions
# - Inference endpoints
# - Model versions
# - API authentication

The Feature URI handles:

*   Model selection
*   Dimension configuration
*   API abstraction
*   Version management

## Building Video Search with Scene Segmentation

Let's build a complete video understanding pipeline.

### Step 1: Create a Collection with Scene Segmentation

from mixpeek import Mixpeek

client = Mixpeek(api\_key="your-api-key")

# Create collection that splits videos by scene
collection = client.collections.create(
    collection\_name="scene-segments",
    source\_bucket="raw-videos",
    feature\_extractors=\[{
        "type": "multimodal",
        "split\_method": "scene",  # Scene-based chunking
        "feature\_uri": "mixpeek://multimodal-extractor/v1/vertex-multimodal-1408",
        "dimensions": 1408
    }\]
)

When videos are uploaded:

1.  AutoShot detects scene boundaries
2.  Each scene is encoded using the video embedding model
3.  Scene embeddings are indexed for retrieval

### Step 2: Create a Retriever

\# Create retriever for scene-based search
retriever = client.retrievers.create(
    retriever\_name="video-semantic-search",
    collections=\["scene-segments"\],
    stages=\[{
        "type": "feature\_search",
        "feature\_uri": "mixpeek://multimodal-extractor/v1/vertex-multimodal-1408",
        "limit": 20
    }\]
)

### Step 3: Execute Semantic Queries

\# Search for contextual video content
results = retriever.execute(
    inputs={"text": "person talking in the video"}
)

# Returns scene segments with:
# - Relevance scores
# - Start/end timestamps
# - Source video reference
# - Extracted features

for result in results:
    print(f"Score: {result.score}")
    print(f"Video: {result.metadata\['source\_video'\]}")
    print(f"Timestamp: {result.metadata\['start\_time'\]} - {result.metadata\['end\_time'\]}")

### Step 4: Join Across Collections

The power of decomposition: query scene segments and join with other collections:

\# Scene segments can join with:
# - Time segments (fixed intervals)
# - Text embeddings (transcriptions)
# - Visual style features
# - Face detection results

results = retriever.execute(
    inputs={"text": "product demo"},
    joins=\[{
        "collection": "time-segments",
        "on": "source\_video\_id"
    }\]
)

## Video Chunking: Scenes vs Time

Recall from the chunking module: video chunking is analogous to text chunking.

Text Chunking

Video Chunking

Sentence

Time interval

Paragraph

Scene

Semantic concept

Silence-based split

### Time-Based Chunking

Split by fixed intervals (like splitting text by token count):

\# Every 10 seconds
split\_method = "time"
split\_interval = 10  # seconds

**Best for:**

*   Predictable segment sizes
*   Large-scale initial processing
*   Simple use cases

### Scene-Based Chunking

Split by visual transitions (like splitting text by semantic similarity):

\# Scene boundaries via AutoShot
split\_method = "scene"
detection\_threshold = 0.5

**Best for:**

*   Semantic video retrieval
*   Content with clear scene transitions
*   Action and motion search

### Silence-Based Chunking

Split by audio pauses (like splitting text by sentence):

\# Pause detection
split\_method = "silence"
silence\_threshold = -40  # dB

**Best for:**

*   Speech content (talks, lectures, podcasts)
*   Idea-based segmentation
*   Dialogue analysis

## Image Understanding vs Video Understanding

Let's crystallize the difference:

### Image Understanding

`Input: Single frame Output: Object-level embedding Captures: "knife", "onion", "cutting board" Query: "vegetables" → matches Query: "chopping" → uncertain match`

### Video Understanding

`Input: Sequence of frames Output: Action-level embedding Captures: "cutting an onion with a knife on a cutting board" Query: "chopping vegetables" → strong match Query: "cooking preparation" → contextual match`

**What video understanding unlocks:**

*   **Expressions**: Facial movements over time
*   **Body language**: Gestures and posture changes
*   **Actions**: Running, jumping, dancing
*   **Transitions**: Scene changes, camera movements
*   **Speech analysis**: Tone and emphasis patterns

## Architecture Summary

`Raw Video (S3/GCS) ↓ ┌──────────────────────┐ │ Scene Detection │ │ (AutoShot/Custom) │ └──────────────────────┘ ↓ ┌──────────────────────┐ │ Video Embeddings │ │ (Vertex Multimodal) │ └──────────────────────┘ ↓ ┌──────────────────────┐ │ Vector Index │ │ (1408 dimensions) │ └──────────────────────┘ ↓ ┌──────────────────────┐ │ Retriever │ │ (Text → Video) │ └──────────────────────┘ ↓ Scene Results`

## Key Takeaways

1.  **Video ≠ Many Images**: Video understanding captures temporal context that frames alone cannot
2.  **Frame extraction matters**: Sampling, keyframe detection, and scene-based extraction have different trade-offs
3.  **Video embeddings encode motion**: "Dribbling" requires seeing the sequence, not just one frame
4.  **Scene-based chunking** produces semantically meaningful segments
5.  **Feature URIs abstract complexity**: One URI encapsulates model, dimensions, and versioning
6.  **Trade-offs exist**: Video-level is more expensive but captures action; frame-level is cheaper but misses motion
7.  **Decomposition enables flexibility**: Split by scene, query across collections, join on demand

## What's Next?

With video understanding covered, explore:

*   **Audio Understanding**: Speech, music, and sound as embeddings
*   **Multimodal Fusion**: Combining video, audio, and text retrieval
*   **Real-Time Video Search**: Streaming video analysis

* * *

## Resources

*   [Mixpeek Video Extractor Docs](https://mixpeek.com/docs/processing/extractors/multimodal)
*   [Vertex AI Multimodal Embeddings](https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-multimodal-embeddings)
*   [AutoShot Model](https://github.com/wentaozhu/AutoShot)
*   [PySceneDetect](https://scenedetect.com/)
*   [Mixpeek Semantic Video Understanding Blog](https://mixpeek.com/blog/semantic-video-understanding)
*   [Reverse Video Search: How It Works + Python API Tutorial](https://mixpeek.com/blog/reverse-video-search)

## Try It Yourself

1.  Upload a video with distinct scenes to Mixpeek Studio
2.  Configure scene-based chunking
3.  Query with action-based text ("person walking", "product demo")
4.  Compare results with time-based chunking: notice the difference in relevance

## Discussion Questions

*   When would you choose frame-level over video-level embeddings?
*   How does scene detection compare to semantic deduplication for chunking?
*   What video use cases require both audio and visual understanding?
*   How would you handle very long videos (hours of content)?

## Frequently Asked Questions

What is the difference between video understanding and image understanding?

What frame extraction techniques does Mixpeek support?

When should I use frame-level vs video-level embeddings?

Can I search videos using text queries?

Previous

Feature URIs: Evolving Embeddings Without Migration

K/J

Ready to build?

## Try it in Mixpeek Studio

Experience the power of multimodal AI firsthand. Build, test, and deploy your application with our intuitive visual interface.

[Launch Studio](https://studio.mixpeek.com/?utm_source=homepage&utm_medium=education_cta&utm_campaign=mvs_onramp)[View Documentation](https://mixpeek.com/docs)

### Quick Start with API

Get started in seconds with a simple API call

[API Reference](https://mixpeek.com/docs/api-reference)

cURL

```bash
1curl -X POST https://api.mixpeek.com/index \
2  -H "Authorization: Bearer YOUR_API_KEY" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "url": "https://example.com/video.mp4",
6    "collection": "my_collection"
7  }'
```

#### Blog & Tutorials

Read our latest articles, guides, and technical deep dives

[Read Blog →](/blog)

#### Community Hub

Connect with developers, share projects, and get help from experts

[Join Community →](/community)

#### Video Library

Watch curated playlists and step-by-step video tutorials

[Watch Videos →](/videos)