
This project is a Dockerized AI agent that automatically generates stylistically diverse captions for video clips using a two-stage prompting pipeline. Built for the AMD Pervasive AI Developer Contest, the agent reads video captioning tasks from a JSON input file, processes each video through multimodal AI analysis, and produces captions in four distinct tones: formal, sarcastic, humorous-tech, and humorous-non-tech. The architecture follows a producer-consumer pattern with model pooling to maximize throughput while respecting free-tier API rate limits across multiple providers. Stage 1 (producers) uses two Gemini 2.5 Flash instances from separate Google Cloud projects to concurrently generate objective video descriptions. Each video is downloaded, keyframes are extracted locally via ffmpeg, and the frames are sent to Gemini's multimodal API for factual content analysis. Descriptions are pushed into an asyncio.Queue that bridges the two stages. Stage 2 (consumers) employs three text-to-text models — Groq Llama 3.3 70B, Mistral Small, and Gemini 3.1 Flash Lite — managed as a rotating pool. When a description arrives in the queue, an available caption model is popped from the pool, generates all four styled captions, then re-enters the pool after a 5-second cooldown to avoid rate limiting. This design distributes load across independent providers with separate quotas, eliminating single-point-of-failure rate limit issues. The system is fully config-driven through a JSON file specifying providers, models, API key references, and cooldown parameters. All provider implementations share abstract base classes (DescriptionProvider, CaptionProvider), making it trivial to add new models. The agent handles failures gracefully with retry logic (exponential backoff), keyframe fallback when video upload fails, and partial result writing if the 8-minute runtime threshold is reached. The Docker image targets linux/amd64 on python:3.11-slim with ffmpeg included.
13 Jul 2026