> This page is for version v1.3 (default).
> For other versions, use one of these documentation indexes:
> - v1.3 (default): https://docs.twelvelabs.io/v1.3/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server.

# ApertureDB - Semantic video search engine

> Create semantic video search by combining the TwelveLabs Embed API with ApertureDB.

![](/_fern-img/0a3f95700e3e3c64360c6f483e49bab1793b095752f68560fec0c7c1da3faf6a.webp)

**Summary**: This integration combines TwelveLabs' [Embed API](/docs/guides/create-embeddings)  with ApertureDB to create an efficient semantic video search solution. It captures rich video content as multimodal embeddings, enabling precise and relevant search results.

**Description**: The process of performing a semantic video search using TwelveLabs and ApertureDB involves two main steps:

1. Create embeddings for your video content and query
2. Use the embeddings to perform a vector search in ApertureDB

**Code explanation**: Our blog post, [Semantic Video Search Engine with TwelveLabs and ApertureDB](https://www.twelvelabs.io/blog/twelve-labs-and-aperturedb), guides you through the process of creating a video search application, from setup to performing vector searches.

**Colab Notebook**: [TwelveLabs-EmbedAPI-ApertureDB](https://colab.research.google.com/drive/19SETd2qpGPLQmuyzBok5GUxXqHLkQ7NF?usp=sharing)

# Integration with TwelveLabs

This section describes how you can use the TwelveLabs Python SDK to create embeddings for semantic video search. The integration involves creating two types of embeddings:

* Video embeddings from your video content
* Text embeddings from queries

These embeddings form the basis for vector search operations.

## Video embeddings

The code below creates a video embedding task that handles the processing of a video. It periodically checks the status of the task and retrieves the embeddings upon completion:

**`Python`**

```python Python
from twelvelabs import TwelveLabs
from twelvelabs.models.embed import EmbeddingsTask

# Initialize the TwelveLabs client
twelvelabs_client = TwelveLabs(api_key=TL_API_KEY)

def generate_embedding(video_url):
    # Create an embedding task
    task = twelvelabs_client.embed.task.create(
        engine_name="Marengo-retrieval-2.7",
        video_url=video_url
    )
    print(f"Created task: id={task.id} engine_name={task.engine_name} status={task.status}")

    # Define a callback function to monitor task progress
    def on_task_update(task: EmbeddingsTask):
        print(f"  Status={task.status}")

    # Wait for the task to complete
    status = task.wait_for_done(
        sleep_interval=2,
        callback=on_task_update
    )
    print(f"Embedding done: {status}")

    # Retrieve the task result
    task_result = twelvelabs_client.embed.task.retrieve(task.id)

    # Extract and return the embeddings
    embeddings = []
    for v in task_result.video_embeddings:
        embeddings.append({
            'embedding': v.embedding.float,
            'start_offset_sec': v.start_offset_sec,
            'end_offset_sec': v.end_offset_sec,
            'embedding_scope': v.embedding_scope
        })

    return embeddings, task_result

# Example usage
video_url = "https://storage.googleapis.com/ad-demos-datasets/videos/Ecommerce%20v2.5.mp4"

# Generate embeddings for the video
embeddings, task_result = generate_embedding(video_url)

print(f"Generated {len(embeddings)} embeddings for the video")
for i, emb in enumerate(embeddings):
    print(f"Embedding {i+1}:")
    print(f"  Scope: {emb['embedding_scope']}")
    print(f"  Time range: {emb['start_offset_sec']} - {emb['end_offset_sec']} seconds")
    print(f"  Embedding vector (first 5 values): {emb['embedding'][:5]}")
    print()
```

For details on creating text embeddings, see the [Video embeddings](/docs/guides/create-embeddings/at-scale/video) page.

## Text embeddings

The code below creates a text embedding for the query provided in the `text` parameter:

**`Python`**

```python Python
# Generate a text embedding for our search query
text_embedding = twelvelabs_client.embed.create(
  engine_name="Marengo-retrieval-2.7",
  text="Show me the part which has lot of outfits being displayed",
  text_truncate="none"
)

print("Created a text embedding")
print(f" Engine: {text_embedding.engine_name}")
print(f" Embedding: {text_embedding.text_embedding.float[:5]}...")  # Display first 5 values

```

For details on creating text embeddings, see the [Embed a query](/docs/guides/create-embeddings/query) page.

# Next steps

After reading this page, you have the following options:

* **Customize and use the example**: Use the [TwelveLabs-EmbedAPI-ApertureDB](https://colab.research.google.com/drive/19SETd2qpGPLQmuyzBok5GUxXqHLkQ7NF?usp=sharing) notebook to understand how the integration works. You can make changes and add functionalities to suit your specific use case. Below are a few examples:
  * **Explore data modeling**: Experiment with different video segmentation strategies to optimize embedding generation.
  * **Implement advanced search**: Try multimodal queries combining text, image, and audio inputs.
  * **Scale your system**: Test performance with larger video datasets and optimize for high-volume queries.
* **Explore further**: Try the [applications built by the community](/docs/resources/from-the-community) or our [sample applications](/docs/resources/sample-applications) to get more insights into the TwelveLabs Video Understanding Platform's diverse capabilities and learn more about integrating the platform into your applications.