Skip to main content
Build an AI agent that analyzes YouTube videos and creates structured summaries with accurate timestamps. This agent extracts key insights from video content, making it easy to navigate educational videos, tutorials, and presentations without watching them in full.

What You’ll Learn

By building this agent, you’ll understand:
  • How to integrate YouTube transcript extraction into agents
  • How to structure prompts for consistent timestamp generation
  • How to organize video content into logical sections
  • How to create agents that transform unstructured media into searchable content

Use Cases

Create study guides from lectures, extract insights from conference talks, build searchable video indexes, or generate documentation from tutorial videos.

How It Works

The agent uses YouTubeTools to fetch video transcripts and metadata, then analyzes the content to:
  1. Extract: Gets video metadata (title, duration) and full transcript
  2. Analyze: Identifies video type and content structure
  3. Organize: Creates timestamps for major topic transitions
  4. Summarize: Generates section-based summaries with key points
The structured output makes long-form video content quickly scannable and searchable.

Code

youtube_agent.py
from textwrap import dedent

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.youtube import YouTubeTools

youtube_agent = Agent(
    name="YouTube Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[YouTubeTools()],
    instructions=dedent("""\
        You are an expert YouTube content analyst with a keen eye for detail! 🎓
        Follow these steps for comprehensive video analysis:
        1. Video Overview
           - Check video length and basic metadata
           - Identify video type (tutorial, review, lecture, etc.)
           - Note the content structure
        2. Timestamp Creation
           - Create precise, meaningful timestamps
           - Focus on major topic transitions
           - Highlight key moments and demonstrations
           - Format: [start_time, end_time, detailed_summary]
        3. Content Organization
           - Group related segments
           - Identify main themes
           - Track topic progression

        Your analysis style:
        - Begin with a video overview
        - Use clear, descriptive segment titles
        - Include relevant emojis for content types:
          📚 Educational
          💻 Technical
          🎮 Gaming
          📱 Tech Review
          🎨 Creative
        - Highlight key learning points
        - Note practical demonstrations
        - Mark important references

        Quality Guidelines:
        - Verify timestamp accuracy
        - Avoid timestamp hallucination
        - Ensure comprehensive coverage
        - Maintain consistent detail level
        - Focus on valuable content markers
    """),
    add_datetime_to_context=True,
    markdown=True,
)

# Example usage with different types of videos
youtube_agent.print_response(
    "Analyze this video: https://www.youtube.com/watch?v=zjkBMFhNj_g",
    stream=True,
)

# More example prompts to explore:
"""
Tutorial Analysis:
1. "Break down this Python tutorial with focus on code examples"
2. "Create a learning path from this web development course"
3. "Extract all practical exercises from this programming guide"
4. "Identify key concepts and implementation examples"

Educational Content:
1. "Create a study guide with timestamps for this math lecture"
2. "Extract main theories and examples from this science video"
3. "Break down this historical documentary into key events"
4. "Summarize the main arguments in this academic presentation"

Tech Reviews:
1. "List all product features mentioned with timestamps"
2. "Compare pros and cons discussed in this review"
3. "Extract technical specifications and benchmarks"
4. "Identify key comparison points and conclusions"

Creative Content:
1. "Break down the techniques shown in this art tutorial"
2. "Create a timeline of project steps in this DIY video"
3. "List all tools and materials mentioned with timestamps"
4. "Extract tips and tricks with their demonstrations"
"""

What to Expect

The agent analyzes YouTube videos by fetching transcripts and generating comprehensive breakdowns. For a typical video, you’ll receive:
  • Video metadata (title, duration, type, and audience)
  • High-level structure overview
  • Timestamped breakdown of major topics with key examples
  • Content organization showing recurring themes
  • Practical highlights and actionable takeaways
Analysis typically takes 30-60 seconds depending on video length and complexity.

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set your API key

export OPENAI_API_KEY=xxx
3

Install libraries

pip install -U agno openai youtube_transcript_api
4

Run Agent

python youtube_agent.py

Next Steps

  • Try analyzing different video types (tutorials, lectures, reviews)
  • Modify instructions to focus on specific content types
  • Combine with other tools for enhanced analysis
  • Explore Tools for additional capabilities