Source: docs/guides/youtube-character-tracking-guide.md
YouTube Sports Analyzer - Character Tracking & LangMem Integration Guide
π― Overview
The YouTube Sports Analyzer now includes advanced multi-character tracking with LangMem integration and Pydantic-based structured output. This allows you to track individual players/characters and their actions throughout sports videos with intelligent memory storage.
β¨ Key Features
π₯ Multi-Character Tracking
- Track multiple players/characters simultaneously
- Sport-specific action types (goals, assists, fouls, etc.)
- Individual performance metrics and statistics
- Team-level aggregations and comparisons
π§ LangMem Integration
- Automatic storage of character data in LangMem memory system
- Cross-session character performance analysis
- Intelligent context for future video analysis
- Session-based memory management with UUID tracking
π Pydantic Statistics Output
- Structured, validated data models for all character information
- Type-safe statistics with automatic validation
- Exportable JSON and CSV formats
- Comprehensive error handling and data integrity
ποΈ Data Models
CharacterAction
{
"timestamp": "15:30",
"action_type": "goal",
"description": "Brilliant solo goal from outside the box",
"impact_score": 9.5,
"confidence": 0.95
}CharacterProfile
{
"character_id": "player_001",
"name": "Lionel Messi",
"team": "Barcelona",
"jersey_number": 10,
"position": "Forward",
"first_detected": "00:05:30",
"last_seen": "01:45:20",
"detection_confidence": 0.95
}MultiCharacterReport
- Complete analysis report with all characters
- Team statistics and comparisons
- Key moments analysis across all characters
- Performance summaries and insights
- LangMem storage metadata
π Action Types Supported
Universal Actions
GOAL,ASSIST,SHOT,SAVE,FOUL,PENALTY
Sport-Specific Actions
- Soccer:
YELLOW_CARD,RED_CARD,CORNER,OFFSIDE - Basketball:
THREE_POINTER,REBOUND,STEAL,BLOCK,TURNOVER - Football:
TOUCHDOWN,INTERCEPTION,SACK,FUMBLE - Hockey:
HIT,FACEOFF_WIN - Tennis:
ACE,WINNER,UNFORCED_ERROR - Combat Sports:
KNOCKDOWN,SUBMISSION_ATTEMPT
βοΈ Configuration Options
Character Tracking Settings
- Enable Multi-Character Tracking: Toggle character tracking on/off
- Track All Characters: Track all detected characters or limit to specific ones
- Store in LangMem: Save character data to LangMem for cross-session analysis
- Min Impact Threshold: Only track actions above this impact score (0-10)
- Max Characters: Maximum number of characters to track simultaneously (1-20)
LangMem Storage Pattern
Following the established LangMem pattern:
Namespace: "sports_videos"
User ID: {session_uuid}
Collection: "character_tracking"
Content: JSON with character statistics and performance dataπ Analysis Output
Individual Character Statistics
- Complete action breakdown with timestamps
- Total impact scores and averages
- Action type distribution charts
- Performance timeline visualization
Team-Level Analysis
- Team performance comparisons
- Player distribution by team
- Aggregate impact scores
- Key players identification
Key Moments Analysis
- Top 10 highest impact moments across all characters
- Cross-character event correlation
- Timeline visualization of critical actions
Export Options
- JSON Export: Complete character report in structured format
- CSV Export: Character profiles and summary statistics
- LangMem Session: View stored memory session details
π Usage Example
- Input Video: Paste YouTube URL
- Configure Tracking: Enable character tracking in sidebar
- Set Parameters: Adjust impact threshold and max characters
- Analyze: Click "Analyze Video"
- View Results: Browse individual character stats, team comparisons, and key moments
- Export Data: Download structured reports in JSON/CSV format
πΎ LangMem Benefits
Cross-Session Analysis
- Compare character performance across multiple videos
- Track player development over time
- Identify performance patterns and trends
Intelligent Context
- Previously analyzed characters provide context for new videos
- Sport-specific action patterns learned from historical data
- Improved action detection based on stored character profiles
Memory Management
- Automatic session tracking with UUIDs
- Organized storage by video and character
- Efficient retrieval for performance comparisons
π‘οΈ Error Handling
The system includes comprehensive error handling:
- Graceful fallback when LangMem is unavailable
- Validation of all character data inputs
- Safe data access patterns throughout
- User-friendly error messages with technical details available
π Future Enhancements
- Real-time character tracking for live streams
- Machine learning-based action detection
- Cross-video character performance comparisons
- Advanced analytics and predictive modeling
- Integration with sports databases for enhanced player profiles
Ready to track your sports characters with intelligent memory? π