import cv2 from moviepy.editor import VideoFileClip from gemini_vision import process_frame_with_gemini, summarize_with_gemini, extract_code_with_gemini def frame_generator(video_path): video = cv2.VideoCapture(video_path) while True: ret, frame = video.read() if not ret: break yield frame video.release() def process_video(video_path, summary_words): # Process frames with Gemini Vision Pro extracted_text = "" for frame in frame_generator(video_path): extracted_text += process_frame_with_gemini(frame) + " " # Extract audio and transcribe video = VideoFileClip(video_path) audio = video.audio audio_path = "temp_audio.wav" audio.write_audiofile(audio_path) # Use Gemini Vision Pro for transcription (assuming it can handle audio) transcription = process_frame_with_gemini(audio_path, mode="audio") # Summarize content using Gemini summary = summarize_with_gemini(transcription, max_words=summary_words) # Extract code using Gemini extracted_code = extract_code_with_gemini(transcription) return { 'summary': summary, 'extracted_text': extracted_text, 'transcription': transcription, 'extracted_code': extracted_code }