The script first loads the video file from local storage, validates the format, and prepares it for upload to Gemini. It sends the file as a multipart request or file object, depending on the API flow, so the model can inspect both visual frames and audio context. This step ensures the video is fully available to Gemini before analysis begins.
After upload, the script sends a structured prompt that tells Gemini exactly what to generate: a concise caption, an engaging social-ready variation, and relevant trending hashtags based on the video’s visuals and audio. The prompt can also specify tone, length, and output format so the response stays practical for developers and content creators using Gemini Video Captioner.
The returned response is parsed from Gemini’s text output into clear fields for captions and hashtags. The script then displays the results in a readable layout, making it easy to copy, review, or reuse in a post. If the response includes multiple suggestions, the script can separate them into distinct sections for quick comparison.