Traditional video captioning systems often process every extracted frame independently, resulting in redundant captions, increased latency, and unnecessary Vision Language Model (VLM) API calls. This project introduces an event-driven video captioning pipeline that intelligently identifies only the most meaningful moments in a video before generating captions. The system combines CLIP-based semantic similarity with optical flow motion analysis to compute a hybrid event score for every extracted frame. Significant scene changes are detected using SciPy peak detection and merged into coherent events, allowing the pipeline to reduce the number of frames sent to the VLM by approximately 90–95% while preserving important context. Each detected event is captioned using MiniMax M3 through the Fireworks AI API. To improve temporal consistency across multiple events, the previous event's summary is passed as contextual memory into subsequent caption generation requests. These event descriptions are then combined into a canonical narrative before generating four stylistic caption variations: Formal, Sarcastic, Humorous (Tech), and Humorous (Non-Tech). The application is implemented in Python using FastAPI, OpenCV, OpenCLIP, PyTorch, SciPy, NumPy, and Docker. It includes asynchronous API requests, structured logging, retry mechanisms for robust VLM communication, and a production-ready architecture. The solution is designed to be scalable, cost-efficient, and easily deployable while maintaining high-quality video understanding.
Category tags: