Skip to content
mentoor

Topic 2 of 5 · 4 min read

Finding moments with timestamped video search

Goal: Design an index for a video library that returns the right segment and timestamp for a natural-language query.

To search a video library, cut each video into short segments, index what was said and what was shown for each segment, and return the segment's start and end time with every hit. The unit of search is the segment, not the video.

Check yourself · 1 of 3

What should a video-search hit contain so the user can jump to the answer?

Choose one answer

Why it matters

"Which training video shows the lockout procedure?" and "when does the customer first mention a refund?" are questions about moments. Sending every video to a model for every question is slow and costly. An index built once lets you answer from a small number of candidate segments, and send only those to a model for a final, detailed answer.

How to build it

  1. Segment. Cut each video into windows of 15 to 60 seconds, or at scene changes. Keep the start and end time of each. Shorter windows give sharper times; longer windows keep more context.
  2. Index speech. Transcribe, then attach each transcript line to the segment that contains it. Keep the speaker label if you have one.
  3. Index visuals. For one or two frames per segment, store a short caption written by a vision model, plus any text read from the screen (OCR). This is what lets you find "the slide with the pricing table".
  4. Embed. Make an embedding (a list of numbers that places similar meanings close together) of the transcript and caption text for each segment. Some products embed frames and audio directly. A multimodal video-search product such as TwelveLabs does this for you and returns segments with start and end times.
  5. Search in two steps. Combine keyword search (good for names, error codes, product numbers) with embedding search (good for paraphrase). Return the top 5 to 10 segments with video_id, start, end and a score.
  6. Verify the winners. Send only the top clips to a model and ask it to confirm the match and refine the time.

A row in the index might look like this:

{
  "video_id": "onboarding-07",
  "start": 312,
  "end": 342,
  "transcript": "Before you open the panel, lock out the breaker.",
  "caption": "Technician hanging a red lock on a breaker box",
  "embedding_id": "seg_07_0312"
}

Before and after

Before: One embedding per whole video, built from the title. A search for "lockout procedure" returns the video, and the user must scrub through 40 minutes.

After: One row per 30-second segment. The same search returns onboarding-07 at 05:12 to 05:42, with the transcript line shown under the hit.

What goes wrong

  • Windows that cut a sentence in half. The answer starts in one segment and ends in the next. Overlap windows by a few seconds.
  • Speech-only index. A query about something shown but never said finds nothing.
  • Stale captions. One caption per minute misses short events.
  • Trusting the score. A high similarity score means related, not correct. Verify before you show a time as fact.

Examples

Two queries, two channels

Query 1: "when does the trainer mention the red lock". The transcript index finds it at 05:12. Query 2: "the slide with the price table". Nothing was said about it, so only the caption and OCR index finds it, at 18:40. A speech-only index would have answered the first query and failed the second.

Result table for a support-call library

video_id start end matched on score
call-2291 02:10 02:40 transcript: "refund" 0.82
call-1874 11:05 11:35 caption: refund form on screen 0.74

The second hit never says the word. It is found through the caption.

Key points

  • The unit of search is the segment: store start and end time for each one, not just a video id.
  • Index both channels: transcript lines for what was said and captions or OCR for what was shown.
  • Combine keyword and embedding search, because names and codes need exact match while paraphrases need meaning.
  • Overlap segments by a few seconds so a sentence that spans a boundary is still found.
  • Verify the top few hits with a model or a person before presenting a timestamp as fact.

Common mistakes

  • Embedding the whole video once, so a hit gives no moment and the user must scrub through it.
  • Indexing the transcript only, which hides everything that is shown and not said.
  • Using embeddings alone, so an exact error code or order number is outranked by loosely related segments.
  • Displaying a similarity score or a model's time as confirmed when nobody checked the clip.

Check yourself · 2 of 3

Users search for "the slide with the pricing table", but the presenter never says the word pricing. Which index finds it?

Choose one answer

Check yourself · 3 of 3

Your index returns the right segment for most queries, but answers that begin at the end of one segment and finish in the next are missed. What is the most direct fix?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic