How Tubi built Media Vision to identify 6.5M narrative cues across their content library
Huge thanks to Tubi’s technical team that helped bring this story to life: Taotao Lin (Engineering Director), Aryan Gupta (AI PM), Frank Chen (PM) and Aidean Sharghi (ML Engineer)
Problem
If you’ve ever experienced a streaming service cut to a loud commercial in the middle of a high tension, silent dramatic build, you may have witnessed the breaking down of rule based video engineering. Historically automation used conventional Python libraries to detect scene changes, but these tools lacked the human touch.
As viewers we can recognize silence isn’t always a break - sometimes it’s a climax. Engineers at Tubi faced a massive scalability bottleneck: how do you teach a pipeline to detect and understand the 6.5 million high impact cue points across over 500k titles? To move beyond broad genre tagging and avoid breaking viewer immersion, we had to stop writing explicit rules and start engineering for narrative intent.
Why this matters: Manual reviews were not scalable across 500k titles. By showing the right ad, at the right time, to the right user in a brand safe environment, Tubi brings massive value to its advertisers and viewers.
What we built
Tubi engineered Media Vision , a foundational architectural layer that treats workflows as data rather than hard coded logic. By shifting to intent based AI development, the pipeline processes long form video as a continuous narrative by using native multimodal reasoning to interpret the emotional pulse of each scene rather than relying on disconnected image-detection rules.
Media Vision allows Tubi to plug in different prompts and models to run across their library for multiple distinct use cases (ad break detection, preview generation, content moderation, etc.)
The pipeline currently powers:
-
Ad Break Finder 3.0: Uses multimodal reasoning to find natural narrative breaks.
-
Video Preview 2.0: Automatically generates movie/tv show previews by identifying high engagement scenes.
The stack and solution
Static, rule based code and manual analysis produced inconsistent results, leading to jarring user experiences and a high volume of expensive manual “human in the loop” validation. Media Vision is built on the following to process the mass amount of video and television titles:
-
Gemini Enterprise Agent Platform: Serves as the reasoning backbone for Media Vision. Not only is it an API for generating text; it is a full lifecycle platform that allows Tubi to orchestrate complex, multimodal video analysis across the entire content library.
-
Gemini 3.1 Pro and Gemini Flash: The model ‘watches’ the video and ‘listens’ to the audio and dialogue simultaneously while also sensing emotional themes, lighting, objects, places, actions, and scene context. This allows the ABF to identify nuanced narrative beats like a cliffhanger or a subplot handoff, which might be invisible to image only or rule based systems.
-
Gemini can evaluate a potential ad spot by looking at the segments preceding and following it, leveraging its deep temporal understanding to grasp the true narrative flow. For Ad Break Finder 3.0, this means Gemini doesn’t just register a rigid cue like a two-second silent pause; it recognizes that a character is in the middle of a continuous thought process. By understanding this sequence of events over time, the pipeline chooses a much more appropriate transition point, preserving viewer immersion.
-
Googler golden advice: Tubi initially built this on 1.5 Pro but we recommend using the newer 3.1 model if you are building something similar
-
-
Gemini Enterprise batch inferencing: Utilized to process high volumes of data asynchronously, providing a 50% discount compared to real time API pricing.
-
Databricks: Functions as the primary data warehouse for storing extracted metadata and grounding the models.
Under the hood
The pipeline uses a Directed Acyclic Graph (DAG) structure to manage dependencies. A critical prerequisite in the DAG is a content moderation layer, ensuring that safety guardrails are consistent across all downstream applications.
Tubi uses a tiered architecture. They used Gemini Flash models for high speed, low cost tasks like uniform chunking and initial scene boundary detection. Once those ‘natural boundaries’ are found, the pipeline routes the high complexity work (ie. sentiment analysis) to Gemini Pro models. This tiered approach optimizes both latency and cost.
-
Segmentation strategy: Processing a 2hr movie shot in 4K in one go is inefficient. Tubi uses VLM driven chunking where Gemini Flash identifies natural scene boundaries, and the pipeline then extracts 5min segments for ad analysis or 20-40 sec segments for metadata tagging.
-
External schema enforcement + retry logic: Gemini helps with external output validation. Instead of relying on a prompt like ‘export as JSON’, Tubi uses Gemini’s structured output capabilities and regex constraints. This forces the model to adhere to a strict JSON schema (ie, specific timestamp formats). If an output fails this validation, the platform’s orchestration layer triggers an automatic retry, ensuring the data landing in Tubi’s Databricks warehouse is 100% reliable.
### DAG Example
ad_breakfinder: %{
ai_preprocessing_ad_breakfinder: [],
ai_analysis_ad_breakfinder: [:ai_preprocessing_ad_breakfinder],
ai_postprocessing_ad_breakfinder: [
:ai_analysis_ad_breakfinder,
:ai_preprocessing_ad_breakfinder
],
delivery: [:ai_postprocessing_ad_breakfinder]
}
Sample prompt
**Analyze the video and identify natural opportunities for advertising breaks.
Select moments where a scene or narrative beat clearly ends before a new one begins.
Consider changes in environment, characters, atmosphere, and breaks in dialogue, music, or motion.
Avoid ordinary camera cuts and any moment that interrupts ongoing dialogue, action, or an important emotional beat.
When uncertain, omit the candidate.
Return the strongest opportunities as JSON objects containing a timestamp and a brief reason.
**
The technical wins
-
Hours reclaimed: Migrating off legacy cue points saved tens of thousands of hours of manual processing.
-
Velocity and cost efficiency: Media Vision has covered 50% of Tubi’s catalog while reducing cost associated with preview generation by half.
-
Massive scale: ABF processed 500k titles in 20 days with Gemini’s batch inferencing.
-
Privacy: This advertising model targets the context of the media, not individual user data, emphasizing Tubi’s commitment to consumer privacy.
What we learned
Share “The Golden Path”—the best practices discovered during the build.
-
Lesson 1: Avoid prompt overloading
-
Old way: Tubi initially tried to make single prompts do too much. They attempted to make one model call identify objects, detect ad breaks, and score sentiment all at once. This led to a significant deterioration in metadata quality.
-
Golden path: Keep use cases highly tailored. Use specific model calls for specific tasks. It is more reliable to run a dedicated prompt for “Ad Breaks” and another for “Sentiment” than one catch all prompt.
-
-
Lesson 2: Rules vs. intent
-
Old way: Programming explicit rules (i.e., if 2 seconds of black frames, then cut to add) produced brittle, jarring ad breaks that ignored the story.
-
Golden path: Use intent based development. Define the goal for the AI agent (e.g., find a natural subplot transition) and provide examples. This allows the model to handle open ended narrative questions that code cannot solve.
-
-
Lesson 3: Prompt-based vs. external schema enforcement
-
Old way: Relying on prompt instructions to format JSON. This frequently resulted in non-deterministic characters that broke production ingestion.
-
Golden path: Bake external schema enforcement into the data instructions. Use the structured output capabilities of the Gemini Enterprise platform and regex constraints to ensure the model limits itself to the tokens you specified.
-
Building something similar?
Read our multimodal prompting guide
Try the ‘Build an Agent Platform Pipeline’ tutorial
Learn more about multimodal RAG orchestration
Questions:
How are you handling the trade off between VLM accuracy and latency for long form video?
Are you utilizing lighter models like Flash for pre-processing, or moving straight to larger context windows?

