File size: 2,584 Bytes
2705160 62ad9da 2705160 d123508 2705160 5e5f9d1 62ad9da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
---
title: Template Final Assignment
emoji: 🕵🏻♂️
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 5.25.2
app_file: app.py
pinned: false
hf_oauth: true
# optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes.
hf_oauth_expiration_minutes: 480
---
# Agent with YouTube Video Analysis
This agent includes advanced YouTube video analysis capabilities using yt-dlp and OpenCV for frame extraction and analysis.
## Features
### YouTube Video Analysis Tools
The agent is equipped with two powerful YouTube video analysis tools:
#### 1. `analyze_youtube_video(video_url, max_frames=6, interval_seconds=45.0)`
- **Purpose**: Downloads a YouTube video and extracts frames at regular intervals for detailed analysis
- **Parameters**:
- `video_url`: YouTube video URL (e.g., https://www.youtube.com/watch?v=VIDEO_ID)
- `max_frames`: Maximum number of frames to extract (1-10, default: 6)
- `interval_seconds`: Time interval between extractions (minimum: 10s, default: 45s)
- **Returns**: JSON with video metadata, frame timestamps, and detailed descriptions of each frame
- **Use cases**: Content analysis, scene detection, video summarization, accessibility descriptions
#### 2. `get_youtube_video_info(video_url)`
- **Purpose**: Quickly retrieves video metadata without downloading
- **Parameters**:
- `video_url`: YouTube video URL
- **Returns**: JSON with title, duration, uploader, view count, description, and resolution
- **Use cases**: Video verification, content filtering, metadata collection
### Technical Implementation
- **Video Processing**: Uses yt-dlp for robust YouTube video downloading
- **Frame Extraction**: OpenCV for efficient frame extraction and processing
- **Image Processing**: PIL and numpy for frame manipulation and encoding
- **Analysis Ready**: Frames are prepared for image analysis (base64 encoded, resized)
- **Error Handling**: Comprehensive error handling for network issues, invalid URLs, and processing failures
### Example Usage
The agent can answer questions like:
- "Analyze this YouTube video and tell me what happens: [URL]"
- "Extract 5 frames from this video every 60 seconds: [URL]"
- "What is the title and duration of this video: [URL]"
- "Describe the visual content of this tutorial video: [URL]"
### Dependencies
- yt-dlp: YouTube video downloading
- opencv-python: Computer vision and frame extraction
- PIL (Pillow): Image processing
- numpy: Numerical operations
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |